Messages in this thread | | | Date | Fri, 28 Mar 2003 15:28:45 +0600 | From | Stephen Cameron <> | Subject | PCI question |
| |
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
- 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/
| |