]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - arch/ia64/include/asm/pgalloc.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[mirror_ubuntu-bionic-kernel.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>
2bd62a40 22#include <linux/quicklist.h>
1da177e4
LT
23
24#include <asm/mmu_context.h>
25
fde740e4 26static inline pgd_t *pgd_alloc(struct mm_struct *mm)
1da177e4 27{
2bd62a40 28 return quicklist_alloc(0, GFP_KERNEL, NULL);
1da177e4
LT
29}
30
5e541973 31static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
1da177e4 32{
2bd62a40 33 quicklist_free(0, NULL, pgd);
1da177e4
LT
34}
35
4d66bcc7 36#if CONFIG_PGTABLE_LEVELS == 4
837cd0bd
RH
37static inline void
38pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
39{
40 pgd_val(*pgd_entry) = __pa(pud);
41}
42
43static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
44{
2bd62a40 45 return quicklist_alloc(0, GFP_KERNEL, NULL);
837cd0bd
RH
46}
47
5e541973 48static inline void pud_free(struct mm_struct *mm, pud_t *pud)
837cd0bd 49{
2bd62a40 50 quicklist_free(0, NULL, pud);
837cd0bd 51}
9e1b32ca 52#define __pud_free_tlb(tlb, pud, address) pud_free((tlb)->mm, pud)
4d66bcc7 53#endif /* CONFIG_PGTABLE_LEVELS == 4 */
837cd0bd 54
fde740e4
RH
55static inline void
56pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
1da177e4 57{
fde740e4
RH
58 pud_val(*pud_entry) = __pa(pmd);
59}
1da177e4 60
fde740e4
RH
61static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
62{
2bd62a40 63 return quicklist_alloc(0, GFP_KERNEL, NULL);
1da177e4
LT
64}
65
5e541973 66static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
1da177e4 67{
2bd62a40 68 quicklist_free(0, NULL, pmd);
1da177e4
LT
69}
70
9e1b32ca 71#define __pmd_free_tlb(tlb, pmd, address) pmd_free((tlb)->mm, pmd)
1da177e4
LT
72
73static inline void
2f569afd 74pmd_populate(struct mm_struct *mm, pmd_t * pmd_entry, pgtable_t pte)
1da177e4
LT
75{
76 pmd_val(*pmd_entry) = page_to_phys(pte);
77}
2f569afd 78#define pmd_pgtable(pmd) pmd_page(pmd)
1da177e4
LT
79
80static inline void
fde740e4 81pmd_populate_kernel(struct mm_struct *mm, pmd_t * pmd_entry, pte_t * pte)
1da177e4
LT
82{
83 pmd_val(*pmd_entry) = __pa(pte);
84}
85
2f569afd 86static inline pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long addr)
1da177e4 87{
2f569afd
MS
88 struct page *page;
89 void *pg;
90
91 pg = quicklist_alloc(0, GFP_KERNEL, NULL);
92 if (!pg)
93 return NULL;
94 page = virt_to_page(pg);
ca973d86
KS
95 if (!pgtable_page_ctor(page)) {
96 quicklist_free(0, NULL, pg);
97 return NULL;
98 }
2f569afd 99 return page;
1da177e4
LT
100}
101
fde740e4
RH
102static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
103 unsigned long addr)
1da177e4 104{
2bd62a40 105 return quicklist_alloc(0, GFP_KERNEL, NULL);
1da177e4
LT
106}
107
2f569afd 108static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
1da177e4 109{
2f569afd 110 pgtable_page_dtor(pte);
2bd62a40 111 quicklist_free_page(0, NULL, pte);
1da177e4
LT
112}
113
5e541973 114static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
1da177e4 115{
2bd62a40 116 quicklist_free(0, NULL, pte);
1da177e4
LT
117}
118
2bd62a40
CL
119static inline void check_pgt_cache(void)
120{
121 quicklist_trim(0, NULL, 25, 16);
122}
1da177e4 123
9e1b32ca 124#define __pte_free_tlb(tlb, pte, address) pte_free((tlb)->mm, pte)
1da177e4 125
fde740e4 126#endif /* _ASM_IA64_PGALLOC_H */