Skip to content

Commit 45c2f70

Browse files
murzinvRussell King
authored andcommitted
ARM: 9069/1: NOMMU: Fix conversion for_each_membock() to for_each_mem_range()
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: b10d6bc ("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>
1 parent d624833 commit 45c2f70

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

arch/arm/mm/pmsa-v7.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ void __init pmsav7_adjust_lowmem_bounds(void)
235235
phys_addr_t mem_end;
236236
phys_addr_t reg_start, reg_end;
237237
unsigned int mem_max_regions;
238+
bool first = true;
238239
int num;
239240
u64 i;
240241

@@ -263,7 +264,7 @@ void __init pmsav7_adjust_lowmem_bounds(void)
263264
#endif
264265

265266
for_each_mem_range(i, &reg_start, &reg_end) {
266-
if (i == 0) {
267+
if (first) {
267268
phys_addr_t phys_offset = PHYS_OFFSET;
268269

269270
/*
@@ -275,6 +276,7 @@ void __init pmsav7_adjust_lowmem_bounds(void)
275276
mem_start = reg_start;
276277
mem_end = reg_end;
277278
specified_mem_size = mem_end - mem_start;
279+
first = false;
278280
} else {
279281
/*
280282
* memblock auto merges contiguous blocks, remove

arch/arm/mm/pmsa-v8.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,11 @@ void __init pmsav8_adjust_lowmem_bounds(void)
9595
{
9696
phys_addr_t mem_end;
9797
phys_addr_t reg_start, reg_end;
98+
bool first = true;
9899
u64 i;
99100

100101
for_each_mem_range(i, &reg_start, &reg_end) {
101-
if (i == 0) {
102+
if (first) {
102103
phys_addr_t phys_offset = PHYS_OFFSET;
103104

104105
/*
@@ -107,6 +108,7 @@ void __init pmsav8_adjust_lowmem_bounds(void)
107108
if (reg_start != phys_offset)
108109
panic("First memory bank must be contiguous from PHYS_OFFSET");
109110
mem_end = reg_end;
111+
first = false;
110112
} else {
111113
/*
112114
* memblock auto merges contiguous blocks, remove

0 commit comments

Comments
 (0)