Subject: [PATCH] PCI, x86: Add pci=pref_bar to realloc pref bars

So could reallocate 64bit pref mem above 4g.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>

---
 arch/x86/include/asm/pci_x86.h |    1 +
 arch/x86/pci/common.c          |    3 +++
 arch/x86/pci/i386.c            |    8 ++++++--
 3 files changed, 10 insertions(+), 2 deletions(-)

Index: linux-2.6/arch/x86/include/asm/pci_x86.h
===================================================================
--- linux-2.6.orig/arch/x86/include/asm/pci_x86.h
+++ linux-2.6/arch/x86/include/asm/pci_x86.h
@@ -31,6 +31,7 @@
 #define PCI_NOASSIGN_ROMS	0x80000
 #define PCI_ROOT_NO_CRS		0x100000
 #define PCI_NOASSIGN_BARS	0x200000
+#define PCI_ASSIGN_PREF_BARS	0x400000
 
 extern unsigned int pci_probe;
 extern unsigned long pirq_table_addr;
Index: linux-2.6/arch/x86/pci/common.c
===================================================================
--- linux-2.6.orig/arch/x86/pci/common.c
+++ linux-2.6/arch/x86/pci/common.c
@@ -556,6 +556,9 @@ char * __devinit  pcibios_setup(char *st
 	} else if (!strcmp(str, "assign-busses")) {
 		pci_probe |= PCI_ASSIGN_ALL_BUSSES;
 		return NULL;
+	} else if (!strcmp(str, "pref_bar")) {
+		pci_probe |= PCI_ASSIGN_PREF_BARS;
+		return NULL;
 	} else if (!strcmp(str, "use_crs")) {
 		pci_probe |= PCI_USE__CRS;
 		return NULL;
Index: linux-2.6/arch/x86/pci/i386.c
===================================================================
--- linux-2.6.orig/arch/x86/pci/i386.c
+++ linux-2.6/arch/x86/pci/i386.c
@@ -212,7 +212,9 @@ static void pcibios_allocate_bridge_reso
 			continue;
 		if (!r->flags)
 			continue;
-		if (!r->start || pci_claim_resource(dev, idx) < 0) {
+		if (((r->flags & IORESOURCE_PREFETCH) &&
+		     (pci_probe & PCI_ASSIGN_PREF_BARS)) ||
+		    !r->start || pci_claim_resource(dev, idx) < 0) {
 			/*
 			 * Something is wrong with the region.
 			 * Invalidate the resource to prevent
@@ -256,7 +258,9 @@ static void pcibios_allocate_dev_resourc
 			dev_dbg(&dev->dev,
 				"BAR %d: reserving %pr (d=%d, p=%d)\n",
 				idx, r, disabled, pass);
-			if (pci_claim_resource(dev, idx) < 0) {
+			if (((r->flags & IORESOURCE_PREFETCH) &&
+			     (pci_probe & PCI_ASSIGN_PREF_BARS)) ||
+			    pci_claim_resource(dev, idx) < 0) {
 				/* We'll assign a new address later */
 				pcibios_save_fw_addr(dev, idx, r->start);
 				r->end -= r->start;
