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/include | |
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/include')
-rw-r--r-- | arch/arm/include/asm/memory.h | 17 | ||||
-rw-r--r-- | arch/arm/include/asm/page.h | 4 |
2 files changed, 4 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__ */ |