This is not a safe assumption, because the OS may reprogram the PCI BARs
at certain times. The rule is: ALWAYS read from dev->resource[] unless
you are a bus driver (PCI bridges, for example, need to assign
resources).
Further, access to PCI BARs -and- dev->resource[] in a driver is wrong
until you have called pci_enable_device. Resource and IRQ assignment
potentially occurs at pci_enable_device time, so BAR is [potentially]
undefined before then.
Finally, make sure to use pci_resource_{start,end,len,flags} macros to
make your core more portable and future-proof.
> 2) (Basically, the question is "Do I understand Documentation/IO-mapping.txt
> right?")
> PCI memory, whenever IO type or memory type, can not be dereferenced but
> should be accessed with readb() etc. On i386, PCI mem (memory type) can be
> accessed by direct pointer access, but this is not portable.
We will yell at you mightily if you directly access PCI mem with a
pointer. As you say it only works on i386 -- but IIRC since ioremap is
required, we are perfectly free to change or modify that assumption.
For example ioremap might [have to] care about whether or not a pci mem
region is prefetchable.
-- Jeff Garzik | Game called on account of naked chick Building 1024 | MandrakeSoft | - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/