diff options
| author | Mika Westerberg <mika.westerberg@iki.fi> | 2010-05-10 04:20:22 -0400 |
|---|---|---|
| committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2010-07-09 10:00:51 -0400 |
| commit | 3c57fb43c8fcbe46541d3a0274f0b4c802c68927 (patch) | |
| tree | 7724845adb0980369b25b5dc97ace64164b17367 | |
| parent | f159f4ed55bb0fa5470800641e03a13a7e0eae6e (diff) | |
ARM: 6116/1: kdump: reserve memory for crashkernel
Implemented ARM support for command line option
"crashkernel=size@start" which allows user to reserve some memory
for a dump capture kernel.
Signed-off-by: Mika Westerberg <ext-mika.1.westerberg@nokia.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
| -rw-r--r-- | arch/arm/kernel/setup.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index 648c3c1e16c4..714cbaaab3aa 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | #include <linux/seq_file.h> | 19 | #include <linux/seq_file.h> |
| 20 | #include <linux/screen_info.h> | 20 | #include <linux/screen_info.h> |
| 21 | #include <linux/init.h> | 21 | #include <linux/init.h> |
| 22 | #include <linux/kexec.h> | ||
| 22 | #include <linux/root_dev.h> | 23 | #include <linux/root_dev.h> |
| 23 | #include <linux/cpu.h> | 24 | #include <linux/cpu.h> |
| 24 | #include <linux/interrupt.h> | 25 | #include <linux/interrupt.h> |
| @@ -680,6 +681,55 @@ static int __init customize_machine(void) | |||
| 680 | } | 681 | } |
| 681 | arch_initcall(customize_machine); | 682 | arch_initcall(customize_machine); |
| 682 | 683 | ||
| 684 | #ifdef CONFIG_KEXEC | ||
| 685 | static inline unsigned long long get_total_mem(void) | ||
| 686 | { | ||
| 687 | unsigned long total; | ||
| 688 | |||
| 689 | total = max_low_pfn - min_low_pfn; | ||
| 690 | return total << PAGE_SHIFT; | ||
| 691 | } | ||
| 692 | |||
| 693 | /** | ||
| 694 | * reserve_crashkernel() - reserves memory are for crash kernel | ||
| 695 | * | ||
| 696 | * This function reserves memory area given in "crashkernel=" kernel command | ||
| 697 | * line parameter. The memory reserved is used by a dump capture kernel when | ||
| 698 | * primary kernel is crashing. | ||
| 699 | */ | ||
| 700 | static void __init reserve_crashkernel(void) | ||
| 701 | { | ||
| 702 | unsigned long long crash_size, crash_base; | ||
| 703 | unsigned long long total_mem; | ||
| 704 | int ret; | ||
| 705 | |||
| 706 | total_mem = get_total_mem(); | ||
| 707 | ret = parse_crashkernel(boot_command_line, total_mem, | ||
| 708 | &crash_size, &crash_base); | ||
| 709 | if (ret) | ||
| 710 | return; | ||
| 711 | |||
| 712 | ret = reserve_bootmem(crash_base, crash_size, BOOTMEM_EXCLUSIVE); | ||
| 713 | if (ret < 0) { | ||
| 714 | printk(KERN_WARNING "crashkernel reservation failed - " | ||
| 715 | "memory is in use (0x%lx)\n", (unsigned long)crash_base); | ||
| 716 | return; | ||
| 717 | } | ||
| 718 | |||
| 719 | printk(KERN_INFO "Reserving %ldMB of memory at %ldMB " | ||
| 720 | "for crashkernel (System RAM: %ldMB)\n", | ||
| 721 | (unsigned long)(crash_size >> 20), | ||
| 722 | (unsigned long)(crash_base >> 20), | ||
| 723 | (unsigned long)(total_mem >> 20)); | ||
| 724 | |||
| 725 | crashk_res.start = crash_base; | ||
| 726 | crashk_res.end = crash_base + crash_size - 1; | ||
| 727 | insert_resource(&iomem_resource, &crashk_res); | ||
| 728 | } | ||
| 729 | #else | ||
| 730 | static inline void reserve_crashkernel(void) {} | ||
| 731 | #endif /* CONFIG_KEXEC */ | ||
| 732 | |||
| 683 | void __init setup_arch(char **cmdline_p) | 733 | void __init setup_arch(char **cmdline_p) |
| 684 | { | 734 | { |
| 685 | struct tag *tags = (struct tag *)&init_tags; | 735 | struct tag *tags = (struct tag *)&init_tags; |
| @@ -739,6 +789,7 @@ void __init setup_arch(char **cmdline_p) | |||
| 739 | #ifdef CONFIG_SMP | 789 | #ifdef CONFIG_SMP |
| 740 | smp_init_cpus(); | 790 | smp_init_cpus(); |
| 741 | #endif | 791 | #endif |
| 792 | reserve_crashkernel(); | ||
| 742 | 793 | ||
| 743 | cpu_init(); | 794 | cpu_init(); |
| 744 | tcm_init(); | 795 | tcm_init(); |
