Skip to content

Commit 8358e8f

Browse files
davejiangdjbw
authored andcommitted
cxl: Add support for reading CXL switch CDAT table
Add read_cdat_data() call in cxl_switch_port_probe() to allow reading of CDAT data for CXL switches. read_cdat_data() needs to be adjusted for the retrieving of the PCIe device depending on if the passed in port is endpoint or switch. Reviewed-by: Davidlohr Bueso <dave@stgolabs.net> Reviewed-by: Ira Weiny <ira.weiny@intel.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Dave Jiang <dave.jiang@intel.com> Link: https://lore.kernel.org/r/169713682855.2205276.6418370379144967443.stgit@djiang5-mobl3 Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 670e4e8 commit 8358e8f

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

drivers/cxl/core/pci.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -613,18 +613,30 @@ static unsigned char cdat_checksum(void *buf, size_t size)
613613
*/
614614
void read_cdat_data(struct cxl_port *port)
615615
{
616-
struct cxl_memdev *cxlmd = to_cxl_memdev(port->uport_dev);
617-
struct device *host = cxlmd->dev.parent;
616+
struct device *uport = port->uport_dev;
618617
struct device *dev = &port->dev;
619618
struct pci_doe_mb *cdat_doe;
619+
struct pci_dev *pdev = NULL;
620+
struct cxl_memdev *cxlmd;
620621
size_t cdat_length;
621622
void *cdat_table;
622623
int rc;
623624

624-
if (!dev_is_pci(host))
625+
if (is_cxl_memdev(uport)) {
626+
struct device *host;
627+
628+
cxlmd = to_cxl_memdev(uport);
629+
host = cxlmd->dev.parent;
630+
if (dev_is_pci(host))
631+
pdev = to_pci_dev(host);
632+
} else if (dev_is_pci(uport)) {
633+
pdev = to_pci_dev(uport);
634+
}
635+
636+
if (!pdev)
625637
return;
626-
cdat_doe = pci_find_doe_mailbox(to_pci_dev(host),
627-
PCI_DVSEC_VENDOR_ID_CXL,
638+
639+
cdat_doe = pci_find_doe_mailbox(pdev, PCI_DVSEC_VENDOR_ID_CXL,
628640
CXL_DOE_PROTOCOL_TABLE_ACCESS);
629641
if (!cdat_doe) {
630642
dev_dbg(dev, "No CDAT mailbox\n");

drivers/cxl/port.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ static int cxl_switch_port_probe(struct cxl_port *port)
6262
struct cxl_hdm *cxlhdm;
6363
int rc;
6464

65+
/* Cache the data early to ensure is_visible() works */
66+
read_cdat_data(port);
67+
6568
rc = devm_cxl_port_enumerate_dports(port);
6669
if (rc < 0)
6770
return rc;

0 commit comments

Comments
 (0)