mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [patch non-x86] PCI-PCI bridges fix
@ 2001-11-22 12:04 Ivan Kokshaysky
  2001-11-22 21:49 ` Paul Mackerras
  0 siblings, 1 reply; 3+ messages in thread
From: Ivan Kokshaysky @ 2001-11-22 12:04 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Richard Henderson, linux-kernel

Bridge resources weren't added to the resource tree. This was
harmless for most real-life configurations (especially on Alpha),
but certainly it will be a problem with the hotplug stuff
(thinking of ES45).

Ivan.

--- 2.4.15p9/drivers/pci/setup-bus.c	Fri Oct  5 05:47:08 2001
+++ linux/drivers/pci/setup-bus.c	Wed Nov 21 20:16:24 2001
@@ -201,6 +201,16 @@ pbus_assign_resources(struct pci_bus *bu
 		b->resource[0]->end = ranges->io_end - 1;
 		b->resource[1]->end = ranges->mem_end - 1;
 
+		/* Add bridge resources to the resource tree. */
+		if (b->resource[0]->end > b->resource[0]->start &&
+		    request_resource(bus->resource[0], b->resource[0]) < 0)
+			printk(KERN_ERR "PCI: failed to reserve IO "
+					"for bus %d\n",	b->number);
+		if (b->resource[1]->end > b->resource[1]->start &&
+		    request_resource(bus->resource[1], b->resource[1]) < 0)
+			printk(KERN_ERR "PCI: failed to reserve MEM "
+					"for bus %d\n", b->number);
+
 		pci_setup_bridge(b);
 	}
 }

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

* Re: [patch non-x86] PCI-PCI bridges fix
  2001-11-22 12:04 [patch non-x86] PCI-PCI bridges fix Ivan Kokshaysky
@ 2001-11-22 21:49 ` Paul Mackerras
  2001-11-23 12:36   ` Ivan Kokshaysky
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Mackerras @ 2001-11-22 21:49 UTC (permalink / raw)
  To: Ivan Kokshaysky; +Cc: Linus Torvalds, Richard Henderson, linux-kernel

Ivan Kokshaysky writes:

> Bridge resources weren't added to the resource tree. This was
> harmless for most real-life configurations (especially on Alpha),
> but certainly it will be a problem with the hotplug stuff
> (thinking of ES45).
> 
> Ivan.
> 
> --- 2.4.15p9/drivers/pci/setup-bus.c	Fri Oct  5 05:47:08 2001
> +++ linux/drivers/pci/setup-bus.c	Wed Nov 21 20:16:24 2001
> @@ -201,6 +201,16 @@ pbus_assign_resources(struct pci_bus *bu
>  		b->resource[0]->end = ranges->io_end - 1;
>  		b->resource[1]->end = ranges->mem_end - 1;
>  
> +		/* Add bridge resources to the resource tree. */
> +		if (b->resource[0]->end > b->resource[0]->start &&
> +		    request_resource(bus->resource[0], b->resource[0]) < 0)
> +			printk(KERN_ERR "PCI: failed to reserve IO "
> +					"for bus %d\n",	b->number);

There is code in pci_read_bridge_bases which will decide under some
circumstances that a PCI-PCI bridge is transparent and set

	child->resource[i] = child->parent->resource[i];

for i = 0, 1 or 2.  What will happen with your request_resource in
this case is that the resource will end up being its own parent and
its own child and all allocations against it will fail. :)

I hit this just yesterday on PPC.  On our RS/6000 boxes, if you have a
PCI-PCI bridge with nothing behind it, the firmware will configure it
with all the apertures closed, i.e. with base set larger than limit.
Then pci_read_bridge_bases goes and decides that the bridge is
transparent and consequently everything stops working. :(

Does anyone really need that "assuming transparent" stuff in
pci_read_bridge_bases?  If so we need to add a check for the case
where base == limit + 0x1000 (for I/O) or base == limit + 0x100000
(for memory) and conclude that the aperture is closed in that case.

Paul.

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

* Re: [patch non-x86] PCI-PCI bridges fix
  2001-11-22 21:49 ` Paul Mackerras
@ 2001-11-23 12:36   ` Ivan Kokshaysky
  0 siblings, 0 replies; 3+ messages in thread
From: Ivan Kokshaysky @ 2001-11-23 12:36 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: Linus Torvalds, Richard Henderson, linux-kernel

On Fri, Nov 23, 2001 at 08:49:30AM +1100, Paul Mackerras wrote:
> There is code in pci_read_bridge_bases which will decide under some
> circumstances that a PCI-PCI bridge is transparent and set
> 
> 	child->resource[i] = child->parent->resource[i];
> 
> for i = 0, 1 or 2.  What will happen with your request_resource in
> this case is that the resource will end up being its own parent and
> its own child and all allocations against it will fail. :)

These code paths shouldn't be mixed in the first place, i.e. if
you use stuff in setup-bus.c, don't use pci_read_bridge_bases.
Basically, these are two different approaches to PCI setup:
"We trust our firmware" (i386, ia64) and "We are the firmware"
(alpha, arm, partially parisc).

> I hit this just yesterday on PPC.  On our RS/6000 boxes, if you have a
> PCI-PCI bridge with nothing behind it, the firmware will configure it
> with all the apertures closed, i.e. with base set larger than limit.

Right, as required by PCI-PCI bridge specs.

> Then pci_read_bridge_bases goes and decides that the bridge is
> transparent and consequently everything stops working. :(

I think that "assuming transparent" code is not correct. Yes, PCI-PCI
bridge specs allow "transparent" (i.e. subtractive decoding) bridges,
but such bridges must have a class code 0x60401. IMO, we need something
like this instead:

 	if (!dev)		/* It's a host bus, nothing to read */
 		return;
 
+	if (dev->class & 1) {
+		printk("Subtractive decoding bridge %s: assuming transparent\n",
+					dev->name);
+		for(i=0; i<3; i++)
+			child->resource[i] = child->parent->resource[i];
+		return;
+	}

Of course, this requires testing on problematic machines.
BTW, currently almost every PC user sees those "Unknown bridge resource"
messages just because a graphic card behind the AGP bridge doesn't use
IO or prefetchable memory...

Ivan.

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

end of thread, other threads:[~2001-11-23 12:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-22 12:04 [patch non-x86] PCI-PCI bridges fix Ivan Kokshaysky
2001-11-22 21:49 ` Paul Mackerras
2001-11-23 12:36   ` Ivan Kokshaysky

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®