aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mm
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2010-10-27 13:14:56 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2010-10-28 08:54:41 -0400
commit7dc50ec7283391dd7a29a80e2a0fb76731a6a7c7 (patch)
treecfce6e8adf5c4a50ed04f390a7acf8f4d7d8b5df /arch/arm/mm
parentc8c90860cd3592fac83a349f84a20360a6498727 (diff)
ARM: ensure membank array is always sorted
This was missing from the noMMU code, so there was the possibility of things not working as expected if out of order memory information was passed. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mm')
-rw-r--r--arch/arm/mm/init.c10
-rw-r--r--arch/arm/mm/mmu.c10
2 files changed, 10 insertions, 10 deletions
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 7fd9b5eb177..759878355a0 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -18,6 +18,7 @@
18#include <linux/highmem.h> 18#include <linux/highmem.h>
19#include <linux/gfp.h> 19#include <linux/gfp.h>
20#include <linux/memblock.h> 20#include <linux/memblock.h>
21#include <linux/sort.h>
21 22
22#include <asm/mach-types.h> 23#include <asm/mach-types.h>
23#include <asm/sections.h> 24#include <asm/sections.h>
@@ -256,10 +257,19 @@ static void arm_memory_present(void)
256} 257}
257#endif 258#endif
258 259
260static int __init meminfo_cmp(const void *_a, const void *_b)
261{
262 const struct membank *a = _a, *b = _b;
263 long cmp = bank_pfn_start(a) - bank_pfn_start(b);
264 return cmp < 0 ? -1 : cmp > 0 ? 1 : 0;
265}
266
259void __init arm_memblock_init(struct meminfo *mi, struct machine_desc *mdesc) 267void __init arm_memblock_init(struct meminfo *mi, struct machine_desc *mdesc)
260{ 268{
261 int i; 269 int i;
262 270
271 sort(&meminfo.bank, meminfo.nr_banks, sizeof(meminfo.bank[0]), meminfo_cmp, NULL);
272
263 memblock_init(); 273 memblock_init();
264 for (i = 0; i < mi->nr_banks; i++) 274 for (i = 0; i < mi->nr_banks; i++)
265 memblock_add(mi->bank[i].start, mi->bank[i].size); 275 memblock_add(mi->bank[i].start, mi->bank[i].size);
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index 8e21b4e721e..5222d385096 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -14,7 +14,6 @@
14#include <linux/mman.h> 14#include <linux/mman.h>
15#include <linux/nodemask.h> 15#include <linux/nodemask.h>
16#include <linux/memblock.h> 16#include <linux/memblock.h>
17#include <linux/sort.h>
18#include <linux/fs.h> 17#include <linux/fs.h>
19 18
20#include <asm/cputype.h> 19#include <asm/cputype.h>
@@ -1011,13 +1010,6 @@ static void __init map_lowmem(void)
1011 } 1010 }
1012} 1011}
1013 1012
1014static int __init meminfo_cmp(const void *_a, const void *_b)
1015{
1016 const struct membank *a = _a, *b = _b;
1017 long cmp = bank_pfn_start(a) - bank_pfn_start(b);
1018 return cmp < 0 ? -1 : cmp > 0 ? 1 : 0;
1019}
1020
1021/* 1013/*
1022 * paging_init() sets up the page tables, initialises the zone memory 1014 * paging_init() sets up the page tables, initialises the zone memory
1023 * maps, and sets up the zero page, bad page and bad page tables. 1015 * maps, and sets up the zero page, bad page and bad page tables.
@@ -1026,8 +1018,6 @@ void __init paging_init(struct machine_desc *mdesc)
1026{ 1018{
1027 void *zero_page; 1019 void *zero_page;
1028 1020
1029 sort(&meminfo.bank, meminfo.nr_banks, sizeof(meminfo.bank[0]), meminfo_cmp, NULL);
1030
1031 build_mem_type_table(); 1021 build_mem_type_table();
1032 sanity_check_meminfo(); 1022 sanity_check_meminfo();
1033 prepare_page_table(); 1023 prepare_page_table();