From: Stephen Cameron <steve.cameron@hp.com>
To: linux-kernel@vger.kernel.org
Subject: PCI question
Date: Fri, 28 Mar 2003 15:28:45 +0600 [thread overview]
Message-ID: <20030328092845.GA1029@zuul.cca.cpqcorp.net> (raw)
Is it possible for a driver to know the size of each
the BARs which struct pci_dev->resource[x].start corresponds with?
(e.g. whether it is a 64 bit BAR, or a 32 bit BAR?)
Why do I need to do this?
Because I have a controller (cciss driver) where some
BARS may be sometimes 32 bit, sometimes 64 bit (depending
on the board).
There's a sequence that you have to go through while init'ing
the board where you get an offset from PCI BAR 0 to know what
BAR to use for a certain other bit of memory.
Rather than reading that BAR directly, I want to use what's
in struct pci_dev->resource[x].start, but I do not know what
'x' is. (I need to find x.)
Currently the code assumes all the BARs are 32 bits, so it does
something like this.
x = (my_bar_offset - PCI_BASE_ADDRESS_0)/4;
Instead, I need to do something along the lines of:
offset = 0;
for (i=0;i<DEVICE_COUNT_RESOURCES;i++) {
if offset == (my_bar_offset - PCI_BASE_ADDRESS_0) {
x = offset;
break;
}
if ( BAR i is 32 bit )
offset += 4;
else if ( BAR i is 64 bit )
ofset += 8;
}
if (i==DEVICE_COUNT_RESOURCES)
offset = -1; /* didn't find it */
But I need to be able to figure out how big each BAR is.
Can I do that without going thru all the rigamarole of
writing all 0xfffff's to the BAR, then reading it back,
etc?
I didn't see anywhere in struct pci_dev->resource[x]
where the size of the bar was saved. It didn't seem
to be encoded in the flags that I could see...
drivers/pci/pci.c:read_pci_bases() looks like it tests
to see if BARs are 32 or 64 bit, but does not save this
information in pci_dev->resource[x], except in the fact that
if fills in the topmost 32 bits of addr.
Any ideas?
Another idea is to just catalog the boards and
just "know" which boards have 64 bit BARs and where,
but I'd rather have more general code.
Thanks,
-- steve
next reply other threads:[~2003-03-28 21:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-03-28 9:28 Stephen Cameron [this message]
2003-03-28 21:40 Cameron, Steve
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=20030328092845.GA1029@zuul.cca.cpqcorp.net \
--to=steve.cameron@hp.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
all inboxes | Powered by JetHome®