public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* ((struct pci_dev*)dev)->resource[...].start
@ 2001-05-16 20:58 Khachaturov, Vassilii
  2001-05-16 21:37 ` Jeff Garzik
  0 siblings, 1 reply; 6+ messages in thread
From: Khachaturov, Vassilii @ 2001-05-16 20:58 UTC (permalink / raw)
  To: LINUX Kernel

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?

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.

Kind regards,
	Vassilii

^ permalink raw reply	[flat|nested] 6+ messages in thread
* RE: ((struct pci_dev*)dev)->resource[...].start
@ 2001-05-16 22:13 Khachaturov, Vassilii
  0 siblings, 0 replies; 6+ messages in thread
From: Khachaturov, Vassilii @ 2001-05-16 22:13 UTC (permalink / raw)
  To: 'Jeff Garzik'; +Cc: LINUX Kernel

Jeff,
Many thanks for the clarifications.

> From: Jeff Garzik
> "Khachaturov, Vassilii" wrote:
[snip]
> > 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).
[snip]

I am not a bus driver, and I do call pci_enable_device once my device gets 
probed and recognized by my driver. I always read from dev->resource[].
But what are the "certain times" you've mentioned? What is the scope
within which I know the BARs didn't change?
 
> Finally, make sure to use pci_resource_{start,end,len,flags} macros to
> make your core more portable and future-proof.
I didn't use the macros - now I do, thanks for the tip!

> > 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 

Right now I am porting a driver to Linux which has so much i386 things in it

(esp. byte order stuff). So far I haven't spoilt it with PCI i386 hacks
though...

> 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.

A really silly q. (I don't quite understand the Linux internals yet):
Is ioremap() needed (in general vs. i386) for memory type PCI memory too, 
or only for IO type?
(In case the default size of the region associated with a BAR is fine with
me?)

Thanks,
	Vassilii

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2001-05-17  5:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-05-16 20:58 ((struct pci_dev*)dev)->resource[...].start Khachaturov, Vassilii
2001-05-16 21:37 ` Jeff Garzik
2001-05-16 23:06   ` Jonathan Lundell
2001-05-16 23:14     ` Jeff Garzik
2001-05-17  5:36   ` Albert D. Cahalan
  -- strict thread matches above, loose matches on Subject: below --
2001-05-16 22:13 Khachaturov, Vassilii

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox