ARM: NOMMU: Fix conversion for_each_membock() to for_each_mem_range()
PATCH 1/1 ARM: 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.
--- arch/arm/mm/pmsa-v7.c | 4 +++- arch/arm/mm/pmsa-v8.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-)
arch/arm/mm/pmsa-v7.c +3 -1
@@ -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, ®_start, ®_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
arch/arm/mm/pmsa-v8.c +3 -1
@@ -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, ®_start, ®_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
Signature · 7 lines
2.24.0 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 5 lines · Vladimir Murzin
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).
Oops, sorry about that.
Quoted 5 lines
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 <[email protected]>
Quoted 62 lines
--- arch/arm/mm/pmsa-v7.c | 4 +++- arch/arm/mm/pmsa-v8.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-)arch/arm/mm/pmsa-v7.c +3
-1@@ -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, ®_start, ®_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 arch/arm/mm/pmsa-v8.c +3
-1@@ -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, ®_start, ®_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 Signature · 1 line
2.24.0
Signature · 7 lines
Sincerely yours, Mike. _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 9 lines · Mike Rapoport
Quoted 5 lines · Vladimir Murzin
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).Oops, sorry about that.
Quoted 8 lines
Quoted 5 lines
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 <[email protected]>Acked-by Mike Rapoport <[email protected]>
Thanks!
I've just put it into Russell's patch system as patch 9069/1
Vladimir
Quoted 50 lines
Quoted 50 lines
--- arch/arm/mm/pmsa-v7.c | 4 +++- arch/arm/mm/pmsa-v8.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-)arch/arm/mm/pmsa-v7.c +3
-1@@ -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, ®_start, ®_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 arch/arm/mm/pmsa-v8.c +2
-1@@ -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, ®_start, ®_end) { -if (i ==0 ) { +if (first) {phys_addr_t phys_offset =PHYS_OFFSET ;
Quoted 13 lines
Quoted 12 lines
arch/arm/mm/pmsa-v8.c +1
-0/* @@ -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 Signature · 1 line
2.24.0
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel