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!
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
.