43

PCI Express slots on the motherboard can be wider then the number of lanes connected. For example a motherboard can have x8 slot with only x1 lane connected.

On the other hand, you can insert a card using only for ex. 4 lanes to a x16 slot on the motherboard, and they will negotiate to use only those x4 lanes.

How to check from the running system how many lanes are used by the inserted PCIe cards?

47

Ok, it seems I missed it on first try in lspci manpages.

Note: Run the command as root/sudo otherwise a lot of detail is ommitted including the Lnk output shown below.

lspci -vv displays a lot of information, including link width:

01:00.0 VGA compatible controller: nVidia Corporation G92 [GeForce 8800 GT] (rev a2) (prog-if 00 [VGA controller])
            [...]
            LnkCap: Port #0, Speed 2.5GT/s, Width x16, ASPM L0s L1, Latency L0 <512ns, L1 <1us
                    ClockPM- Surprise- LLActRep- BwNot-
            LnkCtl: ASPM Disabled; RCB 128 bytes Disabled- Retrain- CommClk+
                    ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
            LnkSta: Speed 2.5GT/s, Width x8, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
4
  • 4
    in your example the output text has both width x16 and width x8. I assume this is interpretted as: the link capacity is width x16 and this device has negotiated width x8? Nov 21 '14 at 18:26
  • 2
    Yes, that's how I understand it, too.
    – silk
    Nov 24 '14 at 10:47
  • 1
    Same as @ʇsәɹoɈ 's comment at other answer; Use root/sudo
    – hbogert
    Oct 7 '18 at 13:38
  • Bad Translation: The Chipset has lanes... I think usually just one Chipset lane at 1x the processor's fastest speed... like PCI-E 3.0. Ethernet, The subsystem the USB is attached, is the chipset one, usually. use -t to get a tree for devices that have a built in switch... which saves you PCI lanes.
    – Ray Foss
    May 27 '20 at 17:27
19

Sometimes it can be a bit more complicated.

For example, 4 Port GBit ethernet adapters have a PCIe switch on board. I trapped into an issue where I found the Ethernet Adapter connected to x4, but a bottleneck upstream when the onboard pcie switch was connected at x1 to the motherboard only.

See this thread for the issue: http://thread.gmane.org/gmane.linux.drivers.e1000.devel/15192/focus=15254

To get a grasp on tree connectivity, compare the view of

sudo lspci -tv
sudo lspci -vv | grep -P "[0-9a-f]{2}:[0-9a-f]{2}\.[0-9a-f]|LnkSta:"

The last line will show you the Link Status below every device on the bus without the overwelming detail of vv option.

1
  • 15
    Note: When run as an unprivileged user, lspci doesn't show the LnkCap / LnkSta / Width stats. Run it with sudo to see them.
    – ʇsәɹoɈ
    Jan 7 '17 at 18:44
2

I use the following commands. lspci -vv provides verbose output. It's parsed with grep to only view "Width" as follows:

lspci -vvv | egrep "0[0-9]:|Width\ "
03:00.0 Ethernet controller: Mellanox Technologies MT26448 [ConnectX EN 10GigE, PCIe 2.0 5GT/s] (rev b0)
pcilib: sysfs_read_vpd: read failed: Input/output error
        LnkCap:    Port #8, Speed 5GT/s, Width x8, ASPM L0s, Exit Latency L0s unlimited, L1 unlimited
        LnkSta:    Speed 5GT/s, Width x8, TrErr- Train- SlotClk- DLActive- BWMgmt- ABWMgmt-

Notice the two Width x8 lines above.

If LnkSta (Link Status) is less than LnkCap (Link Capability), it will display (downgraded) next to the Width. This means that the PCI card is capable of more than what the PCI slot can provide.

Next, you can view display the physical and electrical PCI port information. Physical is the actual slot size on the motherboard. Electrical is how the slot is wired to the chipset. Some motherboards will have a physical x16 slot, but only use x8 lanes.

dmidecode --type 9 | egrep "Usage|Type|Designation"

Designation: PCH SLOT1 PCI-E 3.0 X4(IN X8)
Type: x4 PCI Express 3 x8
Current Usage: Available

Designation is how the motherboard manufacturer reports the SLOT. Type is electrical and physical characteristics. (ex. electrical x4 lanes, physical slot is x8).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.