PCILMR(8) The PCI Utilities PCILMR(8)

pcilmr - margin PCIe Links

pcilmr [--margin] [<margining options>] <downstream component> ...
pcilmr --full [<margining options>]
pcilmr --scan

List of the requirements for links and system settings to run the margining test.

BIOS settings (depends on the system, relevant for server baseboards with Xeon CPUs):

Turn off PCIe Leaky Bucket Feature, Re-Equalization and Link Degradation;
Set Error Thresholds to 0;
Intel VMD for NVMe SSDs - in case of strange behavior of the pcilmr, try to run it with the VMD turned off.

Device (link) requirements:

Configured by the user before running the utility, the utility does not change them:
The current Link data rate must be 16.0 GT/s or higher (right now utility supports 16 GT/s and 32 GT/s Links);
Link Downstream Component must be at D0 Power Management State.
Configured by the utility during operation, utility set them to their original state after receiving the results:
The ASPM must be disabled in both the Downstream Port and Upstream Port;
The Hardware Autonomous Speed Disable bit of the Link Control 2 register must be Set in both the Downstream Port and Upstream Port;
The Hardware Autonomous Width Disable bit of the Link Control register must be Set in both the Downstream Port and Upstream Port.

pcilmr utility allows you to take advantage of the PCIe Lane Margining at the Receiver capability which is mandatory for all Ports supporting a data rate of 16.0 GT/s or higher, including Pseudo Ports (Retimers). Lane Margining at Receiver enables system software to obtain the margin information of a given Receiver while the Link is in the L0 state. The margin information includes both voltage and time, in either direction from the current Receiver position. Margining support for timing is required, while support for voltage is optional at 16.0 GT/s and required at 32.0 GT/s and higher data rates. Also, independent time margining and independent voltage margining is optional.

Utility allows to get an approximation of the eye margin diagram in the form of a rhombus (by four points). Lane Margining at the Receiver capability enables users to margin PCIe links without a hardware debugger and without the need to stop the target system. Utility can be useful to debug link issues due to receiver margins.

However, the utility results may be not particularly accurate and, as it was found out during testing, specific devices provide rather dubious capability support and the reliability of the information they provide is questionable. The PCIe specification provides reference values for the eye diagram, which are also used by the pcilmr to evaluate the results, but it seems that it makes sense to contact the manufacturer of a particular device for references.

The PCIe Base Specification Revision 5.0 sets allowed range for Timing Margin from 20% UI to 50% UI and for Voltage Margin from 50 mV to 500 mV. Utility uses 30% UI as the recommended value for Timing - taken from NVIDIA presentation ("PCIe 4.0 Mass Electrical Margins Data Collection").

pcilmr requires root privileges (to access Extended Configuration Space), but during our testing there were no problems with the devices and they successfully returned to their normal initial state after the end of testing.

<device/component> [<domain>:]<bus>:<dev>.<func> (see lspci(8))

Margin selected Links.
Margin all ready for testing (in a meaning similar to the --scan option) Links in the system (one by one).
Scan for Links with negotiated speed 16 GT/s or higher. Mark "Ready" those of them in which at least one of the Link sides have Margining Ready bit set meaning that these Links are ready for testing and you can run utility on them.

Print Device Lane Margining Capabilities only. Do not run margining.
Specify lanes for margining.
Remember that Device may use Lane Reversal for Lane numbering. However, utility uses logical lane numbers in arguments and for logging. Utility will automatically determine Lane Reversal and tune its calls.
Default: all link lanes.
Specify Error Count Limit for margining.
Default: 4.
Specify Receivers to select margining targets.
Default: all available Receivers (including Retimers).
Specify number of lanes to margin simultaneously.
According to spec it's possible for Receiver to margin up to MaxLanes + 1 lanes simultaneously, but during testing, performing margining on several lanes simultaneously led to results that were different from sequential margining, so this feature requires additional verification and -p option right now is for experiments mostly.
Default: 1.

Use only one of -T/-t options at the same time (same for -V/-v).
Without these options utility will use MaxSteps from Device capabilities as test limit.

Time Margining will continue until the Error Count is no more than an Error Count Limit. Use this option to find Link limit.
Specify maximum number of steps for Time Margining.
Same as -T option, but for Voltage.
Specify maximum number of steps for Voltage Margining.

Save margining results in csv form into the specified directory. Utility will generate file with the name in form of "lmr_<downstream component>_Rx#_<timestamp>.csv" for each successfully tested receiver.

Utility syntax example:

pcilmr -l 0,1 -r 1,6 -TV ab:0.0 52:0.0

Examples of collected results on different systems.

lspci(8), PCI Express Base Specification (Lane Margining at Receiver)

05 April 2024 pciutils-3.12.0