Skip to content

Commit 1acfb9b

Browse files
Jay Fangbjorn-helgaas
authored andcommitted
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>
1 parent 7928b2c commit 1acfb9b

File tree

5 files changed

+14
-3
lines changed

5 files changed

+14
-3
lines changed

drivers/pci/pci-sysfs.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ static ssize_t max_link_speed_show(struct device *dev,
168168
return -EINVAL;
169169

170170
switch (linkcap & PCI_EXP_LNKCAP_SLS) {
171+
case PCI_EXP_LNKCAP_SLS_16_0GB:
172+
speed = "16 GT/s";
173+
break;
171174
case PCI_EXP_LNKCAP_SLS_8_0GB:
172175
speed = "8 GT/s";
173176
break;
@@ -213,6 +216,9 @@ static ssize_t current_link_speed_show(struct device *dev,
213216
return -EINVAL;
214217

215218
switch (linkstat & PCI_EXP_LNKSTA_CLS) {
219+
case PCI_EXP_LNKSTA_CLS_16_0GB:
220+
speed = "16 GT/s";
221+
break;
216222
case PCI_EXP_LNKSTA_CLS_8_0GB:
217223
speed = "8 GT/s";
218224
break;

drivers/pci/probe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ const unsigned char pcie_link_speed[] = {
592592
PCIE_SPEED_2_5GT, /* 1 */
593593
PCIE_SPEED_5_0GT, /* 2 */
594594
PCIE_SPEED_8_0GT, /* 3 */
595-
PCI_SPEED_UNKNOWN, /* 4 */
595+
PCIE_SPEED_16_0GT, /* 4 */
596596
PCI_SPEED_UNKNOWN, /* 5 */
597597
PCI_SPEED_UNKNOWN, /* 6 */
598598
PCI_SPEED_UNKNOWN, /* 7 */

drivers/pci/slot.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ static const char *pci_bus_speed_strings[] = {
7676
"2.5 GT/s PCIe", /* 0x14 */
7777
"5.0 GT/s PCIe", /* 0x15 */
7878
"8.0 GT/s PCIe", /* 0x16 */
79+
"16.0 GT/s PCIe", /* 0x17 */
7980
};
8081

8182
static ssize_t bus_speed_read(enum pci_bus_speed speed, char *buf)

include/linux/pci.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ enum pci_bus_speed {
256256
PCIE_SPEED_2_5GT = 0x14,
257257
PCIE_SPEED_5_0GT = 0x15,
258258
PCIE_SPEED_8_0GT = 0x16,
259+
PCIE_SPEED_16_0GT = 0x17,
259260
PCI_SPEED_UNKNOWN = 0xff,
260261
};
261262

include/uapi/linux/pci_regs.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@
520520
#define PCI_EXP_LNKCAP_SLS_2_5GB 0x00000001 /* LNKCAP2 SLS Vector bit 0 */
521521
#define PCI_EXP_LNKCAP_SLS_5_0GB 0x00000002 /* LNKCAP2 SLS Vector bit 1 */
522522
#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 */
523524
#define PCI_EXP_LNKCAP_MLW 0x000003f0 /* Maximum Link Width */
524525
#define PCI_EXP_LNKCAP_ASPMS 0x00000c00 /* ASPM Support */
525526
#define PCI_EXP_LNKCAP_L0SEL 0x00007000 /* L0s Exit Latency */
@@ -547,6 +548,7 @@
547548
#define PCI_EXP_LNKSTA_CLS_2_5GB 0x0001 /* Current Link Speed 2.5GT/s */
548549
#define PCI_EXP_LNKSTA_CLS_5_0GB 0x0002 /* Current Link Speed 5.0GT/s */
549550
#define PCI_EXP_LNKSTA_CLS_8_0GB 0x0003 /* Current Link Speed 8.0GT/s */
551+
#define PCI_EXP_LNKSTA_CLS_16_0GB 0x0004 /* Current Link Speed 16.0GT/s */
550552
#define PCI_EXP_LNKSTA_NLW 0x03f0 /* Negotiated Link Width */
551553
#define PCI_EXP_LNKSTA_NLW_X1 0x0010 /* Current Link Width x1 */
552554
#define PCI_EXP_LNKSTA_NLW_X2 0x0020 /* Current Link Width x2 */
@@ -648,8 +650,9 @@
648650
#define PCI_CAP_EXP_RC_ENDPOINT_SIZEOF_V2 44 /* v2 endpoints without link end here */
649651
#define PCI_EXP_LNKCAP2 44 /* Link Capabilities 2 */
650652
#define PCI_EXP_LNKCAP2_SLS_2_5GB 0x00000002 /* Supported Speed 2.5GT/s */
651-
#define PCI_EXP_LNKCAP2_SLS_5_0GB 0x00000004 /* Supported Speed 5.0GT/s */
652-
#define PCI_EXP_LNKCAP2_SLS_8_0GB 0x00000008 /* Supported Speed 8.0GT/s */
653+
#define PCI_EXP_LNKCAP2_SLS_5_0GB 0x00000004 /* Supported Speed 5GT/s */
654+
#define PCI_EXP_LNKCAP2_SLS_8_0GB 0x00000008 /* Supported Speed 8GT/s */
655+
#define PCI_EXP_LNKCAP2_SLS_16_0GB 0x00000010 /* Supported Speed 16GT/s */
653656
#define PCI_EXP_LNKCAP2_CROSSLINK 0x00000100 /* Crosslink supported */
654657
#define PCI_EXP_LNKCTL2 48 /* Link Control 2 */
655658
#define PCI_EXP_LNKSTA2 50 /* Link Status 2 */

0 commit comments

Comments
 (0)