aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/Kconfig1
-rw-r--r--arch/arm/include/asm/bitops.h54
-rw-r--r--arch/arm/kernel/setup.c2
-rw-r--r--arch/arm/mm/init.c62
4 files changed, 50 insertions, 69 deletions
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index f219c30eb4e1..c2dbf1416b94 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -64,6 +64,7 @@ config ARM
64 select IRQ_FORCED_THREADING 64 select IRQ_FORCED_THREADING
65 select KTIME_SCALAR 65 select KTIME_SCALAR
66 select MODULES_USE_ELF_REL 66 select MODULES_USE_ELF_REL
67 select NO_BOOTMEM
67 select OLD_SIGACTION 68 select OLD_SIGACTION
68 select OLD_SIGSUSPEND3 69 select OLD_SIGSUSPEND3
69 select PERF_USE_VMALLOC 70 select PERF_USE_VMALLOC
diff --git a/arch/arm/include/asm/bitops.h b/arch/arm/include/asm/bitops.h
index e691ec91e4d3..b2e298a90d76 100644
--- a/arch/arm/include/asm/bitops.h
+++ b/arch/arm/include/asm/bitops.h
@@ -254,25 +254,59 @@ static inline int constant_fls(int x)
254} 254}
255 255
256/* 256/*
257 * On ARMv5 and above those functions can be implemented around 257 * On ARMv5 and above those functions can be implemented around the
258 * the clz instruction for much better code efficiency. 258 * clz instruction for much better code efficiency. __clz returns
259 * the number of leading zeros, zero input will return 32, and
260 * 0x80000000 will return 0.
259 */ 261 */
262static inline unsigned int __clz(unsigned int x)
263{
264 unsigned int ret;
265
266 asm("clz\t%0, %1" : "=r" (ret) : "r" (x));
260 267
268 return ret;
269}
270
271/*
272 * fls() returns zero if the input is zero, otherwise returns the bit
273 * position of the last set bit, where the LSB is 1 and MSB is 32.
274 */
261static inline int fls(int x) 275static inline int fls(int x)
262{ 276{
263 int ret;
264
265 if (__builtin_constant_p(x)) 277 if (__builtin_constant_p(x))
266 return constant_fls(x); 278 return constant_fls(x);
267 279
268 asm("clz\t%0, %1" : "=r" (ret) : "r" (x)); 280 return 32 - __clz(x);
269 ret = 32 - ret; 281}
270 return ret; 282
283/*
284 * __fls() returns the bit position of the last bit set, where the
285 * LSB is 0 and MSB is 31. Zero input is undefined.
286 */
287static inline unsigned long __fls(unsigned long x)
288{
289 return fls(x) - 1;
290}
291
292/*
293 * ffs() returns zero if the input was zero, otherwise returns the bit
294 * position of the first set bit, where the LSB is 1 and MSB is 32.
295 */
296static inline int ffs(int x)
297{
298 return fls(x & -x);
299}
300
301/*
302 * __ffs() returns the bit position of the first bit set, where the
303 * LSB is 0 and MSB is 31. Zero input is undefined.
304 */
305static inline unsigned long __ffs(unsigned long x)
306{
307 return ffs(x) - 1;
271} 308}
272 309
273#define __fls(x) (fls(x) - 1)
274#define ffs(x) ({ unsigned long __t = (x); fls(__t & -__t); })
275#define __ffs(x) (ffs(x) - 1)
276#define ffz(x) __ffs( ~(x) ) 310#define ffz(x) __ffs( ~(x) )
277 311
278#endif 312#endif
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 061cea820e3f..a4729c6be25d 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -831,7 +831,7 @@ static void __init reserve_crashkernel(void)
831 if (ret) 831 if (ret)
832 return; 832 return;
833 833
834 ret = reserve_bootmem(crash_base, crash_size, BOOTMEM_EXCLUSIVE); 834 ret = memblock_reserve(crash_base, crash_size);
835 if (ret < 0) { 835 if (ret < 0) {
836 pr_warn("crashkernel reservation failed - memory is in use (0x%lx)\n", 836 pr_warn("crashkernel reservation failed - memory is in use (0x%lx)\n",
837 (unsigned long)crash_base); 837 (unsigned long)crash_base);
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 3e8f106ee5fe..6dd66a999d9f 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -145,58 +145,6 @@ static void __init find_limits(unsigned long *min, unsigned long *max_low,
145 *max_high = bank_pfn_end(&mi->bank[mi->nr_banks - 1]); 145 *max_high = bank_pfn_end(&mi->bank[mi->nr_banks - 1]);
146} 146}
147 147
148static void __init arm_bootmem_init(unsigned long start_pfn,
149 unsigned long end_pfn)
150{
151 struct memblock_region *reg;
152 unsigned int boot_pages;
153 phys_addr_t bitmap;
154 pg_data_t *pgdat;
155
156 /*
157 * Allocate the bootmem bitmap page. This must be in a region
158 * of memory which has already been mapped.
159 */
160 boot_pages = bootmem_bootmap_pages(end_pfn - start_pfn);
161 bitmap = memblock_alloc_base(boot_pages << PAGE_SHIFT, L1_CACHE_BYTES,
162 __pfn_to_phys(end_pfn));
163
164 /*
165 * Initialise the bootmem allocator, handing the
166 * memory banks over to bootmem.
167 */
168 node_set_online(0);
169 pgdat = NODE_DATA(0);
170 init_bootmem_node(pgdat, __phys_to_pfn(bitmap), start_pfn, end_pfn);
171
172 /* Free the lowmem regions from memblock into bootmem. */
173 for_each_memblock(memory, reg) {
174 unsigned long start = memblock_region_memory_base_pfn(reg);
175 unsigned long end = memblock_region_memory_end_pfn(reg);
176
177 if (end >= end_pfn)
178 end = end_pfn;
179 if (start >= end)
180 break;
181
182 free_bootmem(__pfn_to_phys(start), (end - start) << PAGE_SHIFT);
183 }
184
185 /* Reserve the lowmem memblock reserved regions in bootmem. */
186 for_each_memblock(reserved, reg) {
187 unsigned long start = memblock_region_reserved_base_pfn(reg);
188 unsigned long end = memblock_region_reserved_end_pfn(reg);
189
190 if (end >= end_pfn)
191 end = end_pfn;
192 if (start >= end)
193 break;
194
195 reserve_bootmem(__pfn_to_phys(start),
196 (end - start) << PAGE_SHIFT, BOOTMEM_DEFAULT);
197 }
198}
199
200#ifdef CONFIG_ZONE_DMA 148#ifdef CONFIG_ZONE_DMA
201 149
202phys_addr_t arm_dma_zone_size __read_mostly; 150phys_addr_t arm_dma_zone_size __read_mostly;
@@ -236,7 +184,7 @@ void __init setup_dma_zone(const struct machine_desc *mdesc)
236#endif 184#endif
237} 185}
238 186
239static void __init arm_bootmem_free(unsigned long min, unsigned long max_low, 187static void __init zone_sizes_init(unsigned long min, unsigned long max_low,
240 unsigned long max_high) 188 unsigned long max_high)
241{ 189{
242 unsigned long zone_size[MAX_NR_ZONES], zhole_size[MAX_NR_ZONES]; 190 unsigned long zone_size[MAX_NR_ZONES], zhole_size[MAX_NR_ZONES];
@@ -384,7 +332,6 @@ void __init arm_memblock_init(struct meminfo *mi,
384 dma_contiguous_reserve(min(arm_dma_limit, arm_lowmem_limit)); 332 dma_contiguous_reserve(min(arm_dma_limit, arm_lowmem_limit));
385 333
386 arm_memblock_steal_permitted = false; 334 arm_memblock_steal_permitted = false;
387 memblock_allow_resize();
388 memblock_dump_all(); 335 memblock_dump_all();
389} 336}
390 337
@@ -392,12 +339,11 @@ void __init bootmem_init(void)
392{ 339{
393 unsigned long min, max_low, max_high; 340 unsigned long min, max_low, max_high;
394 341
342 memblock_allow_resize();
395 max_low = max_high = 0; 343 max_low = max_high = 0;
396 344
397 find_limits(&min, &max_low, &max_high); 345 find_limits(&min, &max_low, &max_high);
398 346
399 arm_bootmem_init(min, max_low);
400
401 /* 347 /*
402 * Sparsemem tries to allocate bootmem in memory_present(), 348 * Sparsemem tries to allocate bootmem in memory_present(),
403 * so must be done after the fixed reservations 349 * so must be done after the fixed reservations
@@ -414,7 +360,7 @@ void __init bootmem_init(void)
414 * the sparse mem_map arrays initialized by sparse_init() 360 * the sparse mem_map arrays initialized by sparse_init()
415 * for memmap_init_zone(), otherwise all PFNs are invalid. 361 * for memmap_init_zone(), otherwise all PFNs are invalid.
416 */ 362 */
417 arm_bootmem_free(min, max_low, max_high); 363 zone_sizes_init(min, max_low, max_high);
418 364
419 /* 365 /*
420 * This doesn't seem to be used by the Linux memory manager any 366 * This doesn't seem to be used by the Linux memory manager any
@@ -587,7 +533,7 @@ void __init mem_init(void)
587 extern u32 itcm_end; 533 extern u32 itcm_end;
588#endif 534#endif
589 535
590 max_mapnr = pfn_to_page(max_pfn + PHYS_PFN_OFFSET) - mem_map; 536 set_max_mapnr(pfn_to_page(max_pfn) - mem_map);
591 537
592 /* this will put all unused low memory onto the freelists */ 538 /* this will put all unused low memory onto the freelists */
593 free_unused_memmap(&meminfo); 539 free_unused_memmap(&meminfo);