ps3-debugging: Limit boot mem size
For debugging only.
diff --git a/arch/powerpc/platforms/ps3/Kconfig b/arch/powerpc/platforms/ps3/Kconfig
index 6f75255..5d7880c 100644
--- a/arch/powerpc/platforms/ps3/Kconfig
+++ b/arch/powerpc/platforms/ps3/Kconfig
@@ -171,4 +171,20 @@
If in doubt, say N here.
+config PS3_DEBUG_BOOT_MEM_LIMIT
+ depends on PPC_PS3
+ int "PS3 Limit available boot memory"
+ range -1 1024
+ default -1
+ help
+ This is a debug option used for memory stress testing. Enter
+ a value in units of MiB to limit available boot memory.
+
+ If unsure, choose the default to disable this option.
+
+ A negative value will disable this option. A value of zero (0)
+ will have maximum effect and the system can not boot. The
+ retail console reports 128 MiB of boot memory, this option
+ will have no effect with a value of 128 or greater.
+
endmenu
diff --git a/arch/powerpc/platforms/ps3/mm.c b/arch/powerpc/platforms/ps3/mm.c
index 8c7009d..8a35243 100644
--- a/arch/powerpc/platforms/ps3/mm.c
+++ b/arch/powerpc/platforms/ps3/mm.c
@@ -1215,6 +1215,19 @@
BUG_ON(map.rm.base);
BUG_ON(!map.rm.size);
+#if defined(CONFIG_PS3_DEBUG_BOOT_MEM_LIMIT) \
+ && ((CONFIG_PS3_DEBUG_BOOT_MEM_LIMIT) >= 0)
+{
+ u64 orig_size = map.rm.size;
+
+ map.rm.size = min(map.rm.size,
+ (CONFIG_PS3_DEBUG_BOOT_MEM_LIMIT) * 1024 * 1024);
+ map.total -= orig_size - map.rm.size;
+ pr_info("Limiting boot RAM to 0x%llx (%llu MiB)\n", map.rm.size,
+ map.rm.size / (1024 * 1024));
+}
+#endif
+
/* Check if we got the highmem region from an earlier boot step */
if (ps3_mm_get_repository_highmem(&map.r1)) {