Skip to content

Commit

Permalink
cxl: Ignore CAPI adapters misplaced in switched slots
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Frederic Barrat <[email protected]>
Acked-by: Ian Munsie <[email protected]>
Signed-off-by: Michael Ellerman <[email protected]>
  • Loading branch information
Philippe Bergheaud authored and mpe committed Jul 8, 2016
1 parent e00878b commit 3b3dcd6
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions drivers/misc/cxl/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1402,6 +1402,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;
Expand All @@ -1413,6 +1437,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);

Expand Down

0 comments on commit 3b3dcd6

Please sign in to comment.