Linux Audio

Check our new training course

Loading...
v6.9.4
 1/* SPDX-License-Identifier: GPL-2.0 */
 2#ifndef _ASM_POWERPC_PGALLOC_H
 3#define _ASM_POWERPC_PGALLOC_H
 
 4
 5#include <linux/mm.h>
 6
 7#ifndef MODULE
 8static inline gfp_t pgtable_gfp_flags(struct mm_struct *mm, gfp_t gfp)
 
 
 
 9{
10	if (unlikely(mm == &init_mm))
11		return gfp;
12	return gfp | __GFP_ACCOUNT;
13}
14#else /* !MODULE */
15static inline gfp_t pgtable_gfp_flags(struct mm_struct *mm, gfp_t gfp)
 
16{
17	return gfp | __GFP_ACCOUNT;
18}
19#endif /* MODULE */
20
21#define PGALLOC_GFP (GFP_KERNEL | __GFP_ZERO)
22
23pte_t *pte_fragment_alloc(struct mm_struct *mm, int kernel);
24
25static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm)
26{
27	return (pte_t *)pte_fragment_alloc(mm, 1);
 
28}
29
30static inline pgtable_t pte_alloc_one(struct mm_struct *mm)
 
 
 
 
 
 
 
 
 
 
31{
32	return (pgtable_t)pte_fragment_alloc(mm, 0);
 
 
 
33}
34
35void pte_frag_destroy(void *pte_frag);
36void pte_fragment_free(unsigned long *table, int kernel);
 
 
37
38static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
 
 
 
39{
40	pte_fragment_free((unsigned long *)pte, 1);
41}
 
42
43static inline void pte_free(struct mm_struct *mm, pgtable_t ptepage)
 
44{
45	pte_fragment_free((unsigned long *)ptepage, 0);
 
 
46}
47
48/* arch use pte_free_defer() implementation in arch/powerpc/mm/pgtable-frag.c */
49#define pte_free_defer pte_free_defer
50void pte_free_defer(struct mm_struct *mm, pgtable_t pgtable);
51
52/*
53 * Functions that deal with pagetables that could be at any level of
54 * the table need to be passed an "index_size" so they know how to
55 * handle allocation.  For PTE pages, the allocation size will be
56 * (2^index_size * sizeof(pointer)) and allocations are drawn from
57 * the kmem_cache in PGT_CACHE(index_size).
58 *
59 * The maximum index size needs to be big enough to allow any
60 * pagetable sizes we need, but small enough to fit in the low bits of
61 * any page table pointer.  In other words all pagetables, even tiny
62 * ones, must be aligned to allow at least enough low 0 bits to
63 * contain this value.  This value is also used as a mask, so it must
64 * be one less than a power of two.
65 */
66#define MAX_PGTABLE_INDEX_SIZE	0xf
67
68extern struct kmem_cache *pgtable_cache[];
69#define PGT_CACHE(shift) pgtable_cache[shift]
70
71#ifdef CONFIG_PPC_BOOK3S
72#include <asm/book3s/pgalloc.h>
73#else
74#include <asm/nohash/pgalloc.h>
75#endif
76
77#endif /* _ASM_POWERPC_PGALLOC_H */
v3.1
 
 1#ifndef _ASM_POWERPC_PGALLOC_H
 2#define _ASM_POWERPC_PGALLOC_H
 3#ifdef __KERNEL__
 4
 5#include <linux/mm.h>
 6
 7#ifdef CONFIG_PPC_BOOK3E
 8extern void tlb_flush_pgtable(struct mmu_gather *tlb, unsigned long address);
 9#else /* CONFIG_PPC_BOOK3E */
10static inline void tlb_flush_pgtable(struct mmu_gather *tlb,
11				     unsigned long address)
12{
 
 
 
13}
14#endif /* !CONFIG_PPC_BOOK3E */
15
16static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
17{
18	free_page((unsigned long)pte);
19}
 
 
 
20
21static inline void pte_free(struct mm_struct *mm, pgtable_t ptepage)
 
 
22{
23	pgtable_page_dtor(ptepage);
24	__free_page(ptepage);
25}
26
27#ifdef CONFIG_PPC64
28#include <asm/pgalloc-64.h>
29#else
30#include <asm/pgalloc-32.h>
31#endif
32
33#ifdef CONFIG_SMP
34struct mmu_gather;
35extern void tlb_remove_table(struct mmu_gather *, void *);
36
37static inline void pgtable_free_tlb(struct mmu_gather *tlb, void *table, int shift)
38{
39	unsigned long pgf = (unsigned long)table;
40	BUG_ON(shift > MAX_PGTABLE_INDEX_SIZE);
41	pgf |= shift;
42	tlb_remove_table(tlb, (void *)pgf);
43}
44
45static inline void __tlb_remove_table(void *_table)
46{
47	void *table = (void *)((unsigned long)_table & ~MAX_PGTABLE_INDEX_SIZE);
48	unsigned shift = (unsigned long)_table & MAX_PGTABLE_INDEX_SIZE;
49
50	pgtable_free(table, shift);
51}
52#else /* CONFIG_SMP */
53static inline void pgtable_free_tlb(struct mmu_gather *tlb, void *table, unsigned shift)
54{
55	pgtable_free(table, shift);
56}
57#endif /* !CONFIG_SMP */
58
59static inline void __pte_free_tlb(struct mmu_gather *tlb, struct page *ptepage,
60				  unsigned long address)
61{
62	tlb_flush_pgtable(tlb, address);
63	pgtable_page_dtor(ptepage);
64	pgtable_free_tlb(tlb, page_address(ptepage), 0);
65}
66
67#endif /* __KERNEL__ */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68#endif /* _ASM_POWERPC_PGALLOC_H */