In what instances would you need to remap PCI BAR's

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
devsau
Member
Member
Posts: 35
Joined: Thu Jun 13, 2013 12:07 pm

In what instances would you need to remap PCI BAR's

Post by devsau »

Seen a few posts on here about doing this, but my question is, why? Afaik, wouldn't the system firmware have chosen a memory hole for this device? The system firmware sets up memory decode ranges with the chipset, what if you remap the device to an area already claimed by DRAM thus the request is never even makes it out on the PCI bus?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: In what instances would you need to remap PCI BAR's

Post by Combuster »

The only instance I'm aware of is when you actually do chipset-specific drivers or hotplug devices onto the system bus. But for most practical cases modifying BARs is nonsense.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
mathematician
Member
Member
Posts: 437
Joined: Fri Dec 15, 2006 5:26 pm
Location: Church Stretton Uk

Re: In what instances would you need to remap PCI BAR's

Post by mathematician »

In the normal course of events, you would leave them alone. If you had reason to modify them, it would be because you were doing something unusual, and you would presumably know what that something was.
The continuous image of a connected set is connected.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: In what instances would you need to remap PCI BAR's

Post by Brendan »

Hi,
devsau wrote:Seen a few posts on here about doing this, but my question is, why? Afaik, wouldn't the system firmware have chosen a memory hole for this device? The system firmware sets up memory decode ranges with the chipset, what if you remap the device to an area already claimed by DRAM thus the request is never even makes it out on the PCI bus?
To me it comes down to one simple question: Can you trust the firmware to do it right?

In some cases you can. In other cases you can't. Hot-plug has already been mentioned (firmware can't set something up properly if it's not plugged in at the time). Another case is 64-bit systems with lots of devices, where the firmware tries to squeeze everything into a ~1 GiB hole below 4 GiB (for compatibility with 32-bit OSs) and fails because ~1 GiB isn't enough space. Of course there's also dodgy firmware that gives "less than ideal results that work" (instead of "ideal results that work"), and broken firmware that doesn't work properly at all.

The other problem is that you don't know what other software did before your OS started. For example, maybe your OS supports some sort of "fast reboot" feature (like kexec) and the previous instance of your OS messed things up before starting the next instance of your OS.

Then there's special circumstances. For example, if your OS is able to configure PCI device BARs anyway, then it's not that hard to develop a special (motherboard specific) "boot from ROM" boot loader for your OS that does the bare minimum and lets the OS worry about things like configuring PCI device BARs.

Of course it is an optional feature - an OS doesn't have to do it. All I'm saying here is that there are reasons why an OS would want to do it.


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Post Reply