Skip to content

PCIe Resource Allocation and Access

How PCIe address space and resources are allocated and accessed from a Linux system.

This English edition retains the original diagrams and practical code or command examples.

Reference diagram 1

Commands and examples

hywel@ubuntu:~$ grep MMCONFIG -i /proc/iomem 
  00000000-00000000 : PCI MMCONFIG 0000 [bus 00-7f]
# 读取
hywel@ubuntu:~$ lspci -xxx
00:00.0 Host bridge: Intel Corporation 440BX/ZX/DX - 82443BX/ZX/DX Host bridge (rev 01)
00: 86 80 90 71 06 00 00 02 01 00 00 06 00 00 00 00
10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
20: 00 00 00 00 00 00 00 00 00 00 00 00 ad 15 76 19
30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
# 省略很多
# ...
00:07.1 IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01)
00: 86 80 11 71 05 00 80 02 01 8a 01 01 00 40 00 00
10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
20: 61 10 00 00 00 00 00 00 00 00 00 00 ad 15 76 19
30: 00 00 00 00 00 00 00 00 00 00 00 00 ff 00 00 00
# 读取
hywel@ubuntu:~$ lspci -s 00:07.1 VENDOR_ID
# 写入。。注意当前是什么设备,有时候写完后不正常了
hywel@ubuntu:~$ lspci -s 00.07.1 VENDOR_ID=0X111
lspci -s 00:07.1 vxxxx|less

Practical notes

Validate pin multiplexing, clocks, power sequencing, kernel configuration, and device-tree bindings on the target board before drawing conclusions from a test result.