diff options
Diffstat (limited to 'arch/arm')
-rw-r--r-- | arch/arm/include/asm/memory.h | 17 | ||||
-rw-r--r-- | arch/arm/include/asm/page.h | 4 | ||||
-rw-r--r-- | arch/arm/mm/init.c | 32 |
3 files changed, 36 insertions, 17 deletions
diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h index 85763db87449..b3b54c6216a4 100644 --- a/arch/arm/include/asm/memory.h +++ b/arch/arm/include/asm/memory.h | |||
@@ -212,7 +212,6 @@ static inline __deprecated void *bus_to_virt(unsigned long x) | |||
212 | * | 212 | * |
213 | * page_to_pfn(page) convert a struct page * to a PFN number | 213 | * page_to_pfn(page) convert a struct page * to a PFN number |
214 | * pfn_to_page(pfn) convert a _valid_ PFN number to struct page * | 214 | * pfn_to_page(pfn) convert a _valid_ PFN number to struct page * |
215 | * pfn_valid(pfn) indicates whether a PFN number is valid | ||
216 | * | 215 | * |
217 | * virt_to_page(k) convert a _valid_ virtual address to struct page * | 216 | * virt_to_page(k) convert a _valid_ virtual address to struct page * |
218 | * virt_addr_valid(k) indicates whether a virtual address is valid | 217 | * virt_addr_valid(k) indicates whether a virtual address is valid |
@@ -221,10 +220,6 @@ static inline __deprecated void *bus_to_virt(unsigned long x) | |||
221 | 220 | ||
222 | #define ARCH_PFN_OFFSET PHYS_PFN_OFFSET | 221 | #define ARCH_PFN_OFFSET PHYS_PFN_OFFSET |
223 | 222 | ||
224 | #ifndef CONFIG_SPARSEMEM | ||
225 | #define pfn_valid(pfn) ((pfn) >= PHYS_PFN_OFFSET && (pfn) < (PHYS_PFN_OFFSET + max_mapnr)) | ||
226 | #endif | ||
227 | |||
228 | #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT) | 223 | #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT) |
229 | #define virt_addr_valid(kaddr) ((unsigned long)(kaddr) >= PAGE_OFFSET && (unsigned long)(kaddr) < (unsigned long)high_memory) | 224 | #define virt_addr_valid(kaddr) ((unsigned long)(kaddr) >= PAGE_OFFSET && (unsigned long)(kaddr) < (unsigned long)high_memory) |
230 | 225 | ||
@@ -241,18 +236,6 @@ static inline __deprecated void *bus_to_virt(unsigned long x) | |||
241 | #define arch_pfn_to_nid(pfn) PFN_TO_NID(pfn) | 236 | #define arch_pfn_to_nid(pfn) PFN_TO_NID(pfn) |
242 | #define arch_local_page_offset(pfn, nid) LOCAL_MAP_NR((pfn) << PAGE_SHIFT) | 237 | #define arch_local_page_offset(pfn, nid) LOCAL_MAP_NR((pfn) << PAGE_SHIFT) |
243 | 238 | ||
244 | #define pfn_valid(pfn) \ | ||
245 | ({ \ | ||
246 | unsigned int nid = PFN_TO_NID(pfn); \ | ||
247 | int valid = nid < MAX_NUMNODES; \ | ||
248 | if (valid) { \ | ||
249 | pg_data_t *node = NODE_DATA(nid); \ | ||
250 | valid = (pfn - node->node_start_pfn) < \ | ||
251 | node->node_spanned_pages; \ | ||
252 | } \ | ||
253 | valid; \ | ||
254 | }) | ||
255 | |||
256 | #define virt_to_page(kaddr) \ | 239 | #define virt_to_page(kaddr) \ |
257 | (ADDR_TO_MAPBASE(kaddr) + LOCAL_MAP_NR(kaddr)) | 240 | (ADDR_TO_MAPBASE(kaddr) + LOCAL_MAP_NR(kaddr)) |
258 | 241 | ||
diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h index 9c746af1bf6e..3a32af4cce30 100644 --- a/arch/arm/include/asm/page.h +++ b/arch/arm/include/asm/page.h | |||
@@ -194,6 +194,10 @@ typedef unsigned long pgprot_t; | |||
194 | 194 | ||
195 | typedef struct page *pgtable_t; | 195 | typedef struct page *pgtable_t; |
196 | 196 | ||
197 | #ifndef CONFIG_SPARSEMEM | ||
198 | extern int pfn_valid(unsigned long); | ||
199 | #endif | ||
200 | |||
197 | #include <asm/memory.h> | 201 | #include <asm/memory.h> |
198 | 202 | ||
199 | #endif /* !__ASSEMBLY__ */ | 203 | #endif /* !__ASSEMBLY__ */ |
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 3a7279c1ce5e..ea36186f32c3 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/mman.h> | 15 | #include <linux/mman.h> |
16 | #include <linux/nodemask.h> | 16 | #include <linux/nodemask.h> |
17 | #include <linux/initrd.h> | 17 | #include <linux/initrd.h> |
18 | #include <linux/sort.h> | ||
18 | #include <linux/highmem.h> | 19 | #include <linux/highmem.h> |
19 | 20 | ||
20 | #include <asm/mach-types.h> | 21 | #include <asm/mach-types.h> |
@@ -349,12 +350,43 @@ static void __init bootmem_free_node(int node, struct meminfo *mi) | |||
349 | free_area_init_node(node, zone_size, min, zhole_size); | 350 | free_area_init_node(node, zone_size, min, zhole_size); |
350 | } | 351 | } |
351 | 352 | ||
353 | #ifndef CONFIG_SPARSEMEM | ||
354 | int pfn_valid(unsigned long pfn) | ||
355 | { | ||
356 | struct meminfo *mi = &meminfo; | ||
357 | unsigned int left = 0, right = mi->nr_banks; | ||
358 | |||
359 | do { | ||
360 | unsigned int mid = (right + left) / 2; | ||
361 | struct membank *bank = &mi->bank[mid]; | ||
362 | |||
363 | if (pfn < bank_pfn_start(bank)) | ||
364 | right = mid; | ||
365 | else if (pfn >= bank_pfn_end(bank)) | ||
366 | left = mid + 1; | ||
367 | else | ||
368 | return 1; | ||
369 | } while (left < right); | ||
370 | return 0; | ||
371 | } | ||
372 | EXPORT_SYMBOL(pfn_valid); | ||
373 | #endif | ||
374 | |||
375 | static int __init meminfo_cmp(const void *_a, const void *_b) | ||
376 | { | ||
377 | const struct membank *a = _a, *b = _b; | ||
378 | long cmp = bank_pfn_start(a) - bank_pfn_start(b); | ||
379 | return cmp < 0 ? -1 : cmp > 0 ? 1 : 0; | ||
380 | } | ||
381 | |||
352 | void __init bootmem_init(void) | 382 | void __init bootmem_init(void) |
353 | { | 383 | { |
354 | struct meminfo *mi = &meminfo; | 384 | struct meminfo *mi = &meminfo; |
355 | unsigned long min, max_low, max_high; | 385 | unsigned long min, max_low, max_high; |
356 | int node, initrd_node; | 386 | int node, initrd_node; |
357 | 387 | ||
388 | sort(&mi->bank, mi->nr_banks, sizeof(mi->bank[0]), meminfo_cmp, NULL); | ||
389 | |||
358 | /* | 390 | /* |
359 | * Locate which node contains the ramdisk image, if any. | 391 | * Locate which node contains the ramdisk image, if any. |
360 | */ | 392 | */ |