ioread32 和 pci_bus_read_config_word 包装函数有什么区别?在 pci 设备驱动程序中使用哪个更安全?

What is the difference ioread32 and pci_bus_read_config_word wrapper function? Which is one is safer to use in pci device driver?

在 pci 设备驱动程序中,我试图在 MIPS 平台中使用 ioread32 读取 PCI_COMMAND 寄存器,但抛出数据总线错误。在传递到 ioread32 之前,我已经验证了有效参数。有什么帮助吗?在这种情况下使用 pci_bus_read_config_word 是否可以防止数据总线错误?

这取决于您的平台对配置 space 访问的支持类型。有两种访问方式 -

1 - 传统 PCI 配置机制 - 这使用 IO 端口地址访问端点配置 space。您可以为此使用 ioread32()。
2 - 增强的 PCI 配置机制 - 这使用内存映射 IO。您可以使用简单的指针操作来读取它。

由于很难找到访问机制支持,因此最好使用 pci API(在本例中为 pci_bus_read_config_word),而不是使用 ioread32()。

pci_*() API 将处理对该平台有效的访问方法。