Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c2882b7f authored by Prem Mallappa's avatar Prem Mallappa Committed by Ralf Baechle
Browse files

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: default avatarPrem Mallappa <pmallappa@caviumnetworks.com>
Cc: linux-mips <linux-mips@linux-mips.org>
Patchwork: http://patchwork.linux-mips.org/patch/5805/


Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent 273463b7
Loading
Loading
Loading
Loading
+48 −51
Original line number Original line Diff line number Diff line
@@ -552,6 +552,52 @@ static void __init arch_mem_addpart(phys_t mem, phys_t end, int type)
	add_memory_region(mem, size, type);
	add_memory_region(mem, size, type);
}
}


#ifdef CONFIG_KEXEC
static inline unsigned long long get_total_mem(void)
{
	unsigned long long total;

	total = max_pfn - min_low_pfn;
	return total << PAGE_SHIFT;
}

static void __init mips_parse_crashkernel(void)
{
	unsigned long long total_mem;
	unsigned long long crash_size, crash_base;
	int ret;

	total_mem = get_total_mem();
	ret = parse_crashkernel(boot_command_line, total_mem,
				&crash_size, &crash_base);
	if (ret != 0 || crash_size <= 0)
		return;

	crashk_res.start = crash_base;
	crashk_res.end	 = crash_base + crash_size - 1;
}

static void __init request_crashkernel(struct resource *res)
{
	int ret;

	ret = request_resource(res, &crashk_res);
	if (!ret)
		pr_info("Reserving %ldMB of memory at %ldMB for crashkernel\n",
			(unsigned long)((crashk_res.end -
					 crashk_res.start + 1) >> 20),
			(unsigned long)(crashk_res.start  >> 20));
}
#else /* !defined(CONFIG_KEXEC)		*/
static void __init mips_parse_crashkernel(void)
{
}

static void __init request_crashkernel(struct resource *res)
{
}
#endif /* !defined(CONFIG_KEXEC)  */

static void __init arch_mem_init(char **cmdline_p)
static void __init arch_mem_init(char **cmdline_p)
{
{
	extern void plat_mem_setup(void);
	extern void plat_mem_setup(void);
@@ -608,6 +654,8 @@ static void __init arch_mem_init(char **cmdline_p)
				BOOTMEM_DEFAULT);
				BOOTMEM_DEFAULT);
	}
	}
#endif
#endif

	mips_parse_crashkernel();
#ifdef CONFIG_KEXEC
#ifdef CONFIG_KEXEC
	if (crashk_res.start != crashk_res.end)
	if (crashk_res.start != crashk_res.end)
		reserve_bootmem(crashk_res.start,
		reserve_bootmem(crashk_res.start,
@@ -620,52 +668,6 @@ static void __init arch_mem_init(char **cmdline_p)
	paging_init();
	paging_init();
}
}


#ifdef CONFIG_KEXEC
static inline unsigned long long get_total_mem(void)
{
	unsigned long long total;

	total = max_pfn - min_low_pfn;
	return total << PAGE_SHIFT;
}

static void __init mips_parse_crashkernel(void)
{
	unsigned long long total_mem;
	unsigned long long crash_size, crash_base;
	int ret;

	total_mem = get_total_mem();
	ret = parse_crashkernel(boot_command_line, total_mem,
				&crash_size, &crash_base);
	if (ret != 0 || crash_size <= 0)
		return;

	crashk_res.start = crash_base;
	crashk_res.end	 = crash_base + crash_size - 1;
}

static void __init request_crashkernel(struct resource *res)
{
	int ret;

	ret = request_resource(res, &crashk_res);
	if (!ret)
		pr_info("Reserving %ldMB of memory at %ldMB for crashkernel\n",
			(unsigned long)((crashk_res.end -
				crashk_res.start + 1) >> 20),
			(unsigned long)(crashk_res.start  >> 20));
}
#else /* !defined(CONFIG_KEXEC)	 */
static void __init mips_parse_crashkernel(void)
{
}

static void __init request_crashkernel(struct resource *res)
{
}
#endif /* !defined(CONFIG_KEXEC)  */

static void __init resource_init(void)
static void __init resource_init(void)
{
{
	int i;
	int i;
@@ -678,11 +680,6 @@ static void __init resource_init(void)
	data_resource.start = __pa_symbol(&_etext);
	data_resource.start = __pa_symbol(&_etext);
	data_resource.end = __pa_symbol(&_edata) - 1;
	data_resource.end = __pa_symbol(&_edata) - 1;


	/*
	 * Request address space for all standard RAM.
	 */
	mips_parse_crashkernel();

	for (i = 0; i < boot_mem_map.nr_map; i++) {
	for (i = 0; i < boot_mem_map.nr_map; i++) {
		struct resource *res;
		struct resource *res;
		unsigned long start, end;
		unsigned long start, end;