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

PCI: Add decoding for 16 GT/s link speed

PCIe 4.0 defines the 16.0 GT/s link speed. Links can run at that speed
without any Linux changes, but previously their sysfs "max_link_speed" and
"current_link_speed" files contained "Unknown speed", not the expected
"16.0 GT/s".

Add decoding for the new 16 GT/s link speed.

Signed-off-by: Jay Fang <f.fangjian@huawei.com>
[bhelgaas: add PCI_EXP_LNKCAP2_SLS_16_0GB]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Dongdong Liu <liudongdong3@huawei.com>

authored by

Jay Fang and committed by
Bjorn Helgaas
1acfb9b7 7928b2cb

+14 -3
+6
drivers/pci/pci-sysfs.c
··· 168 168 return -EINVAL; 169 169 170 170 switch (linkcap & PCI_EXP_LNKCAP_SLS) { 171 + case PCI_EXP_LNKCAP_SLS_16_0GB: 172 + speed = "16 GT/s"; 173 + break; 171 174 case PCI_EXP_LNKCAP_SLS_8_0GB: 172 175 speed = "8 GT/s"; 173 176 break; ··· 216 213 return -EINVAL; 217 214 218 215 switch (linkstat & PCI_EXP_LNKSTA_CLS) { 216 + case PCI_EXP_LNKSTA_CLS_16_0GB: 217 + speed = "16 GT/s"; 218 + break; 219 219 case PCI_EXP_LNKSTA_CLS_8_0GB: 220 220 speed = "8 GT/s"; 221 221 break;
+1 -1
drivers/pci/probe.c
··· 592 592 PCIE_SPEED_2_5GT, /* 1 */ 593 593 PCIE_SPEED_5_0GT, /* 2 */ 594 594 PCIE_SPEED_8_0GT, /* 3 */ 595 - PCI_SPEED_UNKNOWN, /* 4 */ 595 + PCIE_SPEED_16_0GT, /* 4 */ 596 596 PCI_SPEED_UNKNOWN, /* 5 */ 597 597 PCI_SPEED_UNKNOWN, /* 6 */ 598 598 PCI_SPEED_UNKNOWN, /* 7 */
+1
drivers/pci/slot.c
··· 76 76 "2.5 GT/s PCIe", /* 0x14 */ 77 77 "5.0 GT/s PCIe", /* 0x15 */ 78 78 "8.0 GT/s PCIe", /* 0x16 */ 79 + "16.0 GT/s PCIe", /* 0x17 */ 79 80 }; 80 81 81 82 static ssize_t bus_speed_read(enum pci_bus_speed speed, char *buf)
+1
include/linux/pci.h
··· 256 256 PCIE_SPEED_2_5GT = 0x14, 257 257 PCIE_SPEED_5_0GT = 0x15, 258 258 PCIE_SPEED_8_0GT = 0x16, 259 + PCIE_SPEED_16_0GT = 0x17, 259 260 PCI_SPEED_UNKNOWN = 0xff, 260 261 }; 261 262
+5 -2
include/uapi/linux/pci_regs.h
··· 520 520 #define PCI_EXP_LNKCAP_SLS_2_5GB 0x00000001 /* LNKCAP2 SLS Vector bit 0 */ 521 521 #define PCI_EXP_LNKCAP_SLS_5_0GB 0x00000002 /* LNKCAP2 SLS Vector bit 1 */ 522 522 #define PCI_EXP_LNKCAP_SLS_8_0GB 0x00000003 /* LNKCAP2 SLS Vector bit 2 */ 523 + #define PCI_EXP_LNKCAP_SLS_16_0GB 0x00000004 /* LNKCAP2 SLS Vector bit 3 */ 523 524 #define PCI_EXP_LNKCAP_MLW 0x000003f0 /* Maximum Link Width */ 524 525 #define PCI_EXP_LNKCAP_ASPMS 0x00000c00 /* ASPM Support */ 525 526 #define PCI_EXP_LNKCAP_L0SEL 0x00007000 /* L0s Exit Latency */ ··· 548 547 #define PCI_EXP_LNKSTA_CLS_2_5GB 0x0001 /* Current Link Speed 2.5GT/s */ 549 548 #define PCI_EXP_LNKSTA_CLS_5_0GB 0x0002 /* Current Link Speed 5.0GT/s */ 550 549 #define PCI_EXP_LNKSTA_CLS_8_0GB 0x0003 /* Current Link Speed 8.0GT/s */ 550 + #define PCI_EXP_LNKSTA_CLS_16_0GB 0x0004 /* Current Link Speed 16.0GT/s */ 551 551 #define PCI_EXP_LNKSTA_NLW 0x03f0 /* Negotiated Link Width */ 552 552 #define PCI_EXP_LNKSTA_NLW_X1 0x0010 /* Current Link Width x1 */ 553 553 #define PCI_EXP_LNKSTA_NLW_X2 0x0020 /* Current Link Width x2 */ ··· 650 648 #define PCI_CAP_EXP_RC_ENDPOINT_SIZEOF_V2 44 /* v2 endpoints without link end here */ 651 649 #define PCI_EXP_LNKCAP2 44 /* Link Capabilities 2 */ 652 650 #define PCI_EXP_LNKCAP2_SLS_2_5GB 0x00000002 /* Supported Speed 2.5GT/s */ 653 - #define PCI_EXP_LNKCAP2_SLS_5_0GB 0x00000004 /* Supported Speed 5.0GT/s */ 654 - #define PCI_EXP_LNKCAP2_SLS_8_0GB 0x00000008 /* Supported Speed 8.0GT/s */ 651 + #define PCI_EXP_LNKCAP2_SLS_5_0GB 0x00000004 /* Supported Speed 5GT/s */ 652 + #define PCI_EXP_LNKCAP2_SLS_8_0GB 0x00000008 /* Supported Speed 8GT/s */ 653 + #define PCI_EXP_LNKCAP2_SLS_16_0GB 0x00000010 /* Supported Speed 16GT/s */ 655 654 #define PCI_EXP_LNKCAP2_CROSSLINK 0x00000100 /* Crosslink supported */ 656 655 #define PCI_EXP_LNKCTL2 48 /* Link Control 2 */ 657 656 #define PCI_EXP_LNKSTA2 50 /* Link Status 2 */