| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2009 Chen Liqin <liqin.chen@sunplusct.com> |
|---|
| 3 | 4 | * Copyright (C) 2012 Regents of the University of California |
|---|
| 4 | | - * |
|---|
| 5 | | - * This program is free software; you can redistribute it and/or |
|---|
| 6 | | - * modify it under the terms of the GNU General Public License |
|---|
| 7 | | - * as published by the Free Software Foundation, version 2. |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 10 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 11 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 12 | | - * GNU General Public License for more details. |
|---|
| 13 | 5 | */ |
|---|
| 14 | 6 | |
|---|
| 15 | 7 | #ifndef _ASM_RISCV_PGALLOC_H |
|---|
| .. | .. |
|---|
| 17 | 9 | |
|---|
| 18 | 10 | #include <linux/mm.h> |
|---|
| 19 | 11 | #include <asm/tlb.h> |
|---|
| 12 | + |
|---|
| 13 | +#ifdef CONFIG_MMU |
|---|
| 14 | +#include <asm-generic/pgalloc.h> |
|---|
| 20 | 15 | |
|---|
| 21 | 16 | static inline void pmd_populate_kernel(struct mm_struct *mm, |
|---|
| 22 | 17 | pmd_t *pmd, pte_t *pte) |
|---|
| .. | .. |
|---|
| 60 | 55 | return pgd; |
|---|
| 61 | 56 | } |
|---|
| 62 | 57 | |
|---|
| 63 | | -static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd) |
|---|
| 64 | | -{ |
|---|
| 65 | | - free_page((unsigned long)pgd); |
|---|
| 66 | | -} |
|---|
| 67 | | - |
|---|
| 68 | 58 | #ifndef __PAGETABLE_PMD_FOLDED |
|---|
| 69 | | - |
|---|
| 70 | | -static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr) |
|---|
| 71 | | -{ |
|---|
| 72 | | - return (pmd_t *)__get_free_page( |
|---|
| 73 | | - GFP_KERNEL | __GFP_RETRY_MAYFAIL | __GFP_ZERO); |
|---|
| 74 | | -} |
|---|
| 75 | | - |
|---|
| 76 | | -static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd) |
|---|
| 77 | | -{ |
|---|
| 78 | | - free_page((unsigned long)pmd); |
|---|
| 79 | | -} |
|---|
| 80 | 59 | |
|---|
| 81 | 60 | #define __pmd_free_tlb(tlb, pmd, addr) pmd_free((tlb)->mm, pmd) |
|---|
| 82 | 61 | |
|---|
| 83 | 62 | #endif /* __PAGETABLE_PMD_FOLDED */ |
|---|
| 84 | 63 | |
|---|
| 85 | | -static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, |
|---|
| 86 | | - unsigned long address) |
|---|
| 87 | | -{ |
|---|
| 88 | | - return (pte_t *)__get_free_page( |
|---|
| 89 | | - GFP_KERNEL | __GFP_RETRY_MAYFAIL | __GFP_ZERO); |
|---|
| 90 | | -} |
|---|
| 91 | | - |
|---|
| 92 | | -static inline struct page *pte_alloc_one(struct mm_struct *mm, |
|---|
| 93 | | - unsigned long address) |
|---|
| 94 | | -{ |
|---|
| 95 | | - struct page *pte; |
|---|
| 96 | | - |
|---|
| 97 | | - pte = alloc_page(GFP_KERNEL | __GFP_RETRY_MAYFAIL | __GFP_ZERO); |
|---|
| 98 | | - if (likely(pte != NULL)) |
|---|
| 99 | | - pgtable_page_ctor(pte); |
|---|
| 100 | | - return pte; |
|---|
| 101 | | -} |
|---|
| 102 | | - |
|---|
| 103 | | -static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) |
|---|
| 104 | | -{ |
|---|
| 105 | | - free_page((unsigned long)pte); |
|---|
| 106 | | -} |
|---|
| 107 | | - |
|---|
| 108 | | -static inline void pte_free(struct mm_struct *mm, pgtable_t pte) |
|---|
| 109 | | -{ |
|---|
| 110 | | - pgtable_page_dtor(pte); |
|---|
| 111 | | - __free_page(pte); |
|---|
| 112 | | -} |
|---|
| 113 | | - |
|---|
| 114 | 64 | #define __pte_free_tlb(tlb, pte, buf) \ |
|---|
| 115 | 65 | do { \ |
|---|
| 116 | | - pgtable_page_dtor(pte); \ |
|---|
| 66 | + pgtable_pte_page_dtor(pte); \ |
|---|
| 117 | 67 | tlb_remove_page((tlb), pte); \ |
|---|
| 118 | 68 | } while (0) |
|---|
| 119 | | - |
|---|
| 120 | | -static inline void check_pgt_cache(void) |
|---|
| 121 | | -{ |
|---|
| 122 | | -} |
|---|
| 69 | +#endif /* CONFIG_MMU */ |
|---|
| 123 | 70 | |
|---|
| 124 | 71 | #endif /* _ASM_RISCV_PGALLOC_H */ |
|---|