From a8a6ec603aff68961521f0a39fc36790a40e914b Mon Sep 17 00:00:00 2001
From: Olof Johansson <olof@austin.ibm.com>
Date: Fri, 27 Feb 2004 01:23:31 -0800
Subject: [PATCH] [PATCH] ppc64: Add iommu=on for enabling DART on small-mem
 machines

This makes it possible for people like me with a small-mem G5 to enable
the DART.  I see two reasons for wanting to do so:

1. To debug/test DART/iommu code itself (small audience, including
   myself).
2. To debug drivers on small-mem machines, since bad pci_map*() usage will
   be punished (possibly larger audience).
---
 arch/ppc64/kernel/prom.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/arch/ppc64/kernel/prom.c b/arch/ppc64/kernel/prom.c
index 8364c3ea095c..5e8e5c50d6b1 100644
--- a/arch/ppc64/kernel/prom.c
+++ b/arch/ppc64/kernel/prom.c
@@ -516,6 +516,9 @@ prom_initialize_naca(unsigned long mem)
 	return mem;
 }
 
+#ifdef CONFIG_PMAC_DART
+static int dart_force_on;
+#endif
 
 static unsigned long __init
 prom_initialize_lmb(unsigned long mem)
@@ -539,10 +542,12 @@ prom_initialize_lmb(unsigned long mem)
 		prom_print(opt);
 		prom_print(RELOC("\n"));
 		opt += 6;
-		while(*opt && *opt == ' ')
+		while (*opt && *opt == ' ')
 			opt++;
 		if (!strncmp(opt, RELOC("off"), 3))
 			nodart = 1;
+		else if (!strncmp(opt, RELOC("on"), 2))
+			RELOC(dart_force_on) = 1;
 	}
 #else
 	nodart = 1;
@@ -763,8 +768,10 @@ void prom_initialize_dart_table(void)
 	extern unsigned long dart_tablebase;
 	extern unsigned long dart_tablesize;
 
-	/* Only reserve DART space if machine has more than 2Gb of RAM */
-	if (lmb_end_of_DRAM() <= 0x80000000ull)
+	/* Only reserve DART space if machine has more than 2GB of RAM
+	 * or if requested with iommu=on on cmdline.
+	 */
+	if (lmb_end_of_DRAM() <= 0x80000000ull && !RELOC(dart_force_on))
 		return;
 
 	/* 512 pages is max DART tablesize. */
-- 
2.30.9