Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read extended PCIE configuration space in Linux?

I've tried both reading userspace pci entry under /proc/bus/pci directory and calling kernel space API pci_read_config_word() in the driver. but it seems both can only read pci basic configuration space, offset less than 0x100.

The offset I want to read is beyond 0x100, could anyone tell me how to do it in Linux? if done in kernel space, telling which API to call would be very appreciated. Thank you very much!

like image 363
OliveU Avatar asked Dec 21 '22 12:12

OliveU


1 Answers

pci_read_config_word() is the correct API, but to access extended configuration space you need to use MMCONFIG. This is not something you set up; the kernel should choose to use MMCONFIG by itself if available. Do you see anything like

e0000000-efffffff : PCI MMCONFIG 0000 [bus 00-ff]

in /proc/iomem? Also in your kernel log, you should see some lines about the ACPI MCFG table and MMCONFIG:

ACPI: MCFG 00000000bb7fec63 0003C (v01 LENOVO TP-6U    00001410 LNVO 00000001)
...
PCI: MMCONFIG for domain 0000 [bus 00-ff] at [mem 0xe0000000-0xefffffff] (base 0xe0000000)

and of course your kernel needs to be built with CONFIG_PCI_MMCONFIG=y.

like image 124
Roland Avatar answered Dec 24 '22 02:12

Roland