MIPS: Reserve extra memory for crash dump
Subsystems (2)
PATCH 1/2 MIPS: Reserve extra memory for crash dump
Traditionally, MIPS's contiguous low memory can be as less as 256M, so crashkernel=X@Y may be unable to large enough in some cases. Moreover, for the "multi numa node + sparse memory model" case, it is attempt to allocate section_mem_maps on every node. Thus, if the total memory of a node is more than 1GB, we reserve the top 128MB for the crash kernel.
--- arch/mips/kernel/setup.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+)
arch/mips/kernel/setup.c +51 -0
@@ -27,6 +27,7 @@#include <linux/dma-contiguous.h> #include <linux/decompress/generic.h> #include <linux/of_fdt.h> +#include <linux/crash_dump.h> #include <asm/addrspace.h> #include <asm/bootinfo.h>
@@ -756,6 +757,48 @@ static void __init request_crashkernel(struct resource *res)#define BUILTIN_EXTEND_WITH_PROM \ IS_ENABLED(CONFIG_MIPS_CMDLINE_BUILTIN_EXTEND) +/* Traditionally, MIPS's contiguous low memory is 256M, so crashkernel=X@Y is +* unable to be large enough in some cases. Thus, if the total memory of a node +* is more than 1GB, we reserve the top 128MB for the crash kernel */ +static void reserve_crashm_region (int node,unsigned long s0,unsigned long e0) +{ +#ifdef CONFIG_KEXEC +if (crashk_res.start == crashk_res.end) +return ; + +if ((e0 - s0) <= (SZ_1G >>PAGE_SHIFT )) +return ; + + s0 = e0 - (SZ_128M >>PAGE_SHIFT ); + +memblock_reserve (PFN_PHYS (s0), (e0 - s0) <<PAGE_SHIFT ); +#endif +} + +static void reserve_oldmem_region (int node,unsigned long s0,unsigned long e0) +{ +#ifdef CONFIG_CRASH_DUMP +unsigned long s1, e1; + +if (!is_kdump_kernel ()) +return ; + +if ((e0 - s0) > (SZ_1G >>PAGE_SHIFT )) + e0 = e0 - (SZ_128M >>PAGE_SHIFT ); + +/* boot_mem_map.map[0] is crashk_res reserved by primary kernel */ + s1 =PFN_UP (boot_mem_map.map[0 ].addr); + e1 =PFN_DOWN (boot_mem_map.map[0 ].addr + boot_mem_map.map[0 ].size); + +if (node ==0 ) { +memblock_reserve (PFN_PHYS (s0), (s1 - s0) <<PAGE_SHIFT ); +memblock_reserve (PFN_PHYS (e1), (e0 - e1) <<PAGE_SHIFT ); + }else { +memblock_reserve (PFN_PHYS (s0), (e0 - s0) <<PAGE_SHIFT ); + } +#endif +} +/* * arch_mem_init - initialize memory management subsystem *
@@ -780,6 +823,8 @@ static void __init request_crashkernel(struct resource *res)*/ static void __init arch_mem_init (char **cmdline_p) { +unsigned int node; +unsigned long start_pfn, end_pfn;struct memblock_region *reg;extern void plat_mem_setup (void );
@@ -878,6 +923,12 @@ static void __init arch_mem_init(char **cmdline_p)memblock_reserve (crashk_res.start, crashk_res.end - crashk_res.start +1 );#endif +for_each_online_node (node) { +get_pfn_range_for_nid (node, &start_pfn, &end_pfn); +reserve_crashm_region (node, start_pfn, end_pfn); +reserve_oldmem_region (node, start_pfn, end_pfn); + } +device_tree_init ();sparse_init ();plat_swiotlb_setup ();
Signature · 1 line
2.7.0
PATCH 2/2 MIPS: Loongson64: Add kexec/kdump support
Add kexec/kdump support for Loongson64 by:
1, Provide Loongson-specific kexec functions: loongson_kexec_prepare,
loongson_kexec_shutdown and loongson_crash_shutdown;
2, Provide Loongson-specific code in kexec_smp_wait;
3, Clear mailbox in loongson3_smp_setup() since KEXEC bypass BIOS; 4, KEXEC always run at boot-cpu, but KDUMP may triggered at non-boot-
cpu. Loongson64 assume boot-cpu is the first possible cpu, so fix boot_cpu_id in prom_init_env();
--- arch/mips/kernel/relocate_kernel.S | 26 ++++++++++ arch/mips/loongson64/common/env.c | 7 +++ arch/mips/loongson64/common/reset.c | 95 +++++++++++++++++++++++++++++++++++ arch/mips/loongson64/loongson-3/smp.c | 5 ++ 4 files changed, 133 insertions(+)
arch/mips/kernel/relocate_kernel.S +26 -0
@@ -135,6 +135,32 @@ LEAF(kexec_smp_wait) #else sync #endif + +#ifdef CONFIG_CPU_LOONGSON3 + /* s0:prid s1:initfn */ + /* t0:base t1:cpuid t2:node t9:count */ + mfc0 t1, CP0_EBASE + andi t1, MIPS_EBASE_CPUNUM + dli t0, 0x900000003ff01000 /* mailbox base */ + dins t0, t1, 8, 2 /* insert core id*/ + dext t2, t1, 2, 2 + dins t0, t2, 44, 2 /* insert node id */ + mfc0 s0, CP0_PRID + andi s0, s0, 0xf + blt s0, 0x6, 1f /* Loongson-3A1000 */ + bgt s0, 0x7, 1f /* Loongson-3A2000/3A3000 */ + dins t0, t2, 14, 2 /* Loongson-3B1000/3B1500 need bit 15~14 */ +1: li t9, 0x100 /* wait for init loop */ +2: addiu t9, -1 /* limit mailbox access */ + bnez t9, 2b + ld s1, 0x20(t0) /* get PC via mailbox */ + beqz s1, 1b + ld sp, 0x28(t0) /* get SP via mailbox */ + ld gp, 0x30(t0) /* get GP via mailbox */ + ld a1, 0x38(t0) + jr s1 /* jump to initial PC */ +#endif + j s1 END(kexec_smp_wait) #endif
arch/mips/loongson64/common/env.c +7 -0
@@ -149,6 +149,13 @@ void __init prom_init_env(void) loongson_sysconf.nr_cpus = ecpu->nr_cpus; loongson_sysconf.boot_cpu_id = ecpu->cpu_startup_core_id; loongson_sysconf.reserved_cpus_mask = ecpu->reserved_cores_mask; +#ifdef CONFIG_KEXEC + loongson_sysconf.boot_cpu_id =get_ebase_cpunum (); + loongson_sysconf.reserved_cpus_mask |= + (1 << loongson_sysconf.boot_cpu_id) -1 ; +pr_info ("Boot CPU ID is being fixed from %d to %d\n" , + ecpu->cpu_startup_core_id, loongson_sysconf.boot_cpu_id); +#endif if (ecpu->nr_cpus >NR_CPUS || ecpu->nr_cpus ==0 ) loongson_sysconf.nr_cpus =NR_CPUS ; loongson_sysconf.nr_nodes = (loongson_sysconf.nr_cpus +
arch/mips/loongson64/common/reset.c +95 -0
116 lines not on this page · raw message
arch/mips/loongson64/loongson-3/smp.c +5 -0
@@ -388,6 +388,11 @@ static void __init loongson3_smp_setup(void)ipi_status0_regs_init ();ipi_en0_regs_init ();ipi_mailbox_buf_init (); + +/* BIOS clear the mailbox, but KEXEC bypass BIOS so clear here */ +for (i =0 ; i < loongson_sysconf.nr_cpus; i++) +loongson3_ipi_write64 (0 , (void *)(ipi_mailbox_buf[i]+0x0 )); +cpu_set_core (&cpu_data[0 ],cpu_logical_map (0 ) % loongson_sysconf.cores_per_package); cpu_data[0 ].package =cpu_logical_map (0 ) / loongson_sysconf.cores_per_package;
Signature · 1 line
2.7.0