我对linux / kernels / drivers很新。我正在为嵌入式Linux(3.2.17)上的pci卡编写驱动程序。
我遇到的问题是,在我的探测功能中,result = pci_enable_device(dev)
失败并出现以下错误
0000:02:00.0: device not available (can't reserve [mem 0x00000000-0x00001ff)
我不确定为什么会这样或如何调试它。
请告诉我我应该发布的其他信息。
编辑:
lspci -v
返回此
02:00.0 Class 0000: Unknown device 11aa:1770 (rev 52)
Subsystem: Unknown device feed:beef
Flags: slow devsel, IRQ 16
Memory at <ignored> (32-bit, non-prefetchable)
Capabilities: [44] Vendor Specific Information
在dmesg中找到了这个
PCI: Probing PCI hardware
pci_bus 0000:00: scanning bus
pci 0000:00:00.0: [1957:0070] type 1 class 0x000b20
pci 0000:00:00.0: calling quirk_mmio_always_on+0x0/0x24
pci 0000:00:00.0: ignoring class b20 (doesn't match header type 01)
pci 0000:00:00.0: calling fixup_hide_host_resource_fsl+0x0/0x54
pci 0000:00:00.0: calling pcibios_fixup_resources+0x0/0x110
pci 0000:00:00.0: calling quirk_fsl_pcie_header+0x0/0x74
pci 0000:00:00.0: calling quirk_resource_alignment+0x0/0x19c
pci 0000:00:00.0: supports D1 D2
pci 0000:00:00.0: PME# supported from D0 D1 D2 D3hot D3cold
pci 0000:00:00.0: PME# disabled
pci_bus 0000:00: fixups for bus
pci 0000:00:00.0: scanning [bus 01-02] behind bridge, pass 0
pci 0000:00:00.0: scanning [bus 00-00] behind bridge, pass 1
pci_bus 0000:01: scanning bus
pci 0000:01:00.0: [12d8:e110] type 1 class 0x000604
pci 0000:01:00.0: calling quirk_mmio_always_on+0x0/0x24
pci 0000:01:00.0: calling pcibios_fixup_resources+0x0/0x110
pci 0000:01:00.0: calling quirk_resource_alignment+0x0/0x19c
pci 0000:01:00.0: PME# supported from D0 D3hot D3cold
pci 0000:01:00.0: PME# disabled
pci_bus 0000:01: fixups for bus
pci 0000:00:00.0: PCI bridge to [bus 01-ff]
pci 0000:00:00.0: bridge window [mem 0xc0000000-0xc00fffff]
pci 0000:01:00.0: scanning [bus 02-02] behind bridge, pass 0
pci 0000:01:00.0: scanning [bus 00-00] behind bridge, pass 1
pci_bus 0000:02: scanning bus
pci 0000:02:00.0: [11aa:1770] type 0 class 0x000000
pci 0000:02:00.0: calling quirk_mmio_always_on+0x0/0x24
pci 0000:02:00.0: reg 10: [mem 0xc0000000-0xc0001fff]
pci 0000:02:00.0: calling pcibios_fixup_resources+0x0/0x110
pci 0000:02:00.0: calling quirk_resource_alignment+0x0/0x19c
pci_bus 0000:02: fixups for bus
pci 0000:01:00.0: PCI bridge to [bus 02-ff]
pci 0000:01:00.0: bridge window [mem 0xc0000000-0xc00fffff]
pci_bus 0000:02: bus scan returning with max=02
pci_bus 0000:01: bus scan returning with max=02
pci_bus 0000:00: bus scan returning with max=02
PCI: Cannot allocate resource region 1 of PCI bridge 2, will remap
PCI: Cannot allocate resource region 0 of device 0000:02:00.0, will remap
PCI 0000:00 Cannot reserve Legacy IO [io 0xff7ec000-0xff7ecfff]
PCI: max bus depth: 2 pci_try_num: 3
pci 0000:01:00.0: BAR 8: assigned [mem 0xc0000000-0xc00fffff]
pci 0000:01:00.0: PCI bridge to [bus 02-02]
pci 0000:01:00.0: bridge window [mem 0xc0000000-0xc00fffff]
pci 0000:00:00.0: PCI bridge to [bus 01-02]
pci 0000:00:00.0: bridge window [io 0xff7ec000-0xff7fbfff]
pci 0000:00:00.0: bridge window [mem 0xc0000000-0xdfffffff]
pci 0000:00:00.0: enabling device (0106 -> 0107)
pci_bus 0000:00: resource 0 [io 0xff7ec000-0xff7fbfff]
pci_bus 0000:00: resource 1 [mem 0xc0000000-0xdfffffff]
pci_bus 0000:01: resource 0 [io 0xff7ec000-0xff7fbfff]
pci_bus 0000:01: resource 1 [mem 0xc0000000-0xdfffffff]
pci_bus 0000:02: resource 1 [mem 0xc0000000-0xc00fffff]
有问题的设备是0000:02
答案 0 :(得分:1)
我认为这个问题是由于函数pci_enable_resources()调用失败,失败的原因是没有resource-&gt;父节点。
resouces关系是在pcibios_init()期间或内核启动期间的某个地方构建的。
我建议解决此问题的方法是,在内核构建资源关系之前,必须正确配置BAR寄存器,这些寄存器位于PCI芯片的配置空间中。然后内核将使用这些配置来开发资源关系。