Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sh: convert kexec crash kernel management to LMB.

This migrates the crash kernel handling off of bootmem and over to LMB.

Signed-off-by: Paul Mundt <lethal@linux-sh.org>

+58 -44
+8
arch/sh/include/asm/kexec.h
··· 26 26 /* The native architecture */ 27 27 #define KEXEC_ARCH KEXEC_ARCH_SH 28 28 29 + #ifdef CONFIG_KEXEC 30 + /* arch/sh/kernel/machine_kexec.c */ 31 + void reserve_crashkernel(void); 32 + 29 33 static inline void crash_setup_regs(struct pt_regs *newregs, 30 34 struct pt_regs *oldregs) 31 35 { ··· 63 59 newregs->pc = (unsigned long)current_text_addr(); 64 60 } 65 61 } 62 + #else 63 + static inline void reserve_crashkernel(void) { } 64 + #endif /* CONFIG_KEXEC */ 65 + 66 66 #endif /* __ASM_SH_KEXEC_H */
+50 -1
arch/sh/kernel/machine_kexec.c
··· 8 8 * This source code is licensed under the GNU General Public License, 9 9 * Version 2. See the file COPYING for more details. 10 10 */ 11 - 12 11 #include <linux/mm.h> 13 12 #include <linux/kexec.h> 14 13 #include <linux/delay.h> ··· 15 16 #include <linux/numa.h> 16 17 #include <linux/ftrace.h> 17 18 #include <linux/suspend.h> 19 + #include <linux/lmb.h> 18 20 #include <asm/pgtable.h> 19 21 #include <asm/pgalloc.h> 20 22 #include <asm/mmu_context.h> ··· 147 147 VMCOREINFO_SYMBOL(node_data); 148 148 VMCOREINFO_LENGTH(node_data, MAX_NUMNODES); 149 149 #endif 150 + } 151 + 152 + void __init reserve_crashkernel(void) 153 + { 154 + unsigned long long crash_size, crash_base; 155 + int ret; 156 + 157 + /* this is necessary because of lmb_phys_mem_size() */ 158 + lmb_analyze(); 159 + 160 + ret = parse_crashkernel(boot_command_line, lmb_phys_mem_size(), 161 + &crash_size, &crash_base); 162 + if (ret == 0 && crash_size > 0) { 163 + crashk_res.start = crash_base; 164 + crashk_res.end = crash_base + crash_size - 1; 165 + } 166 + 167 + if (crashk_res.end == crashk_res.start) 168 + goto disable; 169 + 170 + crash_size = PAGE_ALIGN(crashk_res.end - crashk_res.start + 1); 171 + if (!crashk_res.start) { 172 + crashk_res.start = lmb_alloc(crash_size, PAGE_SIZE); 173 + if (!crashk_res.start) { 174 + pr_err("crashkernel allocation failed\n"); 175 + goto disable; 176 + } 177 + } else { 178 + ret = lmb_reserve(crashk_res.start, crash_size); 179 + if (unlikely(ret < 0)) { 180 + pr_err("crashkernel reservation failed - " 181 + "memory is in use\n"); 182 + goto disable; 183 + } 184 + } 185 + 186 + pr_info("Reserving %ldMB of memory at %ldMB " 187 + "for crashkernel (System RAM: %ldMB)\n", 188 + (unsigned long)(crash_size >> 20), 189 + (unsigned long)(crashk_res.start >> 20), 190 + (unsigned long)(lmb_phys_mem_size() >> 20)); 191 + 192 + crashk_res.end = crashk_res.start + crash_size - 1; 193 + insert_resource(&iomem_resource, &crashk_res); 194 + 195 + return; 196 + 197 + disable: 198 + crashk_res.start = crashk_res.end = 0; 150 199 }
-43
arch/sh/kernel/setup.c
··· 145 145 free_bootmem(PFN_PHYS(curr_pfn), PFN_PHYS(pages)); 146 146 } 147 147 148 - #ifdef CONFIG_KEXEC 149 - static void __init reserve_crashkernel(void) 150 - { 151 - unsigned long long free_mem; 152 - unsigned long long crash_size, crash_base; 153 - void *vp; 154 - int ret; 155 - 156 - free_mem = ((unsigned long long)max_low_pfn - min_low_pfn) << PAGE_SHIFT; 157 - 158 - ret = parse_crashkernel(boot_command_line, free_mem, 159 - &crash_size, &crash_base); 160 - if (ret == 0 && crash_size) { 161 - if (crash_base <= 0) { 162 - vp = alloc_bootmem_nopanic(crash_size); 163 - if (!vp) { 164 - printk(KERN_INFO "crashkernel allocation " 165 - "failed\n"); 166 - return; 167 - } 168 - crash_base = __pa(vp); 169 - } else if (reserve_bootmem(crash_base, crash_size, 170 - BOOTMEM_EXCLUSIVE) < 0) { 171 - printk(KERN_INFO "crashkernel reservation failed - " 172 - "memory is in use\n"); 173 - return; 174 - } 175 - 176 - printk(KERN_INFO "Reserving %ldMB of memory at %ldMB " 177 - "for crashkernel (System RAM: %ldMB)\n", 178 - (unsigned long)(crash_size >> 20), 179 - (unsigned long)(crash_base >> 20), 180 - (unsigned long)(free_mem >> 20)); 181 - crashk_res.start = crash_base; 182 - crashk_res.end = crash_base + crash_size - 1; 183 - insert_resource(&iomem_resource, &crashk_res); 184 - } 185 - } 186 - #else 187 - static inline void __init reserve_crashkernel(void) 188 - {} 189 - #endif 190 - 191 148 static void __init check_for_initrd(void) 192 149 { 193 150 #ifdef CONFIG_BLK_DEV_INITRD