diff options
| author | Yinghai Lu <yinghai@kernel.org> | 2014-01-27 20:06:49 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-01-28 00:02:38 -0500 |
| commit | ad6492b80f60a2139fa9bf8fd79b182fe5e3647c (patch) | |
| tree | f52530fb2240679a0f88ba5047a3bedc6dacf796 | |
| parent | ba635f8cd20ebc7bddf1eb8e1f4eae28a034e916 (diff) | |
memblock, nobootmem: add memblock_virt_alloc_low()
The new memblock_virt APIs are used to replaced old bootmem API.
We need to allocate page below 4G for swiotlb.
That should fix regression on Andrew's system that is using swiotlb.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
| -rw-r--r-- | arch/arm/kernel/setup.c | 2 | ||||
| -rw-r--r-- | include/linux/bootmem.h | 37 | ||||
| -rw-r--r-- | lib/swiotlb.c | 4 |
3 files changed, 40 insertions, 3 deletions
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index 1e8b030dbefd..b0df9761de6d 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c | |||
| @@ -731,7 +731,7 @@ static void __init request_standard_resources(const struct machine_desc *mdesc) | |||
| 731 | kernel_data.end = virt_to_phys(_end - 1); | 731 | kernel_data.end = virt_to_phys(_end - 1); |
| 732 | 732 | ||
| 733 | for_each_memblock(memory, region) { | 733 | for_each_memblock(memory, region) { |
| 734 | res = memblock_virt_alloc(sizeof(*res), 0); | 734 | res = memblock_virt_alloc_low(sizeof(*res), 0); |
| 735 | res->name = "System RAM"; | 735 | res->name = "System RAM"; |
| 736 | res->start = __pfn_to_phys(memblock_region_memory_base_pfn(region)); | 736 | res->start = __pfn_to_phys(memblock_region_memory_base_pfn(region)); |
| 737 | res->end = __pfn_to_phys(memblock_region_memory_end_pfn(region)) - 1; | 737 | res->end = __pfn_to_phys(memblock_region_memory_end_pfn(region)) - 1; |
diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h index 2fae55def608..b388223bd4a9 100644 --- a/include/linux/bootmem.h +++ b/include/linux/bootmem.h | |||
| @@ -175,6 +175,27 @@ static inline void * __init memblock_virt_alloc_nopanic( | |||
| 175 | NUMA_NO_NODE); | 175 | NUMA_NO_NODE); |
| 176 | } | 176 | } |
| 177 | 177 | ||
| 178 | #ifndef ARCH_LOW_ADDRESS_LIMIT | ||
| 179 | #define ARCH_LOW_ADDRESS_LIMIT 0xffffffffUL | ||
| 180 | #endif | ||
| 181 | |||
| 182 | static inline void * __init memblock_virt_alloc_low( | ||
| 183 | phys_addr_t size, phys_addr_t align) | ||
| 184 | { | ||
| 185 | return memblock_virt_alloc_try_nid(size, align, | ||
| 186 | BOOTMEM_LOW_LIMIT, | ||
| 187 | ARCH_LOW_ADDRESS_LIMIT, | ||
| 188 | NUMA_NO_NODE); | ||
| 189 | } | ||
| 190 | static inline void * __init memblock_virt_alloc_low_nopanic( | ||
| 191 | phys_addr_t size, phys_addr_t align) | ||
| 192 | { | ||
| 193 | return memblock_virt_alloc_try_nid_nopanic(size, align, | ||
| 194 | BOOTMEM_LOW_LIMIT, | ||
| 195 | ARCH_LOW_ADDRESS_LIMIT, | ||
| 196 | NUMA_NO_NODE); | ||
| 197 | } | ||
| 198 | |||
| 178 | static inline void * __init memblock_virt_alloc_from_nopanic( | 199 | static inline void * __init memblock_virt_alloc_from_nopanic( |
| 179 | phys_addr_t size, phys_addr_t align, phys_addr_t min_addr) | 200 | phys_addr_t size, phys_addr_t align, phys_addr_t min_addr) |
| 180 | { | 201 | { |
| @@ -238,6 +259,22 @@ static inline void * __init memblock_virt_alloc_nopanic( | |||
| 238 | return __alloc_bootmem_nopanic(size, align, BOOTMEM_LOW_LIMIT); | 259 | return __alloc_bootmem_nopanic(size, align, BOOTMEM_LOW_LIMIT); |
| 239 | } | 260 | } |
| 240 | 261 | ||
| 262 | static inline void * __init memblock_virt_alloc_low( | ||
| 263 | phys_addr_t size, phys_addr_t align) | ||
| 264 | { | ||
| 265 | if (!align) | ||
| 266 | align = SMP_CACHE_BYTES; | ||
| 267 | return __alloc_bootmem_low(size, align, BOOTMEM_LOW_LIMIT); | ||
| 268 | } | ||
| 269 | |||
| 270 | static inline void * __init memblock_virt_alloc_low_nopanic( | ||
| 271 | phys_addr_t size, phys_addr_t align) | ||
| 272 | { | ||
| 273 | if (!align) | ||
| 274 | align = SMP_CACHE_BYTES; | ||
| 275 | return __alloc_bootmem_low_nopanic(size, align, BOOTMEM_LOW_LIMIT); | ||
| 276 | } | ||
| 277 | |||
| 241 | static inline void * __init memblock_virt_alloc_from_nopanic( | 278 | static inline void * __init memblock_virt_alloc_from_nopanic( |
| 242 | phys_addr_t size, phys_addr_t align, phys_addr_t min_addr) | 279 | phys_addr_t size, phys_addr_t align, phys_addr_t min_addr) |
| 243 | { | 280 | { |
diff --git a/lib/swiotlb.c b/lib/swiotlb.c index 2e1c102759ce..b604b831f4d1 100644 --- a/lib/swiotlb.c +++ b/lib/swiotlb.c | |||
| @@ -172,7 +172,7 @@ int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose) | |||
| 172 | /* | 172 | /* |
| 173 | * Get the overflow emergency buffer | 173 | * Get the overflow emergency buffer |
| 174 | */ | 174 | */ |
| 175 | v_overflow_buffer = memblock_virt_alloc_nopanic( | 175 | v_overflow_buffer = memblock_virt_alloc_low_nopanic( |
| 176 | PAGE_ALIGN(io_tlb_overflow), | 176 | PAGE_ALIGN(io_tlb_overflow), |
| 177 | PAGE_SIZE); | 177 | PAGE_SIZE); |
| 178 | if (!v_overflow_buffer) | 178 | if (!v_overflow_buffer) |
| @@ -220,7 +220,7 @@ swiotlb_init(int verbose) | |||
| 220 | bytes = io_tlb_nslabs << IO_TLB_SHIFT; | 220 | bytes = io_tlb_nslabs << IO_TLB_SHIFT; |
| 221 | 221 | ||
| 222 | /* Get IO TLB memory from the low pages */ | 222 | /* Get IO TLB memory from the low pages */ |
| 223 | vstart = memblock_virt_alloc_nopanic(PAGE_ALIGN(bytes), PAGE_SIZE); | 223 | vstart = memblock_virt_alloc_low_nopanic(PAGE_ALIGN(bytes), PAGE_SIZE); |
| 224 | if (vstart && !swiotlb_init_with_tbl(vstart, io_tlb_nslabs, verbose)) | 224 | if (vstart && !swiotlb_init_with_tbl(vstart, io_tlb_nslabs, verbose)) |
| 225 | return; | 225 | return; |
| 226 | 226 | ||
