Subject: Re: linux-next: Tree for September 3

From: Linus Torvalds <[email-masked]>
Date: Wed, 3 Sep 2008 22:21:54 -0700 (PDT)

On Wed, 3 Sep 2008, Andrew Morton wrote:
>
> The Vaio says:
> 
> calling  init_acpi_pm_clocksource+0x0/0x14a
> initcall init_acpi_pm_clocksource+0x0/0x14a returned 0 after 32 msecs
> calling  pcibios_assign_resources+0x0/0x70
> pci 0000:06:05.0: BAR 9 too large: 0x00000000000000-0x00000003ffffff

Hmm. This should not be a new warning, afaik.

But it looks totally bogus.

The code does:

	r_size = r->end - r->start + 1;
	/* For bridges size != alignment */
	align = (i < PCI_BRIDGE_RESOURCES) ? r_size : r->start;
	order = __ffs(align) - 20;
	if (order > 11) {
		dev_warn(&dev->dev, "BAR %d too large: "
			"%#016llx-%#016llx\n", i,
			(unsigned long long)r->start,
			(unsigned long long)r->end);

and the thing is, that's a bridge resource, so it chooses r_start as the 
alignment. Which is zero. so now __ffs(align) returns a bogus value, and 
you get the bogus warning.

But CARDBUS bridges are _different_ from normal PCI bridges, and the 
alignment value isn't r->start. Strictly speaking it's not r_size either, 
it's always a fixed alignment of 4096 for MMIO bridging, i think. Maybe. 
Whatever. But our resource handling code can't handle that, and always 
wants either size alignment or start alignment.

But for cardbus bridges, we should be doing size alignment, and the 
problem is that that code doesn't do the proper "resource_alignment()" 
use.

Can you apply this patch, just to see if it fixes things.

And do you know when this started happening? It shouldn't have been all 
that recent. Maybe you haven't tried your Vaio in a while?

		Linus

---
 drivers/pci/setup-bus.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 82634a2..1aad599 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -352,11 +352,12 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, unsigned long
 				continue;
 			r_size = r->end - r->start + 1;
 			/* For bridges size != alignment */
-			align = (i < PCI_BRIDGE_RESOURCES) ? r_size : r->start;
+			align = resource_alignment(r);
 			order = __ffs(align) - 20;
 			if (order > 11) {
-				dev_warn(&dev->dev, "BAR %d too large: "
+				dev_warn(&dev->dev, "BAR %d bad alignment %llx: "
 				       "%#016llx-%#016llx\n", i,
+				       (unsigned long long)align,
 				       (unsigned long long)r->start,
 				       (unsigned long long)r->end);
 				r->flags = 0;