aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/prom.c
diff options
context:
space:
mode:
authorManish Ahuja <ahuja@austin.ibm.com>2008-03-21 19:37:08 -0400
committerPaul Mackerras <paulus@samba.org>2008-03-25 17:44:06 -0400
commit6ac26c8a7eb149dbd669cc6cd9b77ffc9cd0d2fb (patch)
tree4eb613ed5f8eb7accb042e30c89d9d25097d557f /arch/powerpc/kernel/prom.c
parentd28a79326a4028dbb1755b8efe6daa915d8bfeea (diff)
[POWERPC] pseries: phyp dump: Reserve and release memory
Initial patch for reserving memory in early boot, and freeing it later. If the previous boot had ended with a crash, the reserved memory would contain a copy of the crashed kernel data. Signed-off-by: Manish Ahuja <mahuja@us.ibm.com> Signed-off-by: Linas Vepstas <linasvepstas@gmail.com> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/kernel/prom.c')
-rw-r--r--arch/powerpc/kernel/prom.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index ff600ef0b4d6..e6c022ef12ee 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -51,6 +51,7 @@
51#include <asm/machdep.h> 51#include <asm/machdep.h>
52#include <asm/pSeries_reconfig.h> 52#include <asm/pSeries_reconfig.h>
53#include <asm/pci-bridge.h> 53#include <asm/pci-bridge.h>
54#include <asm/phyp_dump.h>
54#include <asm/kexec.h> 55#include <asm/kexec.h>
55 56
56#ifdef DEBUG 57#ifdef DEBUG
@@ -1040,6 +1041,51 @@ static void __init early_reserve_mem(void)
1040#endif 1041#endif
1041} 1042}
1042 1043
1044#ifdef CONFIG_PHYP_DUMP
1045/**
1046 * phyp_dump_reserve_mem() - reserve all not-yet-dumped mmemory
1047 *
1048 * This routine may reserve memory regions in the kernel only
1049 * if the system is supported and a dump was taken in last
1050 * boot instance or if the hardware is supported and the
1051 * scratch area needs to be setup. In other instances it returns
1052 * without reserving anything. The memory in case of dump being
1053 * active is freed when the dump is collected (by userland tools).
1054 */
1055static void __init phyp_dump_reserve_mem(void)
1056{
1057 unsigned long base, size;
1058 if (!phyp_dump_info->phyp_dump_configured) {
1059 printk(KERN_ERR "Phyp-dump not supported on this hardware\n");
1060 return;
1061 }
1062
1063 if (phyp_dump_info->phyp_dump_is_active) {
1064 /* Reserve *everything* above RMR.Area freed by userland tools*/
1065 base = PHYP_DUMP_RMR_END;
1066 size = lmb_end_of_DRAM() - base;
1067
1068 /* XXX crashed_ram_end is wrong, since it may be beyond
1069 * the memory_limit, it will need to be adjusted. */
1070 lmb_reserve(base, size);
1071
1072 phyp_dump_info->init_reserve_start = base;
1073 phyp_dump_info->init_reserve_size = size;
1074 } else {
1075 size = phyp_dump_info->cpu_state_size +
1076 phyp_dump_info->hpte_region_size +
1077 PHYP_DUMP_RMR_END;
1078 base = lmb_end_of_DRAM() - size;
1079 lmb_reserve(base, size);
1080 phyp_dump_info->init_reserve_start = base;
1081 phyp_dump_info->init_reserve_size = size;
1082 }
1083}
1084#else
1085static inline void __init phyp_dump_reserve_mem(void) {}
1086#endif /* CONFIG_PHYP_DUMP && CONFIG_PPC_RTAS */
1087
1088
1043void __init early_init_devtree(void *params) 1089void __init early_init_devtree(void *params)
1044{ 1090{
1045 DBG(" -> early_init_devtree(%p)\n", params); 1091 DBG(" -> early_init_devtree(%p)\n", params);
@@ -1052,6 +1098,11 @@ void __init early_init_devtree(void *params)
1052 of_scan_flat_dt(early_init_dt_scan_rtas, NULL); 1098 of_scan_flat_dt(early_init_dt_scan_rtas, NULL);
1053#endif 1099#endif
1054 1100
1101#ifdef CONFIG_PHYP_DUMP
1102 /* scan tree to see if dump occured during last boot */
1103 of_scan_flat_dt(early_init_dt_scan_phyp_dump, NULL);
1104#endif
1105
1055 /* Retrieve various informations from the /chosen node of the 1106 /* Retrieve various informations from the /chosen node of the
1056 * device-tree, including the platform type, initrd location and 1107 * device-tree, including the platform type, initrd location and
1057 * size, TCE reserve, and more ... 1108 * size, TCE reserve, and more ...
@@ -1072,6 +1123,7 @@ void __init early_init_devtree(void *params)
1072 reserve_kdump_trampoline(); 1123 reserve_kdump_trampoline();
1073 reserve_crashkernel(); 1124 reserve_crashkernel();
1074 early_reserve_mem(); 1125 early_reserve_mem();
1126 phyp_dump_reserve_mem();
1075 1127
1076 lmb_enforce_memory_limit(memory_limit); 1128 lmb_enforce_memory_limit(memory_limit);
1077 lmb_analyze(); 1129 lmb_analyze();