Skip to content

Commit c2882b7

Browse files
pmallapparalfbaechle
authored andcommitted
MIPS: kexec: Fix random crashes while loading crashkernel
Fixed compilation errors in case of non-KEXEC kernel Rearranging code so that crashk_res gets updated. - crashk_res is updated after mips_parse_crashkernel(), after resource_init(), which is after arch_mem_init(). - The reserved memory is actually treated as Usable memory, Unless we load the crash kernel, everything works. Signed-off-by: Prem Mallappa <pmallappa@caviumnetworks.com> Cc: linux-mips <linux-mips@linux-mips.org> Patchwork: http://patchwork.linux-mips.org/patch/5805/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
1 parent 273463b commit c2882b7

File tree

1 file changed

+48
-51
lines changed

1 file changed

+48
-51
lines changed

arch/mips/kernel/setup.c

Lines changed: 48 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,52 @@ static void __init arch_mem_addpart(phys_t mem, phys_t end, int type)
552552
add_memory_region(mem, size, type);
553553
}
554554

555+
#ifdef CONFIG_KEXEC
556+
static inline unsigned long long get_total_mem(void)
557+
{
558+
unsigned long long total;
559+
560+
total = max_pfn - min_low_pfn;
561+
return total << PAGE_SHIFT;
562+
}
563+
564+
static void __init mips_parse_crashkernel(void)
565+
{
566+
unsigned long long total_mem;
567+
unsigned long long crash_size, crash_base;
568+
int ret;
569+
570+
total_mem = get_total_mem();
571+
ret = parse_crashkernel(boot_command_line, total_mem,
572+
&crash_size, &crash_base);
573+
if (ret != 0 || crash_size <= 0)
574+
return;
575+
576+
crashk_res.start = crash_base;
577+
crashk_res.end = crash_base + crash_size - 1;
578+
}
579+
580+
static void __init request_crashkernel(struct resource *res)
581+
{
582+
int ret;
583+
584+
ret = request_resource(res, &crashk_res);
585+
if (!ret)
586+
pr_info("Reserving %ldMB of memory at %ldMB for crashkernel\n",
587+
(unsigned long)((crashk_res.end -
588+
crashk_res.start + 1) >> 20),
589+
(unsigned long)(crashk_res.start >> 20));
590+
}
591+
#else /* !defined(CONFIG_KEXEC) */
592+
static void __init mips_parse_crashkernel(void)
593+
{
594+
}
595+
596+
static void __init request_crashkernel(struct resource *res)
597+
{
598+
}
599+
#endif /* !defined(CONFIG_KEXEC) */
600+
555601
static void __init arch_mem_init(char **cmdline_p)
556602
{
557603
extern void plat_mem_setup(void);
@@ -608,6 +654,8 @@ static void __init arch_mem_init(char **cmdline_p)
608654
BOOTMEM_DEFAULT);
609655
}
610656
#endif
657+
658+
mips_parse_crashkernel();
611659
#ifdef CONFIG_KEXEC
612660
if (crashk_res.start != crashk_res.end)
613661
reserve_bootmem(crashk_res.start,
@@ -620,52 +668,6 @@ static void __init arch_mem_init(char **cmdline_p)
620668
paging_init();
621669
}
622670

623-
#ifdef CONFIG_KEXEC
624-
static inline unsigned long long get_total_mem(void)
625-
{
626-
unsigned long long total;
627-
628-
total = max_pfn - min_low_pfn;
629-
return total << PAGE_SHIFT;
630-
}
631-
632-
static void __init mips_parse_crashkernel(void)
633-
{
634-
unsigned long long total_mem;
635-
unsigned long long crash_size, crash_base;
636-
int ret;
637-
638-
total_mem = get_total_mem();
639-
ret = parse_crashkernel(boot_command_line, total_mem,
640-
&crash_size, &crash_base);
641-
if (ret != 0 || crash_size <= 0)
642-
return;
643-
644-
crashk_res.start = crash_base;
645-
crashk_res.end = crash_base + crash_size - 1;
646-
}
647-
648-
static void __init request_crashkernel(struct resource *res)
649-
{
650-
int ret;
651-
652-
ret = request_resource(res, &crashk_res);
653-
if (!ret)
654-
pr_info("Reserving %ldMB of memory at %ldMB for crashkernel\n",
655-
(unsigned long)((crashk_res.end -
656-
crashk_res.start + 1) >> 20),
657-
(unsigned long)(crashk_res.start >> 20));
658-
}
659-
#else /* !defined(CONFIG_KEXEC) */
660-
static void __init mips_parse_crashkernel(void)
661-
{
662-
}
663-
664-
static void __init request_crashkernel(struct resource *res)
665-
{
666-
}
667-
#endif /* !defined(CONFIG_KEXEC) */
668-
669671
static void __init resource_init(void)
670672
{
671673
int i;
@@ -678,11 +680,6 @@ static void __init resource_init(void)
678680
data_resource.start = __pa_symbol(&_etext);
679681
data_resource.end = __pa_symbol(&_edata) - 1;
680682

681-
/*
682-
* Request address space for all standard RAM.
683-
*/
684-
mips_parse_crashkernel();
685-
686683
for (i = 0; i < boot_mem_map.nr_map; i++) {
687684
struct resource *res;
688685
unsigned long start, end;

0 commit comments

Comments
 (0)