lspci
lspci
1 | 00:00.0 Host bridge: Intel Corporation Xeon E7 v3/Xeon E5 v3/Core i7 DMI2 (rev 02) |
A general show of PCIe devices in system.
lspci -t
1 | [...] |
Show PCIe topology in tree picture. As showed in above picture, 0000:00 means
domain 0 bus 0; 01.0 means a device under bus 0, so its BDF should be 0000:00:01.0;
01.0-[01] here [01] means the bus number under device 00:01.0, some times we may
get [xx-yy] which means the bus range under this device, apparently this device
is a PCIe bridge; 01.0-[01]—-00.0 here 00.0 means a device which device:function
is 00.0, so together with its father bus, its BDF should be 0000:01:00.0.
lspci -s ff:0f.1
1 | ff:0f.1 System peripheral: Intel Corporation Xeon E7 v3/Xeon E5 v3/Core i7 Buffered Ring Agent (rev 02) |
To see the specific device information, use lspci -s BDF
lspci -vvv
1 | 80:05.4 PIC: Intel Corporation Xeon E7 v3/Xeon E5 v3/Core i7 I/O APIC (rev 02) (prog-if 20 [IO(X)-APIC]) |
To see more information, use -vvv/-vv/-v. You can see BAR in “Region”, different
bridge window range and different capabilities.
lspci -xxx
1 | 7f:13.1 System peripheral: Intel Corporation Xeon E7 v3/Xeon E5 v3/Core i7 Integrated Memory Controller 0 Target Address, Thermal & RAS Registers (rev 02) |
To see configure space as bit value, use -xxx/-xx/-x
setpci
setpci -s BDF 20.L=0x12345678
Above command set 0x20 offset of configure space of a device which BDF is BDF
to 0x12345678. L here means 32bit, W will mean 16bit, B will mean 8bit.
sysfs
remove
We can remove a device by writing 1 to its remove file.
rescan
We can rescan a device/bus by writing 1 to its rescan file, we can also rescan
whole PCIe system by echo 1 > /sys/bus/pci/rescan (need to check…).When we do rescan a device, we find its father bus, and pass this bus to PCIe
enumeration process.However, if we rescan a RP or PCIe bridge, as the structure of related RP or
PCIe bridge is still there, Linux kernel will do nothing about MEM/IO window
of related RP or PCIe bridge.(however, writing/reading MEM/IO operation will
be done to checkout if this bridge’s MEM/IO window register is working)reset
(to do…)