]> xenbits.xensource.com Git - legacy/linux-2.6.18-xen.git/commitdiff
dom0 linux: Fix and cleanup reassigning memory resource code.
authorKeir Fraser <keir.fraser@citrix.com>
Fri, 28 Nov 2008 13:07:36 +0000 (13:07 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Fri, 28 Nov 2008 13:07:36 +0000 (13:07 +0000)
When we use PCI pass-through, we have to assign page-aligned resources
to device. To do this, we round up the alignment to PAGE_SIZE, if
device is specified by "reassigndev=" boot parameter.

"pdev_sort_resources" function uses the alignment. But it does not
round up the alignment to PAGE_SIZE. This patch makes
"pdev_sort_resources" function round up the alignment to PAGE_SIZE.

"pbus_size_mem" function round up the alignment of bridge's resource
window as well as that of normal resource. But we don't need to do
this. This patch makes "pbus_size_mem" function exclude bridges's
resource window.

This patch also cleanups code of reassigning memory resource.

Signed-off-by: Yuji Shimada <shimada-yxb@necst.nec.co.jp>
drivers/pci/pci.h
drivers/pci/quirks.c
drivers/pci/setup-bus.c
drivers/pci/setup-res.c

index 7c96ce8c7433d80f11be5b5f21e45c6f4a25e3b8..1ceef96827ae35ba2f991a5d87604f255c682daf 100644 (file)
@@ -104,5 +104,4 @@ extern int is_reassigndev(struct pci_dev *dev);
 extern void pci_disable_bridge_window(struct pci_dev *dev);
 #else
 #define is_reassigndev(dev) 0
-static inline void pci_disable_bridge_window(struct pci_dev *dev) {}
 #endif
index 421ad6eddf4d0c60a93cf9f7026beea16d8b399e..65aeb34ab37f562d06118cff8bdbd09c31f6806f 100644 (file)
@@ -24,6 +24,7 @@
 #include "pci.h"
 
 
+#ifdef CONFIG_PCI_REASSIGN
 /*
  * This quirk function disables the device and releases resources
  * which is specified by kernel's boot parameter 'reassigndev'.
@@ -66,10 +67,10 @@ static void __devinit quirk_release_resources(struct pci_dev *dev)
                    (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {
                        pci_disable_bridge_window(dev);
                }
-               return;
        }
 }
 DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, quirk_release_resources);
+#endif  /* CONFIG_PCI_REASSIGN */
 
 /* The Mellanox Tavor device gives false positive parity errors
  * Mark this device with a broken_parity_status, to allow
index b113a600045a2cc87c4efcbca0c29d9c413398da..588d6f855402042e6160c8acd13ebf7f9d8ebc43 100644 (file)
@@ -355,7 +355,7 @@ pbus_size_mem(struct pci_bus *bus, unsigned long mask, unsigned long type)
                                continue;
                        r_size = r->end - r->start + 1;
 
-                       if (reassign)
+                       if ((i < PCI_BRIDGE_RESOURCES) && reassign)
                                r_size = ALIGN(r_size, PAGE_SIZE);
 
                        /* For bridges size != alignment */
index 16a5b1d938738cf2097c0d4994ce8ca630fb0c05..c38762b09654bf7d875074d7c04f460cf88af379 100644 (file)
@@ -234,6 +234,7 @@ void __devinit
 pdev_sort_resources(struct pci_dev *dev, struct resource_list *head)
 {
        int i;
+       int reassigndev = is_reassigndev(dev);
 
        for (i = 0; i < PCI_NUM_RESOURCES; i++) {
                struct resource *r;
@@ -245,6 +246,11 @@ pdev_sort_resources(struct pci_dev *dev, struct resource_list *head)
                
                if (!(r->flags) || r->parent)
                        continue;
+               
+               if (i < PCI_BRIDGE_RESOURCES && (r->flags & IORESOURCE_MEM) &&
+                   reassigndev)
+                       r_align = ALIGN(r_align, PAGE_SIZE);
+
                if (!r_align) {
                        printk(KERN_WARNING "PCI: Ignore bogus resource %d "
                                "[%llx:%llx] of %s\n",
@@ -263,6 +269,10 @@ pdev_sort_resources(struct pci_dev *dev, struct resource_list *head)
                                align = (idx < PCI_BRIDGE_RESOURCES) ?
                                        ln->res->end - ln->res->start + 1 :
                                        ln->res->start;
+                               if ((idx < PCI_BRIDGE_RESOURCES) &&
+                                   (ln->res->flags & IORESOURCE_MEM) &&
+                                   is_reassigndev(ln->dev))
+                                       align = ALIGN(align, PAGE_SIZE);
                        }
                        if (r_align > align) {
                                tmp = kmalloc(sizeof(*tmp), GFP_KERNEL);