]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
x86/PCI: Coalesce multiple overlapping host bridge windows
authorAlexey Neyman <stilor@att.net>
Wed, 9 Oct 2013 22:16:38 +0000 (16:16 -0600)
committerBjorn Helgaas <bhelgaas@google.com>
Thu, 10 Oct 2013 13:11:59 +0000 (07:11 -0600)
Previously we coalesced windows by expanding the first overlapping one and
making the second invalid.  But we never look at the expanded first window
again, so we fail to notice other windows that overlap it.  For example, we
coalesced these:

  [io  0x0000-0x03af] // #0
  [io  0x03e0-0x0cf7] // #1
  [io  0x0000-0xdfff] // #2

into these, which still overlap:

  [io  0x0000-0xdfff] // #0
  [io  0x03e0-0x0cf7] // #1

The fix is to expand the *second* overlapping resource and ignore the
first, so we get this instead with no overlaps:

  [io  0x0000-0xdfff] // #2

[bhelgaas: changelog]
Reference: https://bugzilla.kernel.org/show_bug.cgi?id=62511
Signed-off-by: Alexey Neyman <stilor@att.net>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
arch/x86/pci/acpi.c

index b30e937689d617cee4b37775f70bc8e001af0441..7fb24e53d4c8b88b1fd374a327e0535269f7e328 100644 (file)
@@ -354,12 +354,12 @@ static void coalesce_windows(struct pci_root_info *info, unsigned long type)
                         * the kernel resource tree doesn't allow overlaps.
                         */
                        if (resource_overlaps(res1, res2)) {
-                               res1->start = min(res1->start, res2->start);
-                               res1->end = max(res1->end, res2->end);
+                               res2->start = min(res1->start, res2->start);
+                               res2->end = max(res1->end, res2->end);
                                dev_info(&info->bridge->dev,
                                         "host bridge window expanded to %pR; %pR ignored\n",
-                                        res1, res2);
-                               res2->flags = 0;
+                                        res2, res1);
+                               res1->flags = 0;
                        }
                }
        }