Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

who and when to assign PCI/PCIe device BARs base address?

I'm looking for how kernel to do PCI/PCIe enumeration and BAR assigning.

I thought that kernel will assign PCI base addresses of BAR when start-up, but when I tried pci earlydump (before kernel initial PCI subsystem) to see the BARs valuse, I found all base addresses are already assigned !? Does it mean that BIOS do PCI/PCIe enumeration and BAR assigning? How BIOS know each pci devices base addresses and assign these without conflict?

And if so, how the embedded system(without BIOS ) to enumerate and assign base address for PCI/PCIe devices?

By the way, my PC is Ubuntu 14.04.1 LTS (x86_64)

like image 998
jia-chiam Avatar asked Sep 29 '22 20:09

jia-chiam


1 Answers

On all IBM PC-compatible machines, BARs are assigned by the BIOS. Linux simply scans through the buses and records the BAR values.

Some MIPS boards adopt similar approaches, where BARs are assigned by firmware. However, the quality of BAR assignment by firmware vary quite a bit. Some firmware simply assigns BARs to on-board PCI devices and ignore all add-on PCI cards. In that case, Linux cannot solely rely on the firmware's assignment.

There is another issue of depending on the firmware assignment. You need to stick with the address range setup by the firmware. In other words, if the firmware assigns PCI memory space from 0x10000000 to 0x14000000, you cannot easily move it to a different address space somewhere else in Linux. Source: Bar asssignment in Linux

like image 99
Sunil Bojanapally Avatar answered Oct 10 '22 18:10

Sunil Bojanapally