Linux MIPS Architecture development
 help / color / mirror / Atom feed
* Linux MIPS PCI resource sanity check
@ 2008-02-16 10:39 Michael Buesch
  2008-02-16 10:49 ` Sergei Shtylyov
  2008-02-19 15:51 ` Ralf Baechle
  0 siblings, 2 replies; 8+ messages in thread
From: Michael Buesch @ 2008-02-16 10:39 UTC (permalink / raw)
  To: ralf; +Cc: linux-mips

Hi,

There's a sanity check in pcibios_enable_resources() that looks like this:

	r = &dev->resource[idx];
	if (!r->start && r->end) {
		printk(KERN_ERR "PCI: Device %s not available because of resource collisions\n", pci_name(dev));
		return -EINVAL;
	}

What is this check actually doing? It triggers for me on a BCM4318 device
which is behind a BCM4710 PCI bridge.
r->start is 0 and r->end is 0x1FFF when this triggers.
If I simply comment out that check the device is detected correctly
and seems to initialize just fine.

-- 
Greetings Michael.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Linux MIPS PCI resource sanity check
  2008-02-16 10:39 Linux MIPS PCI resource sanity check Michael Buesch
@ 2008-02-16 10:49 ` Sergei Shtylyov
  2008-02-16 10:55   ` Michael Buesch
                     ` (2 more replies)
  2008-02-19 15:51 ` Ralf Baechle
  1 sibling, 3 replies; 8+ messages in thread
From: Sergei Shtylyov @ 2008-02-16 10:49 UTC (permalink / raw)
  To: Michael Buesch; +Cc: ralf, linux-mips

Michael Buesch wrote:

> There's a sanity check in pcibios_enable_resources() that looks like this:

> 	r = &dev->resource[idx];
> 	if (!r->start && r->end) {
> 		printk(KERN_ERR "PCI: Device %s not available because of resource collisions\n", pci_name(dev));
> 		return -EINVAL;
> 	}
> 
> What is this check actually doing?

   It makes sure that a PCI resource is allocated (base of 0 means that it's 
unallocated due to previously detected resource conlict (or some other reason).

> It triggers for me on a BCM4318 device which is behind a BCM4710 PCI bridge.
> r->start is 0 and r->end is 0x1FFF when this triggers.
> If I simply comment out that check the device is detected correctly
> and seems to initialize just fine.

    No, that failnig resource should be relocated.

WBR, Sergei

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Linux MIPS PCI resource sanity check
  2008-02-16 10:49 ` Sergei Shtylyov
@ 2008-02-16 10:55   ` Michael Buesch
  2008-02-16 23:35   ` Andrew Sharp
  2008-02-19 15:30   ` Ralf Baechle
  2 siblings, 0 replies; 8+ messages in thread
From: Michael Buesch @ 2008-02-16 10:55 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: ralf, linux-mips

On Saturday 16 February 2008 11:49:56 Sergei Shtylyov wrote:
> Michael Buesch wrote:
> 
> > There's a sanity check in pcibios_enable_resources() that looks like this:
> 
> > 	r = &dev->resource[idx];
> > 	if (!r->start && r->end) {
> > 		printk(KERN_ERR "PCI: Device %s not available because of resource collisions\n", pci_name(dev));
> > 		return -EINVAL;
> > 	}
> > 
> > What is this check actually doing?
> 
>    It makes sure that a PCI resource is allocated (base of 0 means that it's 
> unallocated due to previously detected resource conlict (or some other reason).

So well, that's what the error message already told me. ;)
But where is the actual bug? I mean, this tells me there's some collision
for this MMIO resource. Still, I can access the MMIO space just fine.

> > It triggers for me on a BCM4318 device which is behind a BCM4710 PCI bridge.
> > r->start is 0 and r->end is 0x1FFF when this triggers.
> > If I simply comment out that check the device is detected correctly
> > and seems to initialize just fine.
> 
>     No, that failnig resource should be relocated.

How?

-- 
Greetings Michael.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Linux MIPS PCI resource sanity check
  2008-02-16 10:49 ` Sergei Shtylyov
  2008-02-16 10:55   ` Michael Buesch
@ 2008-02-16 23:35   ` Andrew Sharp
  2008-02-17 11:19     ` Michael Buesch
  2008-02-18 13:55     ` Sergei Shtylyov
  2008-02-19 15:30   ` Ralf Baechle
  2 siblings, 2 replies; 8+ messages in thread
From: Andrew Sharp @ 2008-02-16 23:35 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: Michael Buesch, ralf, linux-mips

On Sat, 16 Feb 2008 13:49:56 +0300 Sergei Shtylyov
<sshtylyov@ru.mvista.com> wrote:

> Michael Buesch wrote:
> 
> > There's a sanity check in pcibios_enable_resources() that looks
> > like this:
> 
> > 	r = &dev->resource[idx];
> > 	if (!r->start && r->end) {
> > 		printk(KERN_ERR "PCI: Device %s not available
> > because of resource collisions\n", pci_name(dev)); return -EINVAL;
> > 	}
> > 
> > What is this check actually doing?
> 
>    It makes sure that a PCI resource is allocated (base of 0 means
> that it's unallocated due to previously detected resource conlict (or
> some other reason).


Actually, IIRC, resources are based on what the device requested, so a
device behind a bridge could request a resource starting at 0.  I had
to change this for a system as well.  I changed it to

if (!r->start && !r->end) {

because I couldn't see anything in the code that made r->start == 0 an
improper thing.  Not to mention I couldn't access the device any other
way.  Both being 0 is definitelty bogus.

> > It triggers for me on a BCM4318 device which is behind a BCM4710
> > PCI bridge. r->start is 0 and r->end is 0x1FFF when this triggers.
> > If I simply comment out that check the device is detected correctly
> > and seems to initialize just fine.
> 
>     No, that failnig resource should be relocated.
> 
> WBR, Sergei
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Linux MIPS PCI resource sanity check
  2008-02-16 23:35   ` Andrew Sharp
@ 2008-02-17 11:19     ` Michael Buesch
  2008-02-18 13:55     ` Sergei Shtylyov
  1 sibling, 0 replies; 8+ messages in thread
From: Michael Buesch @ 2008-02-17 11:19 UTC (permalink / raw)
  To: Andrew Sharp; +Cc: Sergei Shtylyov, ralf, linux-mips

On Sunday 17 February 2008 00:35:30 Andrew Sharp wrote:
> Actually, IIRC, resources are based on what the device requested, so a
> device behind a bridge could request a resource starting at 0.  I had
> to change this for a system as well.  I changed it to
> 
> if (!r->start && !r->end) {
> 
> because I couldn't see anything in the code that made r->start == 0 an
> improper thing.  Not to mention I couldn't access the device any other
> way.  Both being 0 is definitelty bogus.

I think what's happening for me is the following:
I have a PCI bridge and behind that bridge is one device.
This has a fixed location and fixed size memory window (hardwired).

register_pci_controller() requires me to pass some io_resource
and mem_resource in the controller struct. So I pass the memory window
which is assigned to the controller and the devices behind it.
Later I fixup the bases and sizes for each resource in the
pcibios_plat_dev_init() routine.

So, well. I still don't know where the mips PCI subsystem would
detect this resource conflict and what that means to me.
If I simply rip out the check everything works fine, as I fixup
the addresses and sizes later anyway. (I fixup more stuff like the
IRQ routing an so on, too).

The code is in drivers/ssb/driver_pcicore.c

-- 
Greetings Michael.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Linux MIPS PCI resource sanity check
  2008-02-16 23:35   ` Andrew Sharp
  2008-02-17 11:19     ` Michael Buesch
@ 2008-02-18 13:55     ` Sergei Shtylyov
  1 sibling, 0 replies; 8+ messages in thread
From: Sergei Shtylyov @ 2008-02-18 13:55 UTC (permalink / raw)
  To: Andrew Sharp; +Cc: Michael Buesch, ralf, linux-mips

Andrew Sharp wrote:

>>>There's a sanity check in pcibios_enable_resources() that looks
>>>like this:

>>>	r = &dev->resource[idx];
>>>	if (!r->start && r->end) {
>>>		printk(KERN_ERR "PCI: Device %s not available
>>>because of resource collisions\n", pci_name(dev)); return -EINVAL;
>>>	}

>>>What is this check actually doing?

>>   It makes sure that a PCI resource is allocated (base of 0 means
>>that it's unallocated due to previously detected resource conlict (or
>>some other reason).

> Actually, IIRC, resources are based on what the device requested, so a
> device behind a bridge could request a resource starting at 0.  I had

    Zero value in BAR was considered unallocated resource in the PCI 2.2 spec...

> to change this for a system as well.  I changed it to

> if (!r->start && !r->end) {

    r->end can't be 0.

WBR, Sergei

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Linux MIPS PCI resource sanity check
  2008-02-16 10:49 ` Sergei Shtylyov
  2008-02-16 10:55   ` Michael Buesch
  2008-02-16 23:35   ` Andrew Sharp
@ 2008-02-19 15:30   ` Ralf Baechle
  2 siblings, 0 replies; 8+ messages in thread
From: Ralf Baechle @ 2008-02-19 15:30 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: Michael Buesch, linux-mips

On Sat, Feb 16, 2008 at 01:49:56PM +0300, Sergei Shtylyov wrote:

>   It makes sure that a PCI resource is allocated (base of 0 means that it's 
> unallocated due to previously detected resource conlict (or some other 
> reason).
>
>> It triggers for me on a BCM4318 device which is behind a BCM4710 PCI bridge.
>> r->start is 0 and r->end is 0x1FFF when this triggers.
>> If I simply comment out that check the device is detected correctly
>> and seems to initialize just fine.
>
>    No, that failnig resource should be relocated.

The resources were assigned during the PCI bus scan so at least with the
current implementation it's too late to reassign resources.  I get the
feeling this is an indication of a problem elsewhere.

  Ralf

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Linux MIPS PCI resource sanity check
  2008-02-16 10:39 Linux MIPS PCI resource sanity check Michael Buesch
  2008-02-16 10:49 ` Sergei Shtylyov
@ 2008-02-19 15:51 ` Ralf Baechle
  1 sibling, 0 replies; 8+ messages in thread
From: Ralf Baechle @ 2008-02-19 15:51 UTC (permalink / raw)
  To: Michael Buesch; +Cc: linux-mips

On Sat, Feb 16, 2008 at 11:39:10AM +0100, Michael Buesch wrote:

Can you take a look at ed6d14f9760857c745206c978b80352fc09cfd19 which fixed
a somewhat similar problem for i386, does that seem to be related to your
problem?

The i386 fix makes sense so I'm almost decieded to apply to the MIPS code
even if it should turn out not to make a difference for you.

  Ralf

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-02-19 15:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-16 10:39 Linux MIPS PCI resource sanity check Michael Buesch
2008-02-16 10:49 ` Sergei Shtylyov
2008-02-16 10:55   ` Michael Buesch
2008-02-16 23:35   ` Andrew Sharp
2008-02-17 11:19     ` Michael Buesch
2008-02-18 13:55     ` Sergei Shtylyov
2008-02-19 15:30   ` Ralf Baechle
2008-02-19 15:51 ` Ralf Baechle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox