Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[wrt350n-kernel.git] / include / asm-avr32 / pgalloc.h
blobbb82e70cde8d048fb01c3594b0233ba8c9d83fbd
1 /*
2 * Copyright (C) 2004-2006 Atmel Corporation
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8 #ifndef __ASM_AVR32_PGALLOC_H
9 #define __ASM_AVR32_PGALLOC_H
11 #include <asm/processor.h>
12 #include <linux/threads.h>
13 #include <linux/slab.h>
14 #include <linux/mm.h>
16 #define pmd_populate_kernel(mm, pmd, pte) \
17 set_pmd(pmd, __pmd(_PAGE_TABLE + __pa(pte)))
19 static __inline__ void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
20 struct page *pte)
22 set_pmd(pmd, __pmd(_PAGE_TABLE + page_to_phys(pte)));
26 * Allocate and free page tables
28 static __inline__ pgd_t *pgd_alloc(struct mm_struct *mm)
30 unsigned int pgd_size = (USER_PTRS_PER_PGD * sizeof(pgd_t));
31 pgd_t *pgd = kmalloc(pgd_size, GFP_KERNEL);
33 if (pgd)
34 memset(pgd, 0, pgd_size);
36 return pgd;
39 static inline void pgd_free(pgd_t *pgd)
41 kfree(pgd);
44 static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
45 unsigned long address)
47 int count = 0;
48 pte_t *pte;
50 do {
51 pte = (pte_t *) __get_free_page(GFP_KERNEL | __GFP_REPEAT);
52 if (pte)
53 clear_page(pte);
54 else {
55 current->state = TASK_UNINTERRUPTIBLE;
56 schedule_timeout(HZ);
58 } while (!pte && (count++ < 10));
60 return pte;
63 static inline struct page *pte_alloc_one(struct mm_struct *mm,
64 unsigned long address)
66 int count = 0;
67 struct page *pte;
69 do {
70 pte = alloc_pages(GFP_KERNEL, 0);
71 if (pte)
72 clear_page(page_address(pte));
73 else {
74 current->state = TASK_UNINTERRUPTIBLE;
75 schedule_timeout(HZ);
77 } while (!pte && (count++ < 10));
79 return pte;
82 static inline void pte_free_kernel(pte_t *pte)
84 free_page((unsigned long)pte);
87 static inline void pte_free(struct page *pte)
89 __free_page(pte);
92 #define __pte_free_tlb(tlb,pte) tlb_remove_page((tlb),(pte))
94 #define check_pgt_cache() do { } while(0)
96 #endif /* __ASM_AVR32_PGALLOC_H */