I have noticed pci_resource_start(pdev, bar)
returns different address in each boot on the same machine. If it returns a 'physical address', shouldn't it be consistent on same machine? Am I missing something?
Asked
Active
Viewed 790 times
2

keye
- 135
- 1
- 14
-
My answer is a bit vague because the question is a bit vague. If you would like to give a concrete example, I could perhaps be more specific in the answer. – prl Apr 27 '19 at 00:40
-
PCI resources are allocated at run-time, the device only provides a window it needs. The firmware / OS tries to find such window in the resources provided by the PCI Root Bridge. So, PCI device does not know in advance which physical address will be dedicated for it. – 0andriy Apr 29 '19 at 20:41
1 Answers
1
The BIOS and/or the OS allocates address space for each device on each boot. There's no requirement for consistency from one boot to the next, but one would expect the algorithms to be deterministic. Any change to the system hardware or boot parameters could cause it to vary. (For example, even leaving a USB device plugged in across boot could conceivably cause variation.) I haven't noticed address space assignment changing when rebooting without any other changes.

prl
- 11,716
- 2
- 13
- 31
-
Thanks. On my setup it actually changes each time even though no external devices (other than keyboard and mouse) being plugged/unplugged. – keye Apr 27 '19 at 02:14
-
Would you be willing to dump all your PCI devices and their BARs (twice) and add it to the question. (lspci -v) – prl Apr 27 '19 at 05:40
-
1@keye, if you have firmware / OS which does allocating resources in parallel fashion, it might be that one device is enumerated earlier than another. Same could happen if you have, for example, two identical devices in the neighbour slots, one may require sligtly more time to set up hardware. – 0andriy Apr 29 '19 at 20:44