0
votes

I'm using PCIe bus on Freescale MPC8308 (as root complex) and the endpoint device is an ASIC with just one 256 MB memory region and just one BAR register. The device configuration space registers are readily accessible through "pciutils" package. At first I tried to access memory region by using mmap() but it didn't work. So at the next level, I prepared a device driver for the PCIe endpoint device which is a kernel module that I load into kernel after Linux booting.

In my driver the endpoint device is identified from device ID table but when I want to enable the device by pci_enable_device(), I see this error:

driver-pci 0000:00:00.0: device not available because of BAR 0 [0x000000-0xfffffff] collisions

Also when I want to allocate memory region for PCIe device by using pci_request_region(), it is not possible.

Here is the part of driver code which is not working:

pci_enable_result = pci_enable_device (pdev);
if (pci_enable_result)
{
  printk(KERN_INFO "PCI enable encountered a problem \n");
  return pci_enable_result;
}
else
{
  printk(KERN_INFO "PCI enable was succesfull \n");
}

And here is the result in "dmesg" :

driver-pci 0000:00:00.0: device not available because of BAR 0 [0x000000-0xfffffff] collisions

PCI enable encountered a problem

driver-pci: probe of 0000:00:00.0 failed with error -22

It is worth noting that in the driver I can read and write configuration registers correctly by using functions like pci_read_config_dword() and pci_write_config_dword().

What's the problem do you think? is it possible that the problem appears because the kernel initializes the device prior to kernel module? what should I do to prevent this to occur?

1
Your hardware is broken. In usual working system you have to be sure that there is no collisions in bus address space. Otherwise you need to reallocate it.0andriy
@AndyShevchenko ,Thanks Andy, if I want to reallocate the whole bus addresses and memory regions; is there any way that I can remove currently allocated address space for PCI devices?ali rasteh

1 Answers

0
votes

BAR registers access are generally for small region. Your BAR0 size seems to be too large. Try with less memory (less than 1MB), it should works.