2013-03-04 137 views
2

我是linux/kernels/drivers的新手。我正在爲嵌入式Linux(3.2.17)上的pci卡寫驅動程序。Linux PCI驅動程序 - pci_enable_device失敗

我遇到的問題是,在我的探測功能,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

你是否在熱插拔設備?或者...如果您保持設備並重新啓動PC,問題是否消失? – 2013-03-04 22:28:03

+0

我不是熱插拔設備。設備在通電時連接到電路板。重新啓動電腦並不能解決問題。感謝您的建議。 – greekygyro 2013-03-04 22:30:57

回答

1

我認爲這個問題是由於到函數pci_enable_resources()調用失敗,並失敗的原因是re不是資源 - >父節點。

資源關係是在pcibios_init()或內核啓動期間的某處建立的。

我對解決此問題的建議是,在內核建立資源關係之前,必須正確配置PCI芯片中配置空間中的BAR寄存器。然後內核將使用這些配置來開發資源關係。

+0

我認爲設備樹需要改變一點。謝謝你指出我的方向。 – greekygyro 2013-03-05 17:32:16