Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

parisc: use memblock_alloc() instead of custom get_memblock()

The get_memblock() function implements custom bottom-up memblock allocator.
Setting 'memblock_bottom_up = true' before any memblock allocation is done
allows replacing get_memblock() calls with memblock_alloc().

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
Tested-by: Helge Deller <deller@gmx.de>
Signed-off-by: Helge Deller <deller@gmx.de>

authored by

Mike Rapoport and committed by
Helge Deller
6a528001 c11ef0a8

+19 -33
+19 -33
arch/parisc/mm/init.c
··· 79 79 physmem_range_t pmem_ranges[MAX_PHYSMEM_RANGES] __read_mostly; 80 80 int npmem_ranges __read_mostly; 81 81 82 - /* 83 - * get_memblock() allocates pages via memblock. 84 - * We can't use memblock_find_in_range(0, KERNEL_INITIAL_SIZE) here since it 85 - * doesn't allocate from bottom to top which is needed because we only created 86 - * the initial mapping up to KERNEL_INITIAL_SIZE in the assembly bootup code. 87 - */ 88 - static void * __init get_memblock(unsigned long size) 89 - { 90 - static phys_addr_t search_addr __initdata; 91 - phys_addr_t phys; 92 - 93 - if (!search_addr) 94 - search_addr = PAGE_ALIGN(__pa((unsigned long) &_end)); 95 - search_addr = ALIGN(search_addr, size); 96 - while (!memblock_is_region_memory(search_addr, size) || 97 - memblock_is_region_reserved(search_addr, size)) { 98 - search_addr += size; 99 - } 100 - phys = search_addr; 101 - 102 - if (phys) 103 - memblock_reserve(phys, size); 104 - else 105 - panic("get_memblock() failed.\n"); 106 - 107 - memset(__va(phys), 0, size); 108 - 109 - return __va(phys); 110 - } 111 - 112 82 #ifdef CONFIG_64BIT 113 83 #define MAX_MEM (~0UL) 114 84 #else /* !CONFIG_64BIT */ ··· 291 321 max_pfn = start_pfn + npages; 292 322 } 293 323 324 + /* 325 + * We can't use memblock top-down allocations because we only 326 + * created the initial mapping up to KERNEL_INITIAL_SIZE in 327 + * the assembly bootup code. 328 + */ 329 + memblock_set_bottom_up(true); 330 + 294 331 /* IOMMU is always used to access "high mem" on those boxes 295 332 * that can support enough mem that a PCI device couldn't 296 333 * directly DMA to any physical addresses. ··· 419 442 */ 420 443 421 444 if (!pmd) { 422 - pmd = (pmd_t *) get_memblock(PAGE_SIZE << PMD_ORDER); 445 + pmd = memblock_alloc(PAGE_SIZE << PMD_ORDER, 446 + PAGE_SIZE << PMD_ORDER); 447 + if (!pmd) 448 + panic("pmd allocation failed.\n"); 423 449 pmd = (pmd_t *) __pa(pmd); 424 450 } 425 451 ··· 441 461 442 462 pg_table = (pte_t *)pmd_address(*pmd); 443 463 if (!pg_table) { 444 - pg_table = (pte_t *) get_memblock(PAGE_SIZE); 464 + pg_table = memblock_alloc(PAGE_SIZE, 465 + PAGE_SIZE); 466 + if (!pg_table) 467 + panic("page table allocation failed\n"); 445 468 pg_table = (pte_t *) __pa(pg_table); 446 469 } 447 470 ··· 683 700 } 684 701 #endif 685 702 686 - empty_zero_page = get_memblock(PAGE_SIZE); 703 + empty_zero_page = memblock_alloc(PAGE_SIZE, PAGE_SIZE); 704 + if (!empty_zero_page) 705 + panic("zero page allocation failed.\n"); 706 + 687 707 } 688 708 689 709 static void __init gateway_init(void)