]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
cxl: Ignore CAPI adapters misplaced in switched slots
authorPhilippe Bergheaud <felix@linux.vnet.ibm.com>
Mon, 18 Jul 2016 13:56:40 +0000 (07:56 -0600)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 9 Aug 2016 13:07:32 +0000 (15:07 +0200)
BugLink: http://bugs.launchpad.net/bugs/1602785
One should not attempt to switch a PHB into CAPI mode if there is
a switch between the PHB and the adapter. This patch modifies the
cxl driver to ignore CAPI adapters misplaced in switched slots.

Signed-off-by: Philippe Bergheaud <felix@linux.vnet.ibm.com>
Reviewed-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Acked-by: Ian Munsie <imunsie@au1.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
(cherry picked from linux-next commit 3b3dcd61fa4e3604d8f1bdfd8471fca7b7c012e4)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
Acked-by: Brad Figg <brad.figg@canonical.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
drivers/misc/cxl/pci.c

index 8b551f0d4dcaa90d67d2bc39c6111be6fd8a9b9d..bf5646824873c9dfa24ad0bf18c4659ab7e564c3 100644 (file)
@@ -1281,6 +1281,30 @@ static void cxl_pci_remove_adapter(struct cxl *adapter)
        device_unregister(&adapter->dev);
 }
 
+#define CXL_MAX_PCIEX_PARENT 2
+
+static int cxl_slot_is_switched(struct pci_dev *dev)
+{
+       struct device_node *np;
+       int depth = 0;
+       const __be32 *prop;
+
+       if (!(np = pci_device_to_OF_node(dev))) {
+               pr_err("cxl: np = NULL\n");
+               return -ENODEV;
+       }
+       of_node_get(np);
+       while (np) {
+               np = of_get_next_parent(np);
+               prop = of_get_property(np, "device_type", NULL);
+               if (!prop || strcmp((char *)prop, "pciex"))
+                       break;
+               depth++;
+       }
+       of_node_put(np);
+       return (depth > CXL_MAX_PCIEX_PARENT);
+}
+
 static int cxl_probe(struct pci_dev *dev, const struct pci_device_id *id)
 {
        struct cxl *adapter;
@@ -1292,6 +1316,11 @@ static int cxl_probe(struct pci_dev *dev, const struct pci_device_id *id)
                return -ENODEV;
        }
 
+       if (cxl_slot_is_switched(dev)) {
+               dev_info(&dev->dev, "Ignoring card on incompatible PCI slot\n");
+               return -ENODEV;
+       }
+
        if (cxl_verbose)
                dump_cxl_config_space(dev);