Linux Audio

Check our new training course

Loading...
v6.13.7
 1/* SPDX-License-Identifier: GPL-2.0 */
 2#ifndef M68K_MCF_PGALLOC_H
 3#define M68K_MCF_PGALLOC_H
 4
 5#include <asm/tlb.h>
 6#include <asm/tlbflush.h>
 7
 8static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
 9{
10	pagetable_free(virt_to_ptdesc(pte));
11}
12
13extern const char bad_pmd_string[];
14
15static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm)
 
16{
17	struct ptdesc *ptdesc = pagetable_alloc((GFP_DMA | __GFP_ZERO) &
18			~__GFP_HIGHMEM, 0);
19
20	if (!ptdesc)
21		return NULL;
22
23	return ptdesc_address(ptdesc);
 
24}
25
26extern inline pmd_t *pmd_alloc_kernel(pgd_t *pgd, unsigned long address)
27{
28	return (pmd_t *) pgd;
29}
30
31#define pmd_populate(mm, pmd, pte) (pmd_val(*pmd) = (unsigned long)(pte))
 
32
33#define pmd_populate_kernel pmd_populate
34
35static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t pgtable,
 
 
 
 
 
 
 
36				  unsigned long address)
37{
38	struct ptdesc *ptdesc = virt_to_ptdesc(pgtable);
39
40	pagetable_pte_dtor(ptdesc);
41	pagetable_free(ptdesc);
42}
43
44static inline pgtable_t pte_alloc_one(struct mm_struct *mm)
 
 
 
45{
46	struct ptdesc *ptdesc = pagetable_alloc(GFP_DMA | __GFP_ZERO, 0);
47	pte_t *pte;
48
49	if (!ptdesc)
50		return NULL;
51	if (!pagetable_pte_ctor(ptdesc)) {
52		pagetable_free(ptdesc);
53		return NULL;
54	}
55
56	pte = ptdesc_address(ptdesc);
57	return pte;
 
 
 
 
 
 
 
 
58}
59
60static inline void pte_free(struct mm_struct *mm, pgtable_t pgtable)
61{
62	struct ptdesc *ptdesc = virt_to_ptdesc(pgtable);
63
64	pagetable_pte_dtor(ptdesc);
65	pagetable_free(ptdesc);
66}
67
68/*
69 * In our implementation, each pgd entry contains 1 pmd that is never allocated
70 * or freed.  pgd_present is always 1, so this should never be called. -NL
71 */
72#define pmd_free(mm, pmd) BUG()
73
74static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
75{
76	pagetable_free(virt_to_ptdesc(pgd));
77}
78
79static inline pgd_t *pgd_alloc(struct mm_struct *mm)
80{
81	pgd_t *new_pgd;
82	struct ptdesc *ptdesc = pagetable_alloc((GFP_DMA | __GFP_NOWARN) &
83			~__GFP_HIGHMEM, 0);
84
85	if (!ptdesc)
 
86		return NULL;
87	new_pgd = ptdesc_address(ptdesc);
88
89	memcpy(new_pgd, swapper_pg_dir, PTRS_PER_PGD * sizeof(pgd_t));
90	memset(new_pgd, 0, PAGE_OFFSET >> PGDIR_SHIFT);
91	return new_pgd;
92}
 
 
93
94#endif /* M68K_MCF_PGALLOC_H */
v4.6
 
  1#ifndef M68K_MCF_PGALLOC_H
  2#define M68K_MCF_PGALLOC_H
  3
  4#include <asm/tlb.h>
  5#include <asm/tlbflush.h>
  6
  7extern inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
  8{
  9	free_page((unsigned long) pte);
 10}
 11
 12extern const char bad_pmd_string[];
 13
 14extern inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
 15	unsigned long address)
 16{
 17	unsigned long page = __get_free_page(GFP_DMA|__GFP_REPEAT);
 
 18
 19	if (!page)
 20		return NULL;
 21
 22	memset((void *)page, 0, PAGE_SIZE);
 23	return (pte_t *) (page);
 24}
 25
 26extern inline pmd_t *pmd_alloc_kernel(pgd_t *pgd, unsigned long address)
 27{
 28	return (pmd_t *) pgd;
 29}
 30
 31#define pmd_alloc_one_fast(mm, address) ({ BUG(); ((pmd_t *)1); })
 32#define pmd_alloc_one(mm, address)      ({ BUG(); ((pmd_t *)2); })
 33
 34#define pte_alloc_one_fast(mm, addr) pte_alloc_one(mm, addr)
 35
 36#define pmd_populate(mm, pmd, page) (pmd_val(*pmd) = \
 37	(unsigned long)(page_address(page)))
 38
 39#define pmd_populate_kernel(mm, pmd, pte) (pmd_val(*pmd) = (unsigned long)(pte))
 40
 41#define pmd_pgtable(pmd) pmd_page(pmd)
 42
 43static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t page,
 44				  unsigned long address)
 45{
 46	__free_page(page);
 
 
 
 47}
 48
 49#define __pmd_free_tlb(tlb, pmd, address) do { } while (0)
 50
 51static inline struct page *pte_alloc_one(struct mm_struct *mm,
 52	unsigned long address)
 53{
 54	struct page *page = alloc_pages(GFP_DMA|__GFP_REPEAT, 0);
 55	pte_t *pte;
 56
 57	if (!page)
 58		return NULL;
 59	if (!pgtable_page_ctor(page)) {
 60		__free_page(page);
 61		return NULL;
 62	}
 63
 64	pte = kmap(page);
 65	if (pte) {
 66		clear_page(pte);
 67		__flush_page_to_ram(pte);
 68		flush_tlb_kernel_page(pte);
 69		nocache_page(pte);
 70	}
 71	kunmap(page);
 72
 73	return page;
 74}
 75
 76extern inline void pte_free(struct mm_struct *mm, struct page *page)
 77{
 78	__free_page(page);
 
 
 
 79}
 80
 81/*
 82 * In our implementation, each pgd entry contains 1 pmd that is never allocated
 83 * or freed.  pgd_present is always 1, so this should never be called. -NL
 84 */
 85#define pmd_free(mm, pmd) BUG()
 86
 87static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
 88{
 89	free_page((unsigned long) pgd);
 90}
 91
 92static inline pgd_t *pgd_alloc(struct mm_struct *mm)
 93{
 94	pgd_t *new_pgd;
 
 
 95
 96	new_pgd = (pgd_t *)__get_free_page(GFP_DMA | __GFP_NOWARN);
 97	if (!new_pgd)
 98		return NULL;
 99	memcpy(new_pgd, swapper_pg_dir, PAGE_SIZE);
 
 
100	memset(new_pgd, 0, PAGE_OFFSET >> PGDIR_SHIFT);
101	return new_pgd;
102}
103
104#define pgd_populate(mm, pmd, pte) BUG()
105
106#endif /* M68K_MCF_PGALLOC_H */