Linux PCI/PCI-E Device configuration space Read and modify
1 Preface
PCI and PCI Express, is a high-speed bus commonly used by computers. PCI/PCI-E device drivers and operating system cores in the operating system require access to PCI and PCI-E configuration space. The normal operation of PCI/PCI-E equipment is inseparable from pci/pci-e configuration space.
By reading and writing PCI/PCI-E configuration space, you can change the operation parameters of the equipment and optimize the operation of the equipment. This article describes user space can read, modify, scan pci/pcie device users command and use.
In the Linux kernel, only one bus PCI (the kernel-provided bus system) is available for PCI and PCI-E, so accessing the PCI-E configuration space also includes the PCI device configuration space.
2 P C I e device configuration space read
The command to read the PCI-E device configuration space is lspci.
NAME
Lspci–list All PCI devices
Synopsis
LSPCI [Options]
Detailed command parameters, you can use the man lspci to view, here we only introduce common parameters.
The default output of the command is all PCI/PCI-E devices for the current system.
[Root@localhost ~]# Lspci
00:00.0 Host Bridge:intel Corporation 5500 I/O Hub to ESI Port (Rev. 13)
00:01.0 PCI Bridge:intel Corporation 5520/5500/x58 I/o Hub pci Express Root Port 1 (Rev. 13)
00:03.0 PCI Bridge:intel Corporation 5520/5500/x58 I/o Hub PCI Express Root Port 3 (Rev. 13)
00:07.0 PCI Bridge:intel Corporation 5520/5500/x58 I/o Hub PCI Express Root Port 7 (Rev. 13)
00:09.0 PCI Bridge:intel Corporation 5520/5500/x58 I/o Hub PCI Express Root Port 9 (Rev. 13)
00:10.0 Pic:intel Corporation 5520/5500/x58 physical and Link Layer registers Port 0 (Rev. 13)
00:10.1 Pic:intel Corporation 5520/5500/x58 Routing and Protocol Layer Port 0 (rev. 13)
00:11.0 Pic:intel Corporation 5520/5500 physical and Link Layer registers Port 1 (Rev. 13)
00:11.1 Pic:intel Corporation 5520/5500 Routing & Protocol Layer Register Port 1 (Rev. 13)
00:13.0 Pic:intel Corporation 5520/5500/x58 I/o Hub i/oxapic Interrupt Controller (rev. 13)
00:14.0 Pic:intel Corporation 5520/5500/x58 I/o Hub System Management registers (Rev. 13)
... ...
01:00.0 Ethernet controller:broadcom Corporation netxtreme II BCM5709 Gigabit Ethernet (rev. 20)
01:00.1 Ethernet controller:broadcom Corporation netxtreme II BCM5709 Gigabit Ethernet (rev. 20)
04:00.0 SCSI Storage Controller:lsi logic/symbios Logic sas1068e pci-express fusion-mpt SAS (rev 08)
05:00.0 VGA Compatible Controller:xgi Technology Inc. (eXtreme Graphics Innovation) z9s/z9m (XG21 Core)
[Root@localhost ~]#
Common parameters:
-V Displays the details of the device.
-VV displays more detailed information about the device.
-VVV Displays all resolvable information for the device.
-X Displays the first 64 bytes of the configuration space in 16, or the first 128 bytes of the CardBus bridge.
-XXX displays the entire PCI configuration space (256 bytes) in 16.
-XXXX Displays the entire PCI-E configuration space (4096 bytes) in 16.
-S [[[<domain>]:]<bus>]:][<slot>][.[ <FUNC>]]:
Displays the specified device.
Example:
[Root@localhost ~]# lspci-vvvxxxx-s 00:14
00:14.0 Pic:intel Corporation 5520/5500/x58 I/o Hub System Management Registers (rev) (prog-if 00 [8259])
Subsystem:unknown Device 00e5:0008
control:i/o-mem-busmaster-speccycle-memwinv-vgasnoop-parerr-stepping-serr-fastb2b-
status:cap+ 66mhz-udf-fastb2b-parerr-devsel=fast >tabort-<tabort-<mabort->SERR-
Capabilities: [+] Express Unknown type IRQ 0
Device:Supported:MaxPayload 128 Bytes, Phantfunc 0, exttag-
Device:latency l0s <64ns, L1 <1us