2
votes

I'm fairly new to linux/kernels/drivers. I'm writing a driver for a pci card on embedded linux (3.2.17).

The problem I'm running into is that in my probe function, result = pci_enable_device(dev) fails with the following error

0000:02:00.0: device not available (can't reserve [mem 0x00000000-0x00001ff)

I'm not sure why this is or how to go about debugging it.

Please let me know what other information I should post.

edit:

lspci -v returned this

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

found this in 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]

The device in question is the 0000:02

1
Are you hot-plugging the device? Or... if you keep the device up and reboot the PC, does the problem go away?user405725
I'm not hot plugging the device. The device is attached to the board on power up. Rebooting just the PC doesn't remove the problem. Thanks for the suggestion.greekygyro

1 Answers

1
votes

I think this issue is due to the function pci_enable_resources() call failed, and failed reason is there is no resource->parent node.

The resouces relationship is built during pcibios_init() or somewhere during the kernel booting up.

My suggestion to fix this issue is that before kernel build the resources relationship, you have to configure the BAR registers correctly which are in the configuration spaces in the PCI chip. Then kernel will use these configurations to develop the resource relationship.