Linux中如何读取扩展PCIE配置空间?

发布于 2024-11-15 02:41:06 字数 195 浏览 11 评论 0原文

我尝试过读取 /proc/bus/pci 目录下的用户空间 pci 条目并在驱动程序中调用内核空间 API pci_read_config_word() 。但似乎两者都只能读取pci基本配置空间,偏移量小于0x100。

我想读取的偏移量超出了0x100,谁能告诉我如何在Linux中做到这一点?如果在内核空间中完成,告诉调用哪个 API 将非常感激。非常感谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

家住魔仙堡 2024-11-22 02:41:06

pci_read_config_word() 是正确的 API,但要访问扩展配置空间,您需要使用 MMCONFIG。这不是你设置的;如果可用,内核应选择自行使用 MMCONFIG。 看到类似的东西吗

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

你在 /proc/iomem 中 ?另外,在内核日志中,您应该会看到一些有关 ACPI MCFG 表和 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)

当然,您的内核需要使用 CONFIG_PCI_MMCONFIG=y 构建。

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.

愁杀 2024-11-22 02:41:06

我相信扩展配置空间对于非 root 用户是有限的,至少这是我在非 root 时执行 lspci 时面临的行为。您可以使用 sudo lspci -Qkxxxxnnv 查看所有 0xff0 (4080) 配置空间数据以及其他一些有用的内容。

$ sudo lspci -Qkxxxxnnv

00:1d.0 PCI bridge [0604]: Intel Corporation Comet Lake PCI Express ...
Flags: bus master, fast devsel, latency 0, IRQ 124
...
Kernel driver in use: pcieport
00: 86 80 98 a3 07 04 10 00 f0 00 04 06 10 00 81 00
...
ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

请参阅:PCI 配置空间

I believe that the extended configuration space is restricted for non-root users, at least that's the behaviour I face when executing lspci when not root. You can use sudo lspci -Qkxxxxnnv to view all 0xff0 (4080) configuration space data, and some other useful stuff.

$ sudo lspci -Qkxxxxnnv

00:1d.0 PCI bridge [0604]: Intel Corporation Comet Lake PCI Express ...
Flags: bus master, fast devsel, latency 0, IRQ 124
...
Kernel driver in use: pcieport
00: 86 80 98 a3 07 04 10 00 f0 00 04 06 10 00 81 00
...
ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

See: PCI Configuration Space

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文