fa923f18296fe4b01c23abe38114a4955f6a7c2e
[openwrt/openwrt.git] / target / linux / ramips / patches-5.4 / 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
18 +++ b/arch/mips/kernel/setup.c
19 @@ -285,6 +285,8 @@ static unsigned long __init init_initrd(
20 * Initialize the bootmem allocator. It also setup initrd related data
21 * if needed.
22 */
23 +static int usermem __initdata;
24 +
25 #if defined(CONFIG_SGI_IP27) || (defined(CONFIG_CPU_LOONGSON3) && defined(CONFIG_NUMA))
26
27 static void __init bootmem_init(void)
28 @@ -323,7 +325,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 memblock_reserve(PHYS_OFFSET, ramstart - PHYS_OFFSET);
35
36 if (PFN_UP(ramstart) > ARCH_PFN_OFFSET) {
37 @@ -384,8 +386,6 @@ static void __init bootmem_init(void)
38
39 #endif /* CONFIG_SGI_IP27 */
40
41 -static int usermem __initdata;
42 -
43 static int __init early_parse_mem(char *p)
44 {
45 phys_addr_t start, size;