diff options
author | Jiang Liu <liuj97@gmail.com> | 2013-07-03 18:04:02 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-07-03 19:07:36 -0400 |
commit | 6879ea83c6d14e4f21bf48b5780ed549197c668b (patch) | |
tree | 0f2763bdb63efcd9185e3a08495ffa7dd33b906e /arch/microblaze | |
parent | 132de6717c47f6fb1d4d3ccd6033cd45aee8f779 (diff) |
mm/microblaze: prepare for removing num_physpages and simplify mem_init()
Prepare for removing num_physpages and simplify mem_init().
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: Michal Simek <monstr@monstr.eu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/microblaze')
-rw-r--r-- | arch/microblaze/mm/init.c | 51 |
1 files changed, 6 insertions, 45 deletions
diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c index b384cbc2c8f2..74c7bcc1e82d 100644 --- a/arch/microblaze/mm/init.c +++ b/arch/microblaze/mm/init.c | |||
@@ -71,24 +71,17 @@ static void __init highmem_init(void) | |||
71 | kmap_prot = PAGE_KERNEL; | 71 | kmap_prot = PAGE_KERNEL; |
72 | } | 72 | } |
73 | 73 | ||
74 | static unsigned long highmem_setup(void) | 74 | static void highmem_setup(void) |
75 | { | 75 | { |
76 | unsigned long pfn; | 76 | unsigned long pfn; |
77 | unsigned long reservedpages = 0; | ||
78 | 77 | ||
79 | for (pfn = max_low_pfn; pfn < max_pfn; ++pfn) { | 78 | for (pfn = max_low_pfn; pfn < max_pfn; ++pfn) { |
80 | struct page *page = pfn_to_page(pfn); | 79 | struct page *page = pfn_to_page(pfn); |
81 | 80 | ||
82 | /* FIXME not sure about */ | 81 | /* FIXME not sure about */ |
83 | if (memblock_is_reserved(pfn << PAGE_SHIFT)) | 82 | if (!memblock_is_reserved(pfn << PAGE_SHIFT)) |
84 | continue; | 83 | free_highmem_page(page); |
85 | free_highmem_page(page); | ||
86 | reservedpages++; | ||
87 | } | 84 | } |
88 | pr_info("High memory: %luk\n", | ||
89 | totalhigh_pages << (PAGE_SHIFT-10)); | ||
90 | |||
91 | return reservedpages; | ||
92 | } | 85 | } |
93 | #endif /* CONFIG_HIGHMEM */ | 86 | #endif /* CONFIG_HIGHMEM */ |
94 | 87 | ||
@@ -167,13 +160,12 @@ void __init setup_memory(void) | |||
167 | * min_low_pfn - the first page (mm/bootmem.c - node_boot_start) | 160 | * min_low_pfn - the first page (mm/bootmem.c - node_boot_start) |
168 | * max_low_pfn | 161 | * max_low_pfn |
169 | * max_mapnr - the first unused page (mm/bootmem.c - node_low_pfn) | 162 | * max_mapnr - the first unused page (mm/bootmem.c - node_low_pfn) |
170 | * num_physpages - number of all pages | ||
171 | */ | 163 | */ |
172 | 164 | ||
173 | /* memory start is from the kernel end (aligned) to higher addr */ | 165 | /* memory start is from the kernel end (aligned) to higher addr */ |
174 | min_low_pfn = memory_start >> PAGE_SHIFT; /* minimum for allocation */ | 166 | min_low_pfn = memory_start >> PAGE_SHIFT; /* minimum for allocation */ |
175 | /* RAM is assumed contiguous */ | 167 | /* RAM is assumed contiguous */ |
176 | num_physpages = max_mapnr = memory_size >> PAGE_SHIFT; | 168 | max_mapnr = memory_size >> PAGE_SHIFT; |
177 | max_low_pfn = ((u64)memory_start + (u64)lowmem_size) >> PAGE_SHIFT; | 169 | max_low_pfn = ((u64)memory_start + (u64)lowmem_size) >> PAGE_SHIFT; |
178 | max_pfn = ((u64)memory_start + (u64)memory_size) >> PAGE_SHIFT; | 170 | max_pfn = ((u64)memory_start + (u64)memory_size) >> PAGE_SHIFT; |
179 | 171 | ||
@@ -246,46 +238,15 @@ void free_initmem(void) | |||
246 | 238 | ||
247 | void __init mem_init(void) | 239 | void __init mem_init(void) |
248 | { | 240 | { |
249 | pg_data_t *pgdat; | ||
250 | unsigned long reservedpages = 0, codesize, initsize, datasize, bsssize; | ||
251 | |||
252 | high_memory = (void *)__va(memory_start + lowmem_size - 1); | 241 | high_memory = (void *)__va(memory_start + lowmem_size - 1); |
253 | 242 | ||
254 | /* this will put all memory onto the freelists */ | 243 | /* this will put all memory onto the freelists */ |
255 | free_all_bootmem(); | 244 | free_all_bootmem(); |
256 | |||
257 | for_each_online_pgdat(pgdat) { | ||
258 | unsigned long i; | ||
259 | struct page *page; | ||
260 | |||
261 | for (i = 0; i < pgdat->node_spanned_pages; i++) { | ||
262 | if (!pfn_valid(pgdat->node_start_pfn + i)) | ||
263 | continue; | ||
264 | page = pgdat_page_nr(pgdat, i); | ||
265 | if (PageReserved(page)) | ||
266 | reservedpages++; | ||
267 | } | ||
268 | } | ||
269 | |||
270 | #ifdef CONFIG_HIGHMEM | 245 | #ifdef CONFIG_HIGHMEM |
271 | reservedpages -= highmem_setup(); | 246 | highmem_setup(); |
272 | #endif | 247 | #endif |
273 | 248 | ||
274 | codesize = (unsigned long)&_sdata - (unsigned long)&_stext; | 249 | mem_init_print_info(NULL); |
275 | datasize = (unsigned long)&_edata - (unsigned long)&_sdata; | ||
276 | initsize = (unsigned long)&__init_end - (unsigned long)&__init_begin; | ||
277 | bsssize = (unsigned long)&__bss_stop - (unsigned long)&__bss_start; | ||
278 | |||
279 | pr_info("Memory: %luk/%luk available (%luk kernel code, ", | ||
280 | nr_free_pages() << (PAGE_SHIFT-10), | ||
281 | num_physpages << (PAGE_SHIFT-10), | ||
282 | codesize >> 10); | ||
283 | pr_cont("%luk reserved, %luk data, %luk bss, %luk init)\n", | ||
284 | reservedpages << (PAGE_SHIFT-10), | ||
285 | datasize >> 10, | ||
286 | bsssize >> 10, | ||
287 | initsize >> 10); | ||
288 | |||
289 | #ifdef CONFIG_MMU | 250 | #ifdef CONFIG_MMU |
290 | pr_info("Kernel virtual memory layout:\n"); | 251 | pr_info("Kernel virtual memory layout:\n"); |
291 | pr_info(" * 0x%08lx..0x%08lx : fixmap\n", FIXADDR_START, FIXADDR_TOP); | 252 | pr_info(" * 0x%08lx..0x%08lx : fixmap\n", FIXADDR_START, FIXADDR_TOP); |