aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mm
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2008-10-01 11:56:15 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2008-10-01 12:22:02 -0400
commitd2a38ef9c1585b47462c7be5501228ac57fbd3b1 (patch)
tree81ae36059881fbee802ec45081a74a866d92819e /arch/arm/mm
parent6c5da7aced798c7781f054a76c769b85f0173561 (diff)
[ARM] mm: provide helpers for accessing membanks
Provide helpers for getting physical addresses or pfns from the meminfo array, and use them. Move for_each_nodebank() to asm/setup.h alongside the meminfo structure definition. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mm')
-rw-r--r--arch/arm/mm/init.c59
1 files changed, 28 insertions, 31 deletions
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index ffff901cf627..9b7f0bf26f57 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -69,10 +69,6 @@ __tagtable(ATAG_INITRD2, parse_tag_initrd2);
69 */ 69 */
70static struct meminfo meminfo = { 0, }; 70static struct meminfo meminfo = { 0, };
71 71
72#define for_each_nodebank(iter,mi,no) \
73 for (iter = 0; iter < mi->nr_banks; iter++) \
74 if (mi->bank[iter].node == no)
75
76void show_mem(void) 72void show_mem(void)
77{ 73{
78 int free = 0, total = 0, reserved = 0; 74 int free = 0, total = 0, reserved = 0;
@@ -86,11 +82,12 @@ void show_mem(void)
86 struct page *map = n->node_mem_map - n->node_start_pfn; 82 struct page *map = n->node_mem_map - n->node_start_pfn;
87 83
88 for_each_nodebank (i,mi,node) { 84 for_each_nodebank (i,mi,node) {
85 struct membank *bank = &mi->bank[i];
89 unsigned int pfn1, pfn2; 86 unsigned int pfn1, pfn2;
90 struct page *page, *end; 87 struct page *page, *end;
91 88
92 pfn1 = __phys_to_pfn(mi->bank[i].start); 89 pfn1 = bank_pfn_start(bank);
93 pfn2 = __phys_to_pfn(mi->bank[i].size + mi->bank[i].start); 90 pfn2 = bank_pfn_end(bank);
94 91
95 page = map + pfn1; 92 page = map + pfn1;
96 end = map + pfn2; 93 end = map + pfn2;
@@ -129,17 +126,17 @@ void show_mem(void)
129static unsigned int __init 126static unsigned int __init
130find_bootmap_pfn(int node, struct meminfo *mi, unsigned int bootmap_pages) 127find_bootmap_pfn(int node, struct meminfo *mi, unsigned int bootmap_pages)
131{ 128{
132 unsigned int start_pfn, bank, bootmap_pfn; 129 unsigned int start_pfn, i, bootmap_pfn;
133 130
134 start_pfn = PAGE_ALIGN(__pa(&_end)) >> PAGE_SHIFT; 131 start_pfn = PAGE_ALIGN(__pa(&_end)) >> PAGE_SHIFT;
135 bootmap_pfn = 0; 132 bootmap_pfn = 0;
136 133
137 for_each_nodebank(bank, mi, node) { 134 for_each_nodebank(i, mi, node) {
135 struct membank *bank = &mi->bank[i];
138 unsigned int start, end; 136 unsigned int start, end;
139 137
140 start = mi->bank[bank].start >> PAGE_SHIFT; 138 start = bank_pfn_start(bank);
141 end = (mi->bank[bank].size + 139 end = bank_pfn_end(bank);
142 mi->bank[bank].start) >> PAGE_SHIFT;
143 140
144 if (end < start_pfn) 141 if (end < start_pfn)
145 continue; 142 continue;
@@ -178,13 +175,10 @@ static int __init check_initrd(struct meminfo *mi)
178 initrd_node = -1; 175 initrd_node = -1;
179 176
180 for (i = 0; i < mi->nr_banks; i++) { 177 for (i = 0; i < mi->nr_banks; i++) {
181 unsigned long bank_end; 178 struct membank *bank = &mi->bank[i];
182 179 if (bank_phys_start(bank) <= phys_initrd_start &&
183 bank_end = mi->bank[i].start + mi->bank[i].size; 180 end <= bank_phys_end(bank))
184 181 initrd_node = bank->node;
185 if (mi->bank[i].start <= phys_initrd_start &&
186 end <= bank_end)
187 initrd_node = mi->bank[i].node;
188 } 182 }
189 } 183 }
190 184
@@ -204,9 +198,9 @@ static inline void map_memory_bank(struct membank *bank)
204#ifdef CONFIG_MMU 198#ifdef CONFIG_MMU
205 struct map_desc map; 199 struct map_desc map;
206 200
207 map.pfn = __phys_to_pfn(bank->start); 201 map.pfn = bank_pfn_start(bank);
208 map.virtual = __phys_to_virt(bank->start); 202 map.virtual = __phys_to_virt(bank_phys_start(bank));
209 map.length = bank->size; 203 map.length = bank_phys_size(bank);
210 map.type = MT_MEMORY; 204 map.type = MT_MEMORY;
211 205
212 create_mapping(&map); 206 create_mapping(&map);
@@ -232,8 +226,8 @@ bootmem_init_node(int node, int initrd_node, struct meminfo *mi)
232 struct membank *bank = &mi->bank[i]; 226 struct membank *bank = &mi->bank[i];
233 unsigned long start, end; 227 unsigned long start, end;
234 228
235 start = bank->start >> PAGE_SHIFT; 229 start = bank_pfn_start(bank);
236 end = (bank->start + bank->size) >> PAGE_SHIFT; 230 end = bank_pfn_end(bank);
237 231
238 if (start_pfn > start) 232 if (start_pfn > start)
239 start_pfn = start; 233 start_pfn = start;
@@ -263,8 +257,10 @@ bootmem_init_node(int node, int initrd_node, struct meminfo *mi)
263 pgdat = NODE_DATA(node); 257 pgdat = NODE_DATA(node);
264 init_bootmem_node(pgdat, boot_pfn, start_pfn, end_pfn); 258 init_bootmem_node(pgdat, boot_pfn, start_pfn, end_pfn);
265 259
266 for_each_nodebank(i, mi, node) 260 for_each_nodebank(i, mi, node) {
267 free_bootmem_node(pgdat, mi->bank[i].start, mi->bank[i].size); 261 struct membank *bank = &mi->bank[i];
262 free_bootmem_node(pgdat, bank_phys_start(bank), bank_phys_size(bank));
263 }
268 264
269 /* 265 /*
270 * Reserve the bootmem bitmap for this node. 266 * Reserve the bootmem bitmap for this node.
@@ -317,7 +313,7 @@ bootmem_init_node(int node, int initrd_node, struct meminfo *mi)
317 */ 313 */
318 zhole_size[0] = zone_size[0]; 314 zhole_size[0] = zone_size[0];
319 for_each_nodebank(i, mi, node) 315 for_each_nodebank(i, mi, node)
320 zhole_size[0] -= mi->bank[i].size >> PAGE_SHIFT; 316 zhole_size[0] -= bank_pfn_size(&mi->bank[i]);
321 317
322 /* 318 /*
323 * Adjust the sizes according to any special requirements for 319 * Adjust the sizes according to any special requirements for
@@ -427,7 +423,9 @@ static void __init free_unused_memmap_node(int node, struct meminfo *mi)
427 * information on the command line. 423 * information on the command line.
428 */ 424 */
429 for_each_nodebank(i, mi, node) { 425 for_each_nodebank(i, mi, node) {
430 bank_start = mi->bank[i].start >> PAGE_SHIFT; 426 struct membank *bank = &mi->bank[i];
427
428 bank_start = bank_pfn_start(bank);
431 if (bank_start < prev_bank_end) { 429 if (bank_start < prev_bank_end) {
432 printk(KERN_ERR "MEM: unordered memory banks. " 430 printk(KERN_ERR "MEM: unordered memory banks. "
433 "Not freeing memmap.\n"); 431 "Not freeing memmap.\n");
@@ -441,8 +439,7 @@ static void __init free_unused_memmap_node(int node, struct meminfo *mi)
441 if (prev_bank_end && prev_bank_end != bank_start) 439 if (prev_bank_end && prev_bank_end != bank_start)
442 free_memmap(node, prev_bank_end, bank_start); 440 free_memmap(node, prev_bank_end, bank_start);
443 441
444 prev_bank_end = (mi->bank[i].start + 442 prev_bank_end = bank_pfn_end(bank);
445 mi->bank[i].size) >> PAGE_SHIFT;
446 } 443 }
447} 444}
448 445
@@ -487,8 +484,8 @@ void __init mem_init(void)
487 484
488 num_physpages = 0; 485 num_physpages = 0;
489 for (i = 0; i < meminfo.nr_banks; i++) { 486 for (i = 0; i < meminfo.nr_banks; i++) {
490 num_physpages += meminfo.bank[i].size >> PAGE_SHIFT; 487 num_physpages += bank_pfn_size(&meminfo.bank[i]);
491 printk(" %ldMB", meminfo.bank[i].size >> 20); 488 printk(" %ldMB", bank_phys_size(&meminfo.bank[i]) >> 20);
492 } 489 }
493 490
494 printk(" = %luMB total\n", num_physpages >> (20 - PAGE_SHIFT)); 491 printk(" = %luMB total\n", num_physpages >> (20 - PAGE_SHIFT));