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-changelog

[Xen-changelog] [linux-2.6.18-xen] Add boot parameter 'pci-mem-align' to

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [linux-2.6.18-xen] Add boot parameter 'pci-mem-align' to page-align PCI memory regions.
From: "Xen patchbot-linux-2.6.18-xen" <patchbot-linux-2.6.18-xen@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 31 Oct 2007 15:00:54 -0700
Delivery-date: Wed, 31 Oct 2007 15:03:03 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir@xxxxxxxxxxxxx>
# Date 1193822497 0
# Node ID ba69bacc7e8a28ec3aa7bcec0dbd21a3be2db2eb
# Parent  71a5313e13f5d99b1b550b1b5f1c0198fc4c9a70
Add boot parameter 'pci-mem-align' to page-align PCI memory regions.

In PCI pass-through the mmio resources are mapped/translated from pfns
to mfns (page size), so mmio resources should be at least
page-aligned.

Signed-off-by: Barak Fargoun <barak@xxxxxxxxxxxx>
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 drivers/pci/bus.c    |    7 +++++++
 drivers/pci/quirks.c |   34 ++++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+)

diff -r 71a5313e13f5 -r ba69bacc7e8a drivers/pci/bus.c
--- a/drivers/pci/bus.c Tue Oct 30 17:35:21 2007 +0000
+++ b/drivers/pci/bus.c Wed Oct 31 09:21:37 2007 +0000
@@ -16,6 +16,8 @@
 #include <linux/init.h>
 
 #include "pci.h"
+
+extern int pci_mem_align;
 
 /**
  * pci_bus_alloc_resource - allocate a resource from a parent bus
@@ -43,6 +45,11 @@ pci_bus_alloc_resource(struct pci_bus *b
        int i, ret = -ENOMEM;
 
        type_mask |= IORESOURCE_IO | IORESOURCE_MEM;
+
+       /* If the boot parameter 'pci-mem-align' was specified then we need to 
+          align the memory addresses, at page size alignment. */
+       if (pci_mem_align && (align < (PAGE_SIZE-1)))
+               align = PAGE_SIZE - 1;
 
        for (i = 0; i < PCI_BUS_NUM_RESOURCES; i++) {
                struct resource *r = bus->resource[i];
diff -r 71a5313e13f5 -r ba69bacc7e8a drivers/pci/quirks.c
--- a/drivers/pci/quirks.c      Tue Oct 30 17:35:21 2007 +0000
+++ b/drivers/pci/quirks.c      Wed Oct 31 09:21:37 2007 +0000
@@ -22,6 +22,40 @@
 #include <linux/delay.h>
 #include <linux/acpi.h>
 #include "pci.h"
+
+/* A global flag which signals if we should page-align PCI mem windows. */
+int pci_mem_align = 0;
+
+static int __init set_pci_mem_align(char *str)
+{
+       pci_mem_align = 1;
+       return 1;
+}
+__setup("pci-mem-align", set_pci_mem_align);
+
+/* This quirk function enables us to force all memory resources which are 
+ * assigned to PCI devices, to be page-aligned.
+ */
+static void __devinit quirk_align_mem_resources(struct pci_dev *dev)
+{
+       int i;
+       struct resource *r;
+       resource_size_t old_start;
+
+       if (!pci_mem_align)
+               return;
+
+       for (i=0; i < DEVICE_COUNT_RESOURCE; i++) {
+               r = &dev->resource[i];
+               if ((r == NULL) || !(r->flags & IORESOURCE_MEM))
+                       continue;
+
+               old_start = r->start;
+               r->start = (r->start + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1);
+               r->end = r->end - (old_start - r->start);
+       }
+}
+DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, quirk_align_mem_resources);
 
 /* The Mellanox Tavor device gives false positive parity errors
  * Mark this device with a broken_parity_status, to allow

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [linux-2.6.18-xen] Add boot parameter 'pci-mem-align' to page-align PCI memory regions., Xen patchbot-linux-2.6.18-xen <=