aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorPrem Mallappa <prem.mallappa@gmail.com>2013-09-04 13:56:24 -0400
committerRalf Baechle <ralf@linux-mips.org>2013-09-05 14:53:43 -0400
commitc2882b7fab9251309dc10c980b17e486f848502f (patch)
tree30c1b22534557e7351720ed8f0caeb1c2be180fc /arch
parent273463b78237b53936a61046bfb4c8e55150ca24 (diff)
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>
Diffstat (limited to 'arch')
-rw-r--r--arch/mips/kernel/setup.c99
1 files changed, 48 insertions, 51 deletions
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index c7f90519e58c..c538d6e01b7b 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -552,6 +552,52 @@ static void __init arch_mem_addpart(phys_t mem, phys_t end, int type)
552 add_memory_region(mem, size, type); 552 add_memory_region(mem, size, type);
553} 553}
554 554
555#ifdef CONFIG_KEXEC
556static 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
564static 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
580static 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) */
592static void __init mips_parse_crashkernel(void)
593{
594}
595
596static void __init request_crashkernel(struct resource *res)
597{
598}
599#endif /* !defined(CONFIG_KEXEC) */
600
555static void __init arch_mem_init(char **cmdline_p) 601static void __init arch_mem_init(char **cmdline_p)
556{ 602{
557 extern void plat_mem_setup(void); 603 extern void plat_mem_setup(void);
@@ -608,6 +654,8 @@ static void __init arch_mem_init(char **cmdline_p)
608 BOOTMEM_DEFAULT); 654 BOOTMEM_DEFAULT);
609 } 655 }
610#endif 656#endif
657
658 mips_parse_crashkernel();
611#ifdef CONFIG_KEXEC 659#ifdef CONFIG_KEXEC
612 if (crashk_res.start != crashk_res.end) 660 if (crashk_res.start != crashk_res.end)
613 reserve_bootmem(crashk_res.start, 661 reserve_bootmem(crashk_res.start,
@@ -620,52 +668,6 @@ static void __init arch_mem_init(char **cmdline_p)
620 paging_init(); 668 paging_init();
621} 669}
622 670
623#ifdef CONFIG_KEXEC
624static 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
632static 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
648static 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) */
660static void __init mips_parse_crashkernel(void)
661{
662}
663
664static void __init request_crashkernel(struct resource *res)
665{
666}
667#endif /* !defined(CONFIG_KEXEC) */
668
669static void __init resource_init(void) 671static void __init resource_init(void)
670{ 672{
671 int i; 673 int i;
@@ -678,11 +680,6 @@ static void __init resource_init(void)
678 data_resource.start = __pa_symbol(&_etext); 680 data_resource.start = __pa_symbol(&_etext);
679 data_resource.end = __pa_symbol(&_edata) - 1; 681 data_resource.end = __pa_symbol(&_edata) - 1;
680 682
681 /*
682 * Request address space for all standard RAM.
683 */
684 mips_parse_crashkernel();
685
686 for (i = 0; i < boot_mem_map.nr_map; i++) { 683 for (i = 0; i < boot_mem_map.nr_map; i++) {
687 struct resource *res; 684 struct resource *res;
688 unsigned long start, end; 685 unsigned long start, end;