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

PCI: Add PCIe Device 3 Extended Capability enumeration

PCIe r7.0 Section 7.7.9 Device 3 Extended Capability Structure, defines the
canonical location for determining the Flit Mode of a device. This status
is a dependency for PCIe IDE enabling. Add a new fm_enabled flag to 'struct
pci_dev'.

Cc: Lukas Wunner <lukas@wunner.de>
Cc: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Samuel Ortiz <sameo@rivosinc.com>
Cc: Alexey Kardashevskiy <aik@amd.com>
Cc: Xu Yilun <yilun.xu@linux.intel.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Link: https://patch.msgid.link/20251031212902.2256310-6-dan.j.williams@intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>

+20
+12
drivers/pci/probe.c
··· 2283 2283 return 0; 2284 2284 } 2285 2285 2286 + static void pci_dev3_init(struct pci_dev *pdev) 2287 + { 2288 + u16 cap = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_DEV3); 2289 + u32 val = 0; 2290 + 2291 + if (!cap) 2292 + return; 2293 + pci_read_config_dword(pdev, cap + PCI_DEV3_STA, &val); 2294 + pdev->fm_enabled = !!(val & PCI_DEV3_STA_SEGMENT); 2295 + } 2296 + 2286 2297 /** 2287 2298 * pcie_relaxed_ordering_enabled - Probe for PCIe relaxed ordering enable 2288 2299 * @dev: PCI device to query ··· 2678 2667 pci_doe_init(dev); /* Data Object Exchange */ 2679 2668 pci_tph_init(dev); /* TLP Processing Hints */ 2680 2669 pci_rebar_init(dev); /* Resizable BAR */ 2670 + pci_dev3_init(dev); /* Device 3 capabilities */ 2681 2671 pci_ide_init(dev); /* Link Integrity and Data Encryption */ 2682 2672 2683 2673 pcie_report_downtraining(dev);
+1
include/linux/pci.h
··· 450 450 unsigned int pasid_enabled:1; /* Process Address Space ID */ 451 451 unsigned int pri_enabled:1; /* Page Request Interface */ 452 452 unsigned int tph_enabled:1; /* TLP Processing Hints */ 453 + unsigned int fm_enabled:1; /* Flit Mode (segment captured) */ 453 454 unsigned int is_managed:1; /* Managed via devres */ 454 455 unsigned int is_msi_managed:1; /* MSI release via devres installed */ 455 456 unsigned int needs_freset:1; /* Requires fundamental reset */
+7
include/uapi/linux/pci_regs.h
··· 755 755 #define PCI_EXT_CAP_ID_NPEM 0x29 /* Native PCIe Enclosure Management */ 756 756 #define PCI_EXT_CAP_ID_PL_32GT 0x2A /* Physical Layer 32.0 GT/s */ 757 757 #define PCI_EXT_CAP_ID_DOE 0x2E /* Data Object Exchange */ 758 + #define PCI_EXT_CAP_ID_DEV3 0x2F /* Device 3 Capability/Control/Status */ 758 759 #define PCI_EXT_CAP_ID_IDE 0x30 /* Integrity and Data Encryption */ 759 760 #define PCI_EXT_CAP_ID_PL_64GT 0x31 /* Physical Layer 64.0 GT/s */ 760 761 #define PCI_EXT_CAP_ID_MAX PCI_EXT_CAP_ID_PL_64GT ··· 1246 1245 1247 1246 /* Deprecated old name, replaced with PCI_DOE_DATA_OBJECT_DISC_RSP_3_TYPE */ 1248 1247 #define PCI_DOE_DATA_OBJECT_DISC_RSP_3_PROTOCOL PCI_DOE_DATA_OBJECT_DISC_RSP_3_TYPE 1248 + 1249 + /* Device 3 Extended Capability */ 1250 + #define PCI_DEV3_CAP 0x04 /* Device 3 Capabilities Register */ 1251 + #define PCI_DEV3_CTL 0x08 /* Device 3 Control Register */ 1252 + #define PCI_DEV3_STA 0x0c /* Device 3 Status Register */ 1253 + #define PCI_DEV3_STA_SEGMENT 0x8 /* Segment Captured (end-to-end flit-mode detected) */ 1249 1254 1250 1255 /* Compute Express Link (CXL r3.1, sec 8.1.5) */ 1251 1256 #define PCI_DVSEC_CXL_PORT 3