asm-generic: pgalloc: provide generic pmd_alloc_one() and pmd_free_one()
[linux-block.git] / arch / ia64 / include / asm / pgalloc.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
1da177e4
LT
2#ifndef _ASM_IA64_PGALLOC_H
3#define _ASM_IA64_PGALLOC_H
4
5/*
6 * This file contains the functions and defines necessary to allocate
7 * page tables.
8 *
9 * This hopefully works with any (fixed) ia-64 page-size, as defined
10 * in <asm/page.h> (currently 8192).
11 *
12 * Copyright (C) 1998-2001 Hewlett-Packard Co
13 * David Mosberger-Tang <davidm@hpl.hp.com>
14 * Copyright (C) 2000, Goutham Rao <goutham.rao@intel.com>
15 */
16
1da177e4
LT
17
18#include <linux/compiler.h>
19#include <linux/mm.h>
20#include <linux/page-flags.h>
21#include <linux/threads.h>
22
01319921
MR
23#include <asm-generic/pgalloc.h>
24
1da177e4
LT
25#include <asm/mmu_context.h>
26
fde740e4 27static inline pgd_t *pgd_alloc(struct mm_struct *mm)
1da177e4 28{
13224794 29 return (pgd_t *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
1da177e4
LT
30}
31
5e541973 32static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
1da177e4 33{
13224794 34 free_page((unsigned long)pgd);
1da177e4
LT
35}
36
4d66bcc7 37#if CONFIG_PGTABLE_LEVELS == 4
837cd0bd 38static inline void
c03ab9e3 39p4d_populate(struct mm_struct *mm, p4d_t * p4d_entry, pud_t * pud)
837cd0bd 40{
c03ab9e3 41 p4d_val(*p4d_entry) = __pa(pud);
837cd0bd
RH
42}
43
44static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
45{
13224794 46 return (pud_t *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
837cd0bd
RH
47}
48
5e541973 49static inline void pud_free(struct mm_struct *mm, pud_t *pud)
837cd0bd 50{
13224794 51 free_page((unsigned long)pud);
837cd0bd 52}
9e1b32ca 53#define __pud_free_tlb(tlb, pud, address) pud_free((tlb)->mm, pud)
4d66bcc7 54#endif /* CONFIG_PGTABLE_LEVELS == 4 */
837cd0bd 55
fde740e4
RH
56static inline void
57pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
1da177e4 58{
fde740e4
RH
59 pud_val(*pud_entry) = __pa(pmd);
60}
1da177e4 61
9e1b32ca 62#define __pmd_free_tlb(tlb, pmd, address) pmd_free((tlb)->mm, pmd)
1da177e4
LT
63
64static inline void
2f569afd 65pmd_populate(struct mm_struct *mm, pmd_t * pmd_entry, pgtable_t pte)
1da177e4
LT
66{
67 pmd_val(*pmd_entry) = page_to_phys(pte);
68}
2f569afd 69#define pmd_pgtable(pmd) pmd_page(pmd)
1da177e4
LT
70
71static inline void
fde740e4 72pmd_populate_kernel(struct mm_struct *mm, pmd_t * pmd_entry, pte_t * pte)
1da177e4
LT
73{
74 pmd_val(*pmd_entry) = __pa(pte);
75}
76
9e1b32ca 77#define __pte_free_tlb(tlb, pte, address) pte_free((tlb)->mm, pte)
1da177e4 78
fde740e4 79#endif /* _ASM_IA64_PGALLOC_H */