PCI: Add basic Compute eXpress Link DVSEC decode
cover PCI: Add basic Compute eXpress Link DVSEC decode
This patch series implements basic Designated Vendor-Specific Extended Capabilities (DVSEC) decode for Compute eXpress Link devices, a new CPU interconnect building upon PCIe. As a basis for the CXL support it provides PCI init handling for detection, decode, and caching of CXL device capabilities. Moreover, it makes use of the DVSEC Vendor ID and DVSEC ID so as to identify a CXL capable device. (PCIe r5.0, sec 7.9.6.2)
DocLink: https://www.computeexpresslink.org/
For your reference, a parallel series of patches have been submitted to enable lspci decode of CXL DVSEC and may be tracked.
This patch makes use of pending DVSEC related header additions and the first patch of that series is included here. It can be sorted out when the upstream merge is done.
Sample dmesg output of a CXL Type 3 device (CXL.io, CXL.mem):
[ 2.997177] pci 0000:6b:00.0: CXL: Cache- IO+ Mem+ Viral- HDMCount 1 [ 2.997188] pci 0000:6b:00.0: CXL: cap ctrl status ctrl2 status2 lock [ 2.997201] pci 0000:6b:00.0: CXL: 001e 0002 0000 0000 0000 0000
David E. Box (1):
pci: Add Designated Vendor Specific Capability
Sean V Kelley (1):
PCI: Add basic Compute eXpress Link DVSEC decode
drivers/pci/Kconfig | 9 ++++ drivers/pci/Makefile | 1 + drivers/pci/cxl.c | 89 +++++++++++++++++++++++++++++++++++ drivers/pci/pci.h | 7 +++ drivers/pci/probe.c | 1 + include/linux/pci.h | 1 + include/uapi/linux/pci_regs.h | 5 ++ 7 files changed, 113 insertions(+) create mode 100644 drivers/pci/cxl.c
--
2.26.2
RFC PATCH 1/2 pci: Add Designated Vendor Specific Capability
From: "David E. Box" <[email protected]>
Add pcie dvsec extended capability id along with helper macros to retrieve information from the headers.
https://members.pcisig.com/wg/PCI-SIG/document/12335
--- include/uapi/linux/pci_regs.h | 5 +++++ 1 file changed, 5 insertions(+)
include/uapi/linux/pci_regs.h +5 -0
@@ -720,6 +720,7 @@#define PCI_EXT_CAP_ID_DPC 0x1D/* Downstream Port Containment */ #define PCI_EXT_CAP_ID_L1SS 0x1E/* L1 PM Substates */ #define PCI_EXT_CAP_ID_PTM 0x1F/* Precision Time Measurement */ +#define PCI_EXT_CAP_ID_DVSEC 0x23/* Desinated Vendor-Specific */ #define PCI_EXT_CAP_ID_DLF 0x25/* Data Link Feature */ #define PCI_EXT_CAP_ID_PL_16GT 0x26/* Physical Layer 16.0 GT/s */ #define PCI_EXT_CAP_ID_MAX PCI_EXT_CAP_ID_PL_16GT
@@ -1062,6 +1063,10 @@#define PCI_L1SS_CTL1_LTR_L12_TH_SCALE 0xe0000000/* LTR_L1.2_THRESHOLD_Scale */ #define PCI_L1SS_CTL2 0x0c/* Control 2 Register */ +/* Designated Vendor-Specific (DVSEC, PCI_EXT_CAP_ID_DVSEC) */ +#define PCI_DVSEC_HEADER1 0x4/* Vendor-Specific Header1 */ +#define PCI_DVSEC_HEADER2 0x8/* Vendor-Specific Header2 */ +/* Data Link Feature */ #define PCI_DLF_CAP 0x04/* Capabilities Register */ #define PCI_DLF_EXCHANGE_ENABLE 0x80000000/* Data Link Feature Exchange Enable */
Signature · 1 line
2.26.2
RFC PATCH 2/2 PCI: Add basic Compute eXpress Link DVSEC decode
In reply to Sean V KelleyCompute eXpress Link is a new CPU interconnect created with workload accelerators in mind. The interconnect relies on PCIe Electrical and Physical interconnect for communication. CXL devices enumerate to the OS as an ACPI-described PCIe Root Complex Integrated Endpoint.
This patch introduces the bare minimum support by simply looking for and caching the DVSEC CXL Extended Capability. Currently, only CXL.io (which is mandatory to be configured by BIOS) is enabled. In future, we will also add support for CXL.cache and CXL.mem.
DocLink: https://www.computeexpresslink.org/
--- drivers/pci/Kconfig | 9 +++++ drivers/pci/Makefile | 1 + drivers/pci/cxl.c | 89 ++++++++++++++++++++++++++++++++++++++++++++ drivers/pci/pci.h | 7 ++++ drivers/pci/probe.c | 1 + include/linux/pci.h | 1 + 6 files changed, 108 insertions(+) create mode 100644 drivers/pci/cxl.c
drivers/pci/Kconfig +9 -0
@@ -115,6 +115,15 @@ config XEN_PCIDEV_FRONTEND The PCI device frontend driver allows the kernel to import arbitrary PCI devices from a PCI backend to support PCI driver domains. +config PCI_CXL + bool "Enable PCI Compute eXpress Link" + depends on PCI + help + Say Y here if you want the PCI core to detect CXL devices, decode, and + cache the DVSEC CXL Extended Capability as configured by BIOS. + + When in doubt, say N. + config PCI_ATS bool
drivers/pci/Makefile +1 -0
@@ -30,6 +30,7 @@ obj-$(CONFIG_PCI_PF_STUB) += pci-pf-stub.o obj-$(CONFIG_PCI_ECAM) += ecam.o obj-$(CONFIG_PCI_P2PDMA) += p2pdma.o obj-$(CONFIG_XEN_PCIDEV_FRONTEND) += xen-pcifront.o +obj-$(CONFIG_PCI_CXL) += cxl.o # Endpoint library must be initialized before its users obj-$(CONFIG_PCI_ENDPOINT) += endpoint/
drivers/pci/cxl.c new file +89 -0
89 lines not on this page · raw message
drivers/pci/pci.h +7 -0
@@ -469,6 +469,13 @@ static inline void pci_ats_init(struct pci_dev *d) { }static inline void pci_restore_ats_state (struct pci_dev *dev) { }#endif /* CONFIG_PCI_ATS */ +#ifdef CONFIG_PCI_CXL +/* Compute eXpress Link */ +void pci_cxl_init (struct pci_dev *dev); +#else +static inline void pci_cxl_init (struct pci_dev *dev) { } +#endif +#ifdef CONFIG_PCI_PRI void pci_pri_init (struct pci_dev *dev);void pci_restore_pri_state (struct pci_dev *pdev);
drivers/pci/probe.c +1 -0
@@ -2371,6 +2371,7 @@ static void pci_init_capabilities(struct pci_dev *dev)pci_ptm_init (dev);/* Precision Time Measurement */ pci_aer_init (dev);/* Advanced Error Reporting */ pci_dpc_init (dev);/* Downstream Port Containment */ +pci_cxl_init (dev);/* Compute eXpress Link */ pcie_report_downtraining (dev);
include/linux/pci.h +1 -0
@@ -315,6 +315,7 @@ struct pci_dev {u16 aer_cap;/* AER capability offset */ struct aer_stats *aer_stats;/* AER stats for this device */ #endif +u16 cxl_cap;/* CXL capability offset */ u8 pcie_cap;/* PCIe capability offset */ u8 msi_cap;/* MSI capability offset */ u8 msix_cap;/* MSI-X capability offset */
Signature · 1 line
2.26.2
Quoted 9 lines · Sean V Kelley
Compute eXpress Link is a new CPU interconnect created with workload accelerators in mind. The interconnect relies on PCIe Electrical and Physical interconnect for communication. CXL devices enumerate to the OS as an ACPI-described PCIe Root Complex Integrated Endpoint.
This patch introduces the bare minimum support by simply looking for and caching the DVSEC CXL Extended Capability. Currently, only CXL.io (which is mandatory to be configured by BIOS) is enabled. In future, we will also add support for CXL.cache and CXL.mem.
This looks fine, but AFAICT, it doesn't *do* anything yet (except print a few things to dmesg). We don't normally merge code until it adds some new functionality. So just FYI that I'll wait until that new functionality comes along and then merge this as part of that series. But let me know if I'm missing something.
drivers/pci/cxl.c line 84
Quoted 6 lines
drivers/pci/cxl.c new file +6
-0+dev_info (&dev->dev,"CXL: Cache%c IO%c Mem%c Viral%c HDMCount %d\n" , + (cap &PCI_CXL_CACHE ) ?'+' :'-' , + (cap &PCI_CXL_IO ) ?'+' :'-' , + (cap &PCI_CXL_MEM ) ?'+' :'-' , + (cap &PCI_CXL_VIRAL ) ?'+' :'-' , +PCI_CXL_HDM_COUNT (cap));
These could use pci_info() and FLAG(), as in pcie_init().
include/linux/pci.h struct pci_dev { · line 318
Quoted 12 lines
drivers/pci/cxl.c new file +4
-0+dev_info (&dev->dev,"CXL: cap ctrl status ctrl2 status2 lock\n" ); +dev_info (&dev->dev,"CXL: %04x %04x %04x %04x %04x %04x\n" , + cap, ctrl, status, ctrl2, status2, lock); +}include/linux/pci.h +1
-0@@ -315,6 +315,7 @@ struct pci_dev {u16 aer_cap;/* AER capability offset */ struct aer_stats *aer_stats;/* AER stats for this device */ #endif +u16 cxl_cap;/* CXL capability offset */
Wrap in #ifdef PCI_CXL.
Hi,
Quoted 11 lines · Bjorn Helgaas
Quoted 9 lines · Sean V Kelley
Compute eXpress Link is a new CPU interconnect created with workload accelerators in mind. The interconnect relies on PCIe Electrical and Physical interconnect for communication. CXL devices enumerate to the OS as an ACPI-described PCIe Root Complex Integrated Endpoint.
This patch introduces the bare minimum support by simply looking for and caching the DVSEC CXL Extended Capability. Currently, only CXL.io (which is mandatory to be configured by BIOS) is enabled. In future, we will also add support for CXL.cache and CXL.mem.
Quoted 6 lines
This looks fine, but AFAICT, it doesn't *do* anything yet (except print a few things to dmesg). We don't normally merge code until it adds some new functionality. So just FYI that I'll wait until that new functionality comes along and then merge this as part of that series. But let me know if I'm missing something.
Correct. Understood. I’ve additional changes for CXL.mem/.cache. I’ll queue those up.
Quoted 9 lines
drivers/pci/cxl.c line 84
Quoted 7 lines
(quoted diff) +1
-0+ dev_info(&dev->dev, "CXL: Cache%c IO%c Mem%c Viral%c HDMCount%d\n",
drivers/pci/cxl.c new file +5
-0+ (cap &PCI_CXL_CACHE ) ?'+' :'-' , + (cap &PCI_CXL_IO ) ?'+' :'-' , + (cap &PCI_CXL_MEM ) ?'+' :'-' , + (cap &PCI_CXL_VIRAL ) ?'+' :'-' , + PCI_CXL_HDM_COUNT(cap));These could use
pci_info()andFLAG(), as inpcie_init().
Will do.
Quoted 6 lines
Quoted 5 lines
drivers/pci/cxl.c new file +4
-0+dev_info (&dev->dev,"CXL: cap ctrl status ctrl2 status2 lock\n" ); +dev_info (&dev->dev,"CXL: %04x %04x %04x %04x %04x %04x\n" , + cap, ctrl, status, ctrl2, status2, lock); +}
Quoted 9 lines
include/linux/pci.h struct pci_dev { · line 318
Quoted 7 lines
include/linux/pci.h +1
-0@@ -315,6 +315,7 @@ struct pci_dev {u16 aer_cap;/* AER capability offset */ struct aer_stats *aer_stats;/* AER stats for this device */ #endif +u16 cxl_cap;/* CXL capability offset */ Wrap in #ifdef
PCI_CXL.
Will do.
Thanks,
Sean