Skip to content

Commit

Permalink
microblaze: simplify pte_alloc_one_kernel()
Browse files Browse the repository at this point in the history
The microblaze's implementation of pte_alloc_one_kernel() used
memblock_alloc_try_nid_raw() along with clear_page() to allocated a zeroed
page during early setup.

Replace calls of these functions with a call to memblock_alloc_try_nid()
that already returns zeroed page and respects the same allocation limits
as memblock_alloc_try_nid_raw().

While on it drop early_get_page() wrapper that was only used in
pte_alloc_one_kernel().

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Mike Rapoport <[email protected]>
Reviewed-by: David Hildenbrand <[email protected]>
Cc: Michal Simek <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
rppt authored and torvalds committed Sep 3, 2021
1 parent c3ab6ba commit 22e7878
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 23 deletions.
2 changes: 0 additions & 2 deletions arch/microblaze/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,6 @@ extern int mem_init_done;

asmlinkage void __init mmu_init(void);

void __init *early_get_page(void);

#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */

Expand Down
12 changes: 0 additions & 12 deletions arch/microblaze/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,18 +265,6 @@ asmlinkage void __init mmu_init(void)
dma_contiguous_reserve(memory_start + lowmem_size - 1);
}

/* This is only called until mem_init is done. */
void __init *early_get_page(void)
{
/*
* Mem start + kernel_tlb -> here is limit
* because of mem mapping from head.S
*/
return memblock_alloc_try_nid_raw(PAGE_SIZE, PAGE_SIZE,
MEMBLOCK_LOW_LIMIT, memory_start + kernel_tlb,
NUMA_NO_NODE);
}

void * __ref zalloc_maybe_bootmem(size_t size, gfp_t mask)
{
void *p;
Expand Down
17 changes: 8 additions & 9 deletions arch/microblaze/mm/pgtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <linux/init.h>
#include <linux/mm_types.h>
#include <linux/pgtable.h>
#include <linux/memblock.h>

#include <asm/pgalloc.h>
#include <linux/io.h>
Expand Down Expand Up @@ -242,15 +243,13 @@ unsigned long iopa(unsigned long addr)

__ref pte_t *pte_alloc_one_kernel(struct mm_struct *mm)
{
pte_t *pte;
if (mem_init_done) {
pte = (pte_t *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
} else {
pte = (pte_t *)early_get_page();
if (pte)
clear_page(pte);
}
return pte;
if (mem_init_done)
return (pte_t *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
else
return memblock_alloc_try_nid(PAGE_SIZE, PAGE_SIZE,
MEMBLOCK_LOW_LIMIT,
memory_start + kernel_tlb,
NUMA_NO_NODE);
}

void __set_fixmap(enum fixed_addresses idx, phys_addr_t phys, pgprot_t flags)
Expand Down

0 comments on commit 22e7878

Please sign in to comment.