* PCI question
@ 2003-03-28 9:28 Stephen Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Stephen Cameron @ 2003-03-28 9:28 UTC (permalink / raw)
To: linux-kernel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* RE: PCI question
@ 2003-03-28 21:40 Cameron, Steve
0 siblings, 0 replies; 2+ messages in thread
From: Cameron, Steve @ 2003-03-28 21:40 UTC (permalink / raw)
To: linux-kernel
I wrote:
> Is it possible for a driver to know the size of each
> the BARs which struct pci_dev->resource[x].start corresponds with?
[...]
> 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],[...]
Duh! Now I see where it saves it in resource[x]->flags...
The low bits tell me this information. (Sorry about the noise.)
-- steve
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-03-28 21:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-28 9:28 PCI question Stephen Cameron
2003-03-28 21:40 Cameron, Steve
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®