diff options
author | Yinghai Lu <yinghai@kernel.org> | 2012-11-16 22:39:01 -0500 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2012-11-17 14:59:23 -0500 |
commit | 5c51bdbe4c74dce7996d0bbfa39974775cc3f13c (patch) | |
tree | 42c95d78f80b73307c4df17c80c03b2e701e7372 /arch/x86/mm/init.c | |
parent | 868bf4d6b94c980d3ad87f892a5e528b8ee2c320 (diff) |
x86, mm: Merge alloc_low_page between 64bit and 32bit
They are almost same except 64 bit need to handle after_bootmem case.
Add mm_internal.h to make that alloc_low_page() only to be accessible
from arch/x86/mm/init*.c
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Link: http://lkml.kernel.org/r/1353123563-3103-25-git-send-email-yinghai@kernel.org
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'arch/x86/mm/init.c')
-rw-r--r-- | arch/x86/mm/init.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c index 2393d0099e7f..848189229b2d 100644 --- a/arch/x86/mm/init.c +++ b/arch/x86/mm/init.c | |||
@@ -17,10 +17,44 @@ | |||
17 | #include <asm/proto.h> | 17 | #include <asm/proto.h> |
18 | #include <asm/dma.h> /* for MAX_DMA_PFN */ | 18 | #include <asm/dma.h> /* for MAX_DMA_PFN */ |
19 | 19 | ||
20 | #include "mm_internal.h" | ||
21 | |||
20 | unsigned long __initdata pgt_buf_start; | 22 | unsigned long __initdata pgt_buf_start; |
21 | unsigned long __meminitdata pgt_buf_end; | 23 | unsigned long __meminitdata pgt_buf_end; |
22 | unsigned long __meminitdata pgt_buf_top; | 24 | unsigned long __meminitdata pgt_buf_top; |
23 | 25 | ||
26 | __ref void *alloc_low_page(void) | ||
27 | { | ||
28 | unsigned long pfn; | ||
29 | void *adr; | ||
30 | |||
31 | #ifdef CONFIG_X86_64 | ||
32 | if (after_bootmem) { | ||
33 | adr = (void *)get_zeroed_page(GFP_ATOMIC | __GFP_NOTRACK); | ||
34 | |||
35 | return adr; | ||
36 | } | ||
37 | #endif | ||
38 | |||
39 | if ((pgt_buf_end + 1) >= pgt_buf_top) { | ||
40 | unsigned long ret; | ||
41 | if (min_pfn_mapped >= max_pfn_mapped) | ||
42 | panic("alloc_low_page: ran out of memory"); | ||
43 | ret = memblock_find_in_range(min_pfn_mapped << PAGE_SHIFT, | ||
44 | max_pfn_mapped << PAGE_SHIFT, | ||
45 | PAGE_SIZE, PAGE_SIZE); | ||
46 | if (!ret) | ||
47 | panic("alloc_low_page: can not alloc memory"); | ||
48 | memblock_reserve(ret, PAGE_SIZE); | ||
49 | pfn = ret >> PAGE_SHIFT; | ||
50 | } else | ||
51 | pfn = pgt_buf_end++; | ||
52 | |||
53 | adr = __va(pfn * PAGE_SIZE); | ||
54 | clear_page(adr); | ||
55 | return adr; | ||
56 | } | ||
57 | |||
24 | /* need 4 4k for initial PMD_SIZE, 4k for 0-ISA_END_ADDRESS */ | 58 | /* need 4 4k for initial PMD_SIZE, 4k for 0-ISA_END_ADDRESS */ |
25 | #define INIT_PGT_BUF_SIZE (5 * PAGE_SIZE) | 59 | #define INIT_PGT_BUF_SIZE (5 * PAGE_SIZE) |
26 | RESERVE_BRK(early_pgt_alloc, INIT_PGT_BUF_SIZE); | 60 | RESERVE_BRK(early_pgt_alloc, INIT_PGT_BUF_SIZE); |