From: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Subject: [PATCH] SPARC/PCI: Correct 64-bit non-pref -> pref

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

---
 arch/sparc/kernel/of_device_64.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/arch/sparc/kernel/of_device_64.c b/arch/sparc/kernel/of_device_64.c
index f53092b07b9e..ea21d90e3f94 100644
--- a/arch/sparc/kernel/of_device_64.c
+++ b/arch/sparc/kernel/of_device_64.c
@@ -311,6 +311,23 @@ static int __init use_1to1_mapping(struct device_node *pp)
 	return 1;
 }
 
+static void of_fixup_pci_pref(struct device_node *dp, int index,
+			      struct device_node *pp, struct resource *res)
+{
+	if (!resource_size(res))
+		return;
+	if (res->end <= ~((u32)0))
+		return;
+
+	if (!of_node_is_type(pp, "pci") && !of_node_is_type(pp, "pciex"))
+		return;
+
+	if (!(res->flags & IORESOURCE_PREFETCH)) {
+		res->flags |= IORESOURCE_PREFETCH;
+		printk("%pOF reg[%d] fixup: pref corrected\n", dp, index);
+	}
+}
+
 static int of_resource_verbose;
 
 static void __init build_device_resources(struct platform_device *op,
@@ -412,6 +429,7 @@ static void __init build_device_resources(struct platform_device *op,
 			r->start = result;
 			r->end = result + size - 1;
 			r->flags = flags;
+			of_fixup_pci_pref(dp, index, pp, r);
 		}
 		r->name = op->dev.of_node->full_name;
 	}

-- 
tg: (3a8660878839..) sparc/dt-fixup-pref (depends on: main)
