lkml.org 
[lkml]   [2001]   [May]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: ((struct pci_dev*)dev)->resource[...].start
"Khachaturov, Vassilii" wrote:
> Can someone please confirm if my assumptions below are correct:
> 1) Unless someone specifically tampered with my driver's device since the OS
> bootup, the mapping of the PCI base address registers to virtual memory will
> remain the same (just as seen in /proc/pci, and as reflected in <subj>)? If
> not, is there a way to freeze it for the time I want to access it?

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/

\
 
 \ /
  Last update: 2005-03-22 13:17    [W:0.063 / U:0.644 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site