Skip to contentSkip to conversation

Linux MIPS PCI resource sanity check

DISCUSSION Michael Buesch 4 participants 8 messages Feb 16, 2008 – Feb 19, 2008 MIPS

lore
Share & tools
lore
#0 lore raw

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.

Signature · 1 line
Greetings Michael.
#1 lore raw
Quoted 9 lines · Michael Buesch

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).

Quoted 4 lines

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

#2 lore raw
Quoted 10 lines · On Saturday 16 February 2008 11:49:56 Sergei Shtylyov wrote:
Quoted 8 lines · Michael Buesch

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;
	}
Quoted 4 lines
Quoted 1 line

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.

Quoted 6 lines
Quoted 4 lines

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?

Signature · 1 line
Greetings Michael.
#3 lore raw
In reply to Sergei Shtylyov
Quoted 11 lines · On Sat, 16 Feb 2008 13:49:56 +0300 Sergei Shtylyov <[email protected]>…
Quoted 9 lines · Michael Buesch

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;
	}
Quoted 5 lines
Quoted 1 line

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.

Quoted 9 lines
Quoted 4 lines

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

#4 lore raw
Quoted 9 lines · 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

Signature · 1 line
Greetings Michael.
#5 lore raw
In reply to Andrew Sharp
Quoted 9 lines · Andrew Sharp
Quoted 8 lines
Quoted 8 lines

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;
	}
Quoted 8 lines
Quoted 5 lines
Quoted 1 line

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...

Quoted 3 lines

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

#6 lore raw
In reply to Sergei Shtylyov
Quoted 10 lines · Sergei Shtylyov

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).

Quoted 4 lines

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

#7 lore raw
In reply to Michael Buesch

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