Skip to content

Commit 6a52800

Browse files
rppthdeller
authored andcommitted
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>
1 parent c11ef0a commit 6a52800

1 file changed

Lines changed: 19 additions & 33 deletions

File tree

‎arch/parisc/mm/init.c‎

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -79,36 +79,6 @@ static struct resource sysram_resources[MAX_PHYSMEM_RANGES] __read_mostly;
7979
physmem_range_t pmem_ranges[MAX_PHYSMEM_RANGES] __read_mostly;
8080
int npmem_ranges __read_mostly;
8181

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-
11282
#ifdef CONFIG_64BIT
11383
#define MAX_MEM (~0UL)
11484
#else /* !CONFIG_64BIT */
@@ -321,6 +291,13 @@ static void __init setup_bootmem(void)
321291
max_pfn = start_pfn + npages;
322292
}
323293

294+
/*
295+
* We can't use memblock top-down allocations because we only
296+
* created the initial mapping up to KERNEL_INITIAL_SIZE in
297+
* the assembly bootup code.
298+
*/
299+
memblock_set_bottom_up(true);
300+
324301
/* IOMMU is always used to access "high mem" on those boxes
325302
* that can support enough mem that a PCI device couldn't
326303
* directly DMA to any physical addresses.
@@ -442,7 +419,10 @@ static void __init map_pages(unsigned long start_vaddr,
442419
*/
443420

444421
if (!pmd) {
445-
pmd = (pmd_t *) get_memblock(PAGE_SIZE << PMD_ORDER);
422+
pmd = memblock_alloc(PAGE_SIZE << PMD_ORDER,
423+
PAGE_SIZE << PMD_ORDER);
424+
if (!pmd)
425+
panic("pmd allocation failed.\n");
446426
pmd = (pmd_t *) __pa(pmd);
447427
}
448428

@@ -461,7 +441,10 @@ static void __init map_pages(unsigned long start_vaddr,
461441

462442
pg_table = (pte_t *)pmd_address(*pmd);
463443
if (!pg_table) {
464-
pg_table = (pte_t *) get_memblock(PAGE_SIZE);
444+
pg_table = memblock_alloc(PAGE_SIZE,
445+
PAGE_SIZE);
446+
if (!pg_table)
447+
panic("page table allocation failed\n");
465448
pg_table = (pte_t *) __pa(pg_table);
466449
}
467450

@@ -700,7 +683,10 @@ static void __init pagetable_init(void)
700683
}
701684
#endif
702685

703-
empty_zero_page = get_memblock(PAGE_SIZE);
686+
empty_zero_page = memblock_alloc(PAGE_SIZE, PAGE_SIZE);
687+
if (!empty_zero_page)
688+
panic("zero page allocation failed.\n");
689+
704690
}
705691

706692
static void __init gateway_init(void)

0 commit comments

Comments
 (0)