[PATCH v2] cxl: Ignore CAPI adapters misplaced in switched slots

Subsystems: char and misc drivers, the rest

STALE3675d

4 messages, 4 authors, 2016-07-11 · open the first message on its own page

[PATCH v2] cxl: Ignore CAPI adapters misplaced in switched slots

From: Philippe Bergheaud <hidden>
Date: 2016-07-01 11:33:06

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 <redacted>
---
This patch fixes Bz 142217.

Changes since v1:
  - As suggested by Fred, tell user that CAPI adapter is misplaced
    s/dev_dbg/dev_info/

 drivers/misc/cxl/pci.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c
index a08fcc8..0d69eac 100644
--- a/drivers/misc/cxl/pci.c
+++ b/drivers/misc/cxl/pci.c
@@ -1280,6 +1280,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;
@@ -1291,6 +1315,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);
 
-- 
2.8.0

Re: [PATCH v2] cxl: Ignore CAPI adapters misplaced in switched slots

From: Frederic Barrat <hidden>
Date: 2016-07-01 14:21:43


Le 01/07/2016 13:32, Philippe Bergheaud a écrit :
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 <redacted>
---
This patch fixes Bz 142217.

Changes since v1:
   - As suggested by Fred, tell user that CAPI adapter is misplaced
     s/dev_dbg/dev_info/
Thanks!

Reviewed-by: Frederic Barrat <redacted>

Re: [PATCH v2] cxl: Ignore CAPI adapters misplaced in switched slots

From: Ian Munsie <hidden>
Date: 2016-07-04 01:52:27

Acked-by: Ian Munsie <redacted>

Re: [v2] cxl: Ignore CAPI adapters misplaced in switched slots

From: Michael Ellerman <mpe@ellerman.id.au>
Date: 2016-07-11 10:19:29

On Fri, 2016-01-07 at 11:32:52 UTC, Philippe Bergheaud wrote:
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 <redacted>
Reviewed-by: Frederic Barrat <redacted>
Acked-by: Ian Munsie <redacted>
Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/3b3dcd61fa4e3604d8f1bdfd84

cheers
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help