public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jeff Garzik <jgarzik@mandrakesoft.com>
To: "Khachaturov, Vassilii" <Vassilii.Khachaturov@comverse.com>
Cc: LINUX Kernel <linux-kernel@vger.kernel.org>
Subject: Re: ((struct pci_dev*)dev)->resource[...].start
Date: Wed, 16 May 2001 17:37:19 -0400	[thread overview]
Message-ID: <3B02F30F.5D05C77E@mandrakesoft.com> (raw)
In-Reply-To: <6B1DF6EEBA51D31182F200902740436802678ED4@mail-in.comverse-in.com>

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

  reply	other threads:[~2001-05-16 21:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-05-16 20:58 ((struct pci_dev*)dev)->resource[...].start Khachaturov, Vassilii
2001-05-16 21:37 ` Jeff Garzik [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3B02F30F.5D05C77E@mandrakesoft.com \
    --to=jgarzik@mandrakesoft.com \
    --cc=Vassilii.Khachaturov@comverse.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox