diff options
author | Russell King <rmk@dyn-67.arm.linux.org.uk> | 2009-09-07 10:06:42 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2009-09-12 06:48:09 -0400 |
commit | b7cfda9fc3d7aa60cffab5367f2a72a4a70060cd (patch) | |
tree | a52c6cdbbc7973a4904ec499a607732832e4ca38 /arch/arm/mm/init.c | |
parent | 5eb38f44839ec1aade167b125d86d265c886c195 (diff) |
ARM: Fix pfn_valid() for sparse memory
On OMAP platforms, some people want to declare to segment up the memory
between the kernel and a separate application such that there is a hole
in the middle of the memory as far as Linux is concerned. However,
they want to be able to mmap() the hole.
This currently causes problems, because update_mmu_cache() thinks that
there are valid struct pages for the "hole". Fix this by making
pfn_valid() slightly more expensive, by checking whether the PFN is
contained within the meminfo array.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Tested-by: Khasim Syed Mohammed <khasim@ti.com>
Diffstat (limited to 'arch/arm/mm/init.c')
-rw-r--r-- | arch/arm/mm/init.c | 32 |
1 files changed, 32 insertions, 0 deletions
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 | */ |