diff options
| author | Yinghai Lu <yinghai@kernel.org> | 2010-08-25 16:39:18 -0400 | 
|---|---|---|
| committer | H. Peter Anvin <hpa@zytor.com> | 2010-08-27 14:13:54 -0400 | 
| commit | 6f2a75369e7561e800d86927ecd83c970996b21f (patch) | |
| tree | 558e90d291a6dfc17cd950805bf5f56cb2b690e1 | |
| parent | a587d2daebcd2bc159d4348b6a7b028950a6d803 (diff) | |
x86, memblock: Use memblock_memory_size()/memblock_free_memory_size() to get correct dma_reserve
memblock_memory_size() will return memory size in memblock.memory.region.
memblock_free_memory_size() will return free memory size in memblock.memory.region.
So We can get exact reseved size in specified range.
Set the size right after initmem_init(), because later bootmem API will
get area above 16M. (except some fallback).
Later after we remove the bootmem, We could call that just before paging_init().
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
| -rw-r--r-- | arch/x86/include/asm/e820.h | 2 | ||||
| -rw-r--r-- | arch/x86/kernel/e820.c | 16 | ||||
| -rw-r--r-- | arch/x86/kernel/setup.c | 1 | ||||
| -rw-r--r-- | arch/x86/mm/init_64.c | 7 | 
4 files changed, 19 insertions, 7 deletions
| diff --git a/arch/x86/include/asm/e820.h b/arch/x86/include/asm/e820.h index 718646384e03..5be1542fbfaf 100644 --- a/arch/x86/include/asm/e820.h +++ b/arch/x86/include/asm/e820.h | |||
| @@ -117,6 +117,8 @@ extern unsigned long e820_end_of_low_ram_pfn(void); | |||
| 117 | extern u64 early_reserve_e820(u64 startt, u64 sizet, u64 align); | 117 | extern u64 early_reserve_e820(u64 startt, u64 sizet, u64 align); | 
| 118 | 118 | ||
| 119 | void memblock_x86_fill(void); | 119 | void memblock_x86_fill(void); | 
| 120 | void memblock_find_dma_reserve(void); | ||
| 121 | |||
| 120 | extern void finish_e820_parsing(void); | 122 | extern void finish_e820_parsing(void); | 
| 121 | extern void e820_reserve_resources(void); | 123 | extern void e820_reserve_resources(void); | 
| 122 | extern void e820_reserve_resources_late(void); | 124 | extern void e820_reserve_resources_late(void); | 
| diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index d5fd89462d79..0c2b7ef7a34d 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c | |||
| @@ -1105,3 +1105,19 @@ void __init memblock_x86_fill(void) | |||
| 1105 | memblock_analyze(); | 1105 | memblock_analyze(); | 
| 1106 | memblock_dump_all(); | 1106 | memblock_dump_all(); | 
| 1107 | } | 1107 | } | 
| 1108 | |||
| 1109 | void __init memblock_find_dma_reserve(void) | ||
| 1110 | { | ||
| 1111 | #ifdef CONFIG_X86_64 | ||
| 1112 | u64 free_size_pfn; | ||
| 1113 | u64 mem_size_pfn; | ||
| 1114 | /* | ||
| 1115 | * need to find out used area below MAX_DMA_PFN | ||
| 1116 | * need to use memblock to get free size in [0, MAX_DMA_PFN] | ||
| 1117 | * at first, and assume boot_mem will not take below MAX_DMA_PFN | ||
| 1118 | */ | ||
| 1119 | mem_size_pfn = memblock_x86_memory_in_range(0, MAX_DMA_PFN << PAGE_SHIFT) >> PAGE_SHIFT; | ||
| 1120 | free_size_pfn = memblock_x86_free_memory_in_range(0, MAX_DMA_PFN << PAGE_SHIFT) >> PAGE_SHIFT; | ||
| 1121 | set_dma_reserve(mem_size_pfn - free_size_pfn); | ||
| 1122 | #endif | ||
| 1123 | } | ||
| diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index a4f01733e879..924c8f78e98e 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c | |||
| @@ -1013,6 +1013,7 @@ void __init setup_arch(char **cmdline_p) | |||
| 1013 | #endif | 1013 | #endif | 
| 1014 | 1014 | ||
| 1015 | initmem_init(0, max_pfn, acpi, k8); | 1015 | initmem_init(0, max_pfn, acpi, k8); | 
| 1016 | memblock_find_dma_reserve(); | ||
| 1016 | #ifndef CONFIG_NO_BOOTMEM | 1017 | #ifndef CONFIG_NO_BOOTMEM | 
| 1017 | memblock_x86_to_bootmem(0, max_low_pfn<<PAGE_SHIFT); | 1018 | memblock_x86_to_bootmem(0, max_low_pfn<<PAGE_SHIFT); | 
| 1018 | #endif | 1019 | #endif | 
| diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index 592b2368062d..d6d408467c46 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c | |||
| @@ -53,8 +53,6 @@ | |||
| 53 | #include <asm/init.h> | 53 | #include <asm/init.h> | 
| 54 | #include <linux/bootmem.h> | 54 | #include <linux/bootmem.h> | 
| 55 | 55 | ||
| 56 | static unsigned long dma_reserve __initdata; | ||
| 57 | |||
| 58 | static int __init parse_direct_gbpages_off(char *arg) | 56 | static int __init parse_direct_gbpages_off(char *arg) | 
| 59 | { | 57 | { | 
| 60 | direct_gbpages = 0; | 58 | direct_gbpages = 0; | 
| @@ -821,11 +819,6 @@ int __init reserve_bootmem_generic(unsigned long phys, unsigned long len, | |||
| 821 | 819 | ||
| 822 | reserve_bootmem(phys, len, flags); | 820 | reserve_bootmem(phys, len, flags); | 
| 823 | 821 | ||
| 824 | if (phys+len <= MAX_DMA_PFN*PAGE_SIZE) { | ||
| 825 | dma_reserve += len / PAGE_SIZE; | ||
| 826 | set_dma_reserve(dma_reserve); | ||
| 827 | } | ||
| 828 | |||
| 829 | return 0; | 822 | return 0; | 
| 830 | } | 823 | } | 
| 831 | #endif | 824 | #endif | 
