ramips: Fix early memory calculation for certain MIPS platforms
[openwrt/openwrt.git] / target / linux / ramips / patches-4.14 / 0003-MIPS-Fix-memory-reservation-in-bootmem_init-for-cert.patch
1 From: Tobias Wolf <dev-NTEO@vplace.de>
2 Subject: [v2] MIPS: Fix memory reservation in bootmem_init for certain non-usermem setups
3
4 Commit 67a3ba25aa95 ("MIPS: Fix incorrect mem=X@Y handling") introduced a new
5 issue for rt288x where "PHYS_OFFSET" is 0x0 but the calculated "ramstart" is
6 not. As the prerequisite of custom memory map has been removed, this results
7 in the full memory range of 0x0 - 0x8000000 to be marked as reserved for this
8 platform.
9
10 v2: Correctly compare that usermem is not null.
11
12 This patch adds the originally intended prerequisite again.
13
14 Signed-off-by: Tobias Wolf <dev-NTEO@vplace.de>
15 ---
16
17 --- a/arch/mips/kernel/setup.c 2018-08-18 19:07:07.142066706 +0200
18 +++ b/arch/mips/kernel/setup.c 2018-08-18 19:10:17.827918423 +0200
19 @@ -369,6 +369,8 @@ static unsigned long __init bootmap_byte
20 return ALIGN(bytes, sizeof(long));
21 }
22
23 +static int usermem __initdata;
24 +
25 static void __init bootmem_init(void)
26 {
27 unsigned long reserved_end;
28 @@ -442,7 +444,7 @@ static void __init bootmem_init(void)
29 /*
30 * Reserve any memory between the start of RAM and PHYS_OFFSET
31 */
32 - if (ramstart > PHYS_OFFSET)
33 + if (usermem && ramstart > PHYS_OFFSET)
34 add_memory_region(PHYS_OFFSET, ramstart - PHYS_OFFSET,
35 BOOT_MEM_RESERVED);
36
37 @@ -652,8 +654,6 @@ static void __init bootmem_init(void)
38 * initialization hook for anything else was introduced.
39 */
40
41 -static int usermem __initdata;
42 -
43 static int __init early_parse_mem(char *p)
44 {
45 phys_addr_t start, size;