WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] dom0 linux: Fix and cleanup reassigning memory resou

To: Keir Fraser <keir.fraser@xxxxxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] dom0 linux: Fix and cleanup reassigning memory resource code.
From: Yuji Shimada <shimada-yxb@xxxxxxxxxxxxxxx>
Date: Fri, 28 Nov 2008 18:00:13 +0900
Cc:
Delivery-date: Fri, 28 Nov 2008 01:00:46 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
This patch fixes and cleanups reassigning memory resource code of dom0 linux.


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.

Thanks,
--
Yuji Shimada


Signed-off-by: Yuji Shimada <shimada-yxb@xxxxxxxxxxxxxxx>

diff -r 0b859c9516ba drivers/pci/pci.h
--- a/drivers/pci/pci.h Wed Nov 26 11:13:49 2008 +0000
+++ b/drivers/pci/pci.h Fri Nov 28 11:18:45 2008 +0900
@@ -104,5 +104,4 @@ extern void pci_disable_bridge_window(st
 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
diff -r 0b859c9516ba drivers/pci/quirks.c
--- a/drivers/pci/quirks.c      Wed Nov 26 11:13:49 2008 +0000
+++ b/drivers/pci/quirks.c      Fri Nov 28 11:18:45 2008 +0900
@@ -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_reso
                    (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
diff -r 0b859c9516ba drivers/pci/setup-bus.c
--- a/drivers/pci/setup-bus.c   Wed Nov 26 11:13:49 2008 +0000
+++ b/drivers/pci/setup-bus.c   Fri Nov 28 11:18:45 2008 +0900
@@ -355,7 +355,7 @@ pbus_size_mem(struct pci_bus *bus, unsig
                                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 */
diff -r 0b859c9516ba drivers/pci/setup-res.c
--- a/drivers/pci/setup-res.c   Wed Nov 26 11:13:49 2008 +0000
+++ b/drivers/pci/setup-res.c   Fri Nov 28 11:18:45 2008 +0900
@@ -234,6 +234,7 @@ pdev_sort_resources(struct pci_dev *dev,
 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,
                
                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,
                                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);


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] dom0 linux: Fix and cleanup reassigning memory resource code., Yuji Shimada <=