Currently the cxl driver attempts to bind to any class 1200 (processing accelerator) device, and only works out whether it's actually a CAPI card later on. This doesn't really break anything (if it's not a CAPI card, we'll abort very quickly), but ideally we'd like to remove this and be explicit about the cards we support.
For CAPI-capable FPGA devices, we currently use a regular PCI_DEVICE entry in the ID table to match the vendor and device ID. However, in the case of some bi-modal devices, such as the Mellanox ConnectX-4, this may not be sufficient. The CX-4 uses the same vendor and device ID whether in regular PCIe mode or in CAPI mode, and one of its functions in PCIe mode has a CAPI VSEC, so cxl would incorrectly try to initialise it as if it's already in CAPI mode. For this case, add a PCI_DEVICE_ACCEL macro which also checks the class number, and add a device ID for the Mellanox CX-4 in CAPI mode. Don't remove the generic class entry just yet - we'll remove it eventually after we're certain that no end users are depending on it. Suggested-by: Frederic Barrat <fbar...@linux.vnet.ibm.com> Signed-off-by: Andrew Donnellan <andrew.donnel...@au1.ibm.com> --- drivers/misc/cxl/pci.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c index d152e2d..cc66ee2 100644 --- a/drivers/misc/cxl/pci.c +++ b/drivers/misc/cxl/pci.c @@ -118,13 +118,29 @@ #define AFUD_EB_LEN(val) EXTRACT_PPC_BITS(val, 8, 63) #define AFUD_READ_EB_OFF(afu) AFUD_READ(afu, 0x48) +/* + * Matches a given PCI vendor ID and device ID, but only for class 12 + * (processing accelerators). Useful for bi-modal cards, such as the + * Mellanox ConnectX-4, which keep the same vendor/device ID + * post-mode-switch. + */ +#define PCI_DEVICE_ACCEL(vend, dev) \ + .vendor = (vend), .device = (dev), \ + .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, \ + .class = 0x120000, .class_mask = 0xff0000 + static const struct pci_device_id cxl_pci_tbl[] = { + /* FPGA devices */ { PCI_DEVICE(PCI_VENDOR_ID_IBM, 0x0477), }, { PCI_DEVICE(PCI_VENDOR_ID_IBM, 0x044b), }, { PCI_DEVICE(PCI_VENDOR_ID_IBM, 0x04cf), }, { PCI_DEVICE(PCI_VENDOR_ID_IBM, 0x0601), }, - { PCI_DEVICE_CLASS(0x120000, ~0), }, + /* Mellanox ConnectX-4 */ + { PCI_DEVICE_ACCEL(PCI_VENDOR_ID_MELLANOX, 0x1013), }, + + /* Generic match for class 120000 devices, will be removed eventually */ + { PCI_DEVICE_CLASS(0x120000, ~0), }, { } }; MODULE_DEVICE_TABLE(pci, cxl_pci_tbl); -- Andrew Donnellan OzLabs, ADL Canberra andrew.donnel...@au1.ibm.com IBM Australia Limited _______________________________________________ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev