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>
This commit is contained in:
parent
9b7a37853a
commit
a5ec395071
|
@ -26,6 +26,10 @@
|
||||||
/* The native architecture */
|
/* The native architecture */
|
||||||
#define KEXEC_ARCH KEXEC_ARCH_SH
|
#define KEXEC_ARCH KEXEC_ARCH_SH
|
||||||
|
|
||||||
|
#ifdef CONFIG_KEXEC
|
||||||
|
/* arch/sh/kernel/machine_kexec.c */
|
||||||
|
void reserve_crashkernel(void);
|
||||||
|
|
||||||
static inline void crash_setup_regs(struct pt_regs *newregs,
|
static inline void crash_setup_regs(struct pt_regs *newregs,
|
||||||
struct pt_regs *oldregs)
|
struct pt_regs *oldregs)
|
||||||
{
|
{
|
||||||
|
@ -59,4 +63,8 @@ static inline void crash_setup_regs(struct pt_regs *newregs,
|
||||||
newregs->pc = (unsigned long)current_text_addr();
|
newregs->pc = (unsigned long)current_text_addr();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
static inline void reserve_crashkernel(void) { }
|
||||||
|
#endif /* CONFIG_KEXEC */
|
||||||
|
|
||||||
#endif /* __ASM_SH_KEXEC_H */
|
#endif /* __ASM_SH_KEXEC_H */
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
* This source code is licensed under the GNU General Public License,
|
* This source code is licensed under the GNU General Public License,
|
||||||
* Version 2. See the file COPYING for more details.
|
* Version 2. See the file COPYING for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <linux/mm.h>
|
#include <linux/mm.h>
|
||||||
#include <linux/kexec.h>
|
#include <linux/kexec.h>
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
|
@ -16,6 +15,7 @@
|
||||||
#include <linux/numa.h>
|
#include <linux/numa.h>
|
||||||
#include <linux/ftrace.h>
|
#include <linux/ftrace.h>
|
||||||
#include <linux/suspend.h>
|
#include <linux/suspend.h>
|
||||||
|
#include <linux/lmb.h>
|
||||||
#include <asm/pgtable.h>
|
#include <asm/pgtable.h>
|
||||||
#include <asm/pgalloc.h>
|
#include <asm/pgalloc.h>
|
||||||
#include <asm/mmu_context.h>
|
#include <asm/mmu_context.h>
|
||||||
|
@ -148,3 +148,52 @@ void arch_crash_save_vmcoreinfo(void)
|
||||||
VMCOREINFO_LENGTH(node_data, MAX_NUMNODES);
|
VMCOREINFO_LENGTH(node_data, MAX_NUMNODES);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void __init reserve_crashkernel(void)
|
||||||
|
{
|
||||||
|
unsigned long long crash_size, crash_base;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
/* this is necessary because of lmb_phys_mem_size() */
|
||||||
|
lmb_analyze();
|
||||||
|
|
||||||
|
ret = parse_crashkernel(boot_command_line, lmb_phys_mem_size(),
|
||||||
|
&crash_size, &crash_base);
|
||||||
|
if (ret == 0 && crash_size > 0) {
|
||||||
|
crashk_res.start = crash_base;
|
||||||
|
crashk_res.end = crash_base + crash_size - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (crashk_res.end == crashk_res.start)
|
||||||
|
goto disable;
|
||||||
|
|
||||||
|
crash_size = PAGE_ALIGN(crashk_res.end - crashk_res.start + 1);
|
||||||
|
if (!crashk_res.start) {
|
||||||
|
crashk_res.start = lmb_alloc(crash_size, PAGE_SIZE);
|
||||||
|
if (!crashk_res.start) {
|
||||||
|
pr_err("crashkernel allocation failed\n");
|
||||||
|
goto disable;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ret = lmb_reserve(crashk_res.start, crash_size);
|
||||||
|
if (unlikely(ret < 0)) {
|
||||||
|
pr_err("crashkernel reservation failed - "
|
||||||
|
"memory is in use\n");
|
||||||
|
goto disable;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pr_info("Reserving %ldMB of memory at %ldMB "
|
||||||
|
"for crashkernel (System RAM: %ldMB)\n",
|
||||||
|
(unsigned long)(crash_size >> 20),
|
||||||
|
(unsigned long)(crashk_res.start >> 20),
|
||||||
|
(unsigned long)(lmb_phys_mem_size() >> 20));
|
||||||
|
|
||||||
|
crashk_res.end = crashk_res.start + crash_size - 1;
|
||||||
|
insert_resource(&iomem_resource, &crashk_res);
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
disable:
|
||||||
|
crashk_res.start = crashk_res.end = 0;
|
||||||
|
}
|
||||||
|
|
|
@ -145,49 +145,6 @@ static void __init register_bootmem_low_pages(void)
|
||||||
free_bootmem(PFN_PHYS(curr_pfn), PFN_PHYS(pages));
|
free_bootmem(PFN_PHYS(curr_pfn), PFN_PHYS(pages));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_KEXEC
|
|
||||||
static void __init reserve_crashkernel(void)
|
|
||||||
{
|
|
||||||
unsigned long long free_mem;
|
|
||||||
unsigned long long crash_size, crash_base;
|
|
||||||
void *vp;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
free_mem = ((unsigned long long)max_low_pfn - min_low_pfn) << PAGE_SHIFT;
|
|
||||||
|
|
||||||
ret = parse_crashkernel(boot_command_line, free_mem,
|
|
||||||
&crash_size, &crash_base);
|
|
||||||
if (ret == 0 && crash_size) {
|
|
||||||
if (crash_base <= 0) {
|
|
||||||
vp = alloc_bootmem_nopanic(crash_size);
|
|
||||||
if (!vp) {
|
|
||||||
printk(KERN_INFO "crashkernel allocation "
|
|
||||||
"failed\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
crash_base = __pa(vp);
|
|
||||||
} else if (reserve_bootmem(crash_base, crash_size,
|
|
||||||
BOOTMEM_EXCLUSIVE) < 0) {
|
|
||||||
printk(KERN_INFO "crashkernel reservation failed - "
|
|
||||||
"memory is in use\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
printk(KERN_INFO "Reserving %ldMB of memory at %ldMB "
|
|
||||||
"for crashkernel (System RAM: %ldMB)\n",
|
|
||||||
(unsigned long)(crash_size >> 20),
|
|
||||||
(unsigned long)(crash_base >> 20),
|
|
||||||
(unsigned long)(free_mem >> 20));
|
|
||||||
crashk_res.start = crash_base;
|
|
||||||
crashk_res.end = crash_base + crash_size - 1;
|
|
||||||
insert_resource(&iomem_resource, &crashk_res);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
static inline void __init reserve_crashkernel(void)
|
|
||||||
{}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void __init check_for_initrd(void)
|
static void __init check_for_initrd(void)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_BLK_DEV_INITRD
|
#ifdef CONFIG_BLK_DEV_INITRD
|
||||||
|
|
Loading…
Reference in a new issue