All of lore.kernel.org
 help / color / mirror / Atom feed
* PCI question
@ 2004-02-03 22:35 Pat Gefre
  2004-02-03 22:56 ` Matthew Wilcox
                   ` (9 more replies)
  0 siblings, 10 replies; 13+ messages in thread
From: Pat Gefre @ 2004-02-03 22:35 UTC (permalink / raw)
  To: linux-ia64



The usage of pci_dev.sysdata is a bit confusing to me. I had initially
thought that this was available for any system specific use,  but then
in pcibios_fixup_device_resources() it is specifically cast as a struct
pci_controller *:

#define PCI_CONTROLLER(busdev) ((struct pci_controller *) busdev->sysdata)

void __init
pcibios_fixup_device_resources (struct pci_dev *dev, struct pci_bus *bus)
{
   struct pci_controller *controller = PCI_CONTROLLER(dev);

In this funtion  the pci_controller elements 'window[]' and 'windows'
are also used.  This implies to me that these fields must be maintained
in any system specific structure ? i.e.

struct my_sysdata_struct {
   struct pci_controller dummy;
   /* my stuff would go here */
   struct my_real_sysdata_stuff;
};

Yet I don't see where anyone else is doing the above. Am I missing
something obvious ??

Thanks,
-- Pat


^ permalink raw reply	[flat|nested] 13+ messages in thread
* RE: PCI question
@ 2003-03-28 21:40 Cameron, Steve
  0 siblings, 0 replies; 13+ 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] 13+ messages in thread
* PCI question
@ 2003-03-28  9:28 Stephen Cameron
  0 siblings, 0 replies; 13+ 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] 13+ messages in thread

end of thread, other threads:[~2004-02-05 17:11 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-03 22:35 PCI question Pat Gefre
2004-02-03 22:56 ` Matthew Wilcox
2004-02-03 23:15 ` Patrick Gefre
2004-02-03 23:29 ` Jesse Barnes
2004-02-03 23:36 ` Patrick Gefre
2004-02-04  3:28 ` Jesse Barnes
2004-02-04 17:04 ` Patrick Gefre
2004-02-04 17:48 ` Grant Grundler
2004-02-04 19:10 ` Patrick Gefre
2004-02-04 19:50 ` Bjorn Helgaas
2004-02-05 17:11 ` Patrick Gefre
  -- strict thread matches above, loose matches on Subject: below --
2003-03-28 21:40 Cameron, Steve
2003-03-28  9:28 Stephen Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.