Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cxl/pci: Cache device DVSEC offset

The PCIe device DVSEC, defined in the CXL 2.0 spec, 8.1.3 is required to
be implemented by CXL 2.0 endpoint devices. In preparation for consuming
this information in a new cxl_mem driver, retrieve the CXL DVSEC
position and warn about the implications of not finding it. Allow for
mailbox operation even if the CXL DVSEC is missing.

Signed-off-by: Ben Widawsky <ben.widawsky@intel.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/164375309615.513620.7874131241128599893.stgit@dwillia2-desk3.amr.corp.intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>

authored by

Ben Widawsky and committed by
Dan Williams
06e279e5 4112a08d

+8
+2
drivers/cxl/cxlmem.h
··· 98 98 * 99 99 * @dev: The device associated with this CXL state 100 100 * @regs: Parsed register blocks 101 + * @cxl_dvsec: Offset to the PCIe device DVSEC 101 102 * @payload_size: Size of space for payload 102 103 * (CXL 2.0 8.2.8.4.3 Mailbox Capabilities Register) 103 104 * @lsa_size: Size of Label Storage Area ··· 127 126 struct device *dev; 128 127 129 128 struct cxl_regs regs; 129 + int cxl_dvsec; 130 130 131 131 size_t payload_size; 132 132 size_t lsa_size;
+6
drivers/cxl/pci.c
··· 408 408 if (IS_ERR(cxlds)) 409 409 return PTR_ERR(cxlds); 410 410 411 + cxlds->cxl_dvsec = pci_find_dvsec_capability( 412 + pdev, PCI_DVSEC_VENDOR_ID_CXL, CXL_DVSEC_PCIE_DEVICE); 413 + if (!cxlds->cxl_dvsec) 414 + dev_warn(&pdev->dev, 415 + "Device DVSEC not present, skip CXL.mem init\n"); 416 + 411 417 rc = cxl_setup_regs(pdev, CXL_REGLOC_RBI_MEMDEV, &map); 412 418 if (rc) 413 419 return rc;