]> git.ipfire.org Git - people/arne_f/kernel.git/commitdiff
ARM: 9069/1: NOMMU: Fix conversion for_each_membock() to for_each_mem_range()
authorVladimir Murzin <vladimir.murzin@arm.com>
Thu, 11 Mar 2021 12:32:16 +0000 (13:32 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 21 Apr 2021 11:13:27 +0000 (13:13 +0200)
[ Upstream commit 45c2f70cba3a7eff34574103b2e2b901a5f771aa ]

for_each_mem_range() uses a loop variable, yet looking into code it is
not just iteration counter but more complex entity which encodes
information about memblock. Thus condition i == 0 looks fragile.
Indeed, it broke boot of R-class platforms since it never took i == 0
path (due to i was set to 1). Fix that with restoring original flag
check.

Fixes: b10d6bca8720 ("arch, drivers: replace for_each_membock() with for_each_mem_range()")
Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com>
Acked-by: Mike Rapoport <rppt@linux.ibm.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/arm/mm/pmsa-v7.c
arch/arm/mm/pmsa-v8.c

index 88950e41a3a9e7eb50b043560d89536d2dbde2c7..59d916ccdf25fe7ffbf6724051145bd657a8cd1b 100644 (file)
@@ -235,6 +235,7 @@ void __init pmsav7_adjust_lowmem_bounds(void)
        phys_addr_t mem_end;
        phys_addr_t reg_start, reg_end;
        unsigned int mem_max_regions;
+       bool first = true;
        int num;
        u64 i;
 
@@ -263,7 +264,7 @@ void __init pmsav7_adjust_lowmem_bounds(void)
 #endif
 
        for_each_mem_range(i, &reg_start, &reg_end) {
-               if (i == 0) {
+               if (first) {
                        phys_addr_t phys_offset = PHYS_OFFSET;
 
                        /*
@@ -275,6 +276,7 @@ void __init pmsav7_adjust_lowmem_bounds(void)
                        mem_start = reg_start;
                        mem_end = reg_end;
                        specified_mem_size = mem_end - mem_start;
+                       first = false;
                } else {
                        /*
                         * memblock auto merges contiguous blocks, remove
index 2de019f7503e87d9f5229b5672c901a0dae63958..8359748a19a11a6a206c59facacc0378704c6cc4 100644 (file)
@@ -95,10 +95,11 @@ void __init pmsav8_adjust_lowmem_bounds(void)
 {
        phys_addr_t mem_end;
        phys_addr_t reg_start, reg_end;
+       bool first = true;
        u64 i;
 
        for_each_mem_range(i, &reg_start, &reg_end) {
-               if (i == 0) {
+               if (first) {
                        phys_addr_t phys_offset = PHYS_OFFSET;
 
                        /*
@@ -107,6 +108,7 @@ void __init pmsav8_adjust_lowmem_bounds(void)
                        if (reg_start != phys_offset)
                                panic("First memory bank must be contiguous from PHYS_OFFSET");
                        mem_end = reg_end;
+                       first = false;
                } else {
                        /*
                         * memblock auto merges contiguous blocks, remove