Commit | Line | Data |
---|---|---|
3f65ce4d | 1 | /* |
f30c2269 | 2 | * arch/xtensa/mm/pgtable.c |
3f65ce4d CZ |
3 | * |
4 | * This file is subject to the terms and conditions of the GNU General Public | |
5 | * License. See the file "COPYING" in the main directory of this archive | |
6 | * for more details. | |
7 | * | |
8 | * Copyright (C) 2001 - 2005 Tensilica Inc. | |
9 | * | |
10 | * Chris Zankel <chris@zankel.net> | |
11 | */ | |
12 | ||
13 | #if (DCACHE_SIZE > PAGE_SIZE) | |
14 | ||
15 | pte_t* pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address) | |
16 | { | |
8e7a9aae | 17 | pte_t *pte = NULL, *p; |
3f65ce4d CZ |
18 | int color = ADDR_COLOR(address); |
19 | int i; | |
20 | ||
21 | p = (pte_t*) __get_free_pages(GFP_KERNEL|__GFP_REPEAT, COLOR_ORDER); | |
22 | ||
23 | if (likely(p)) { | |
8dfcc9ba | 24 | split_page(virt_to_page(p), COLOR_ORDER); |
3f65ce4d | 25 | |
8e7a9aae | 26 | for (i = 0; i < COLOR_SIZE; i++) { |
3f65ce4d CZ |
27 | if (ADDR_COLOR(p) == color) |
28 | pte = p; | |
29 | else | |
30 | free_page(p); | |
8e7a9aae | 31 | p += PTRS_PER_PTE; |
3f65ce4d CZ |
32 | } |
33 | clear_page(pte); | |
34 | } | |
35 | return pte; | |
36 | } | |
37 | ||
38 | #ifdef PROFILING | |
39 | ||
40 | int mask; | |
41 | int hit; | |
42 | int flush; | |
43 | ||
44 | #endif | |
45 | ||
46 | struct page* pte_alloc_one(struct mm_struct *mm, unsigned long address) | |
47 | { | |
8e7a9aae | 48 | struct page *page = NULL, *p; |
3f65ce4d CZ |
49 | int color = ADDR_COLOR(address); |
50 | ||
51 | p = alloc_pages(GFP_KERNEL | __GFP_REPEAT, PTE_ORDER); | |
52 | ||
53 | if (likely(p)) { | |
8dfcc9ba | 54 | split_page(p, COLOR_ORDER); |
3f65ce4d | 55 | |
8dfcc9ba | 56 | for (i = 0; i < PAGE_ORDER; i++) { |
8e7a9aae | 57 | if (PADDR_COLOR(page_address(p)) == color) |
3f65ce4d CZ |
58 | page = p; |
59 | else | |
8e7a9aae NP |
60 | __free_page(p); |
61 | p++; | |
3f65ce4d CZ |
62 | } |
63 | clear_highpage(page); | |
64 | } | |
65 | ||
66 | return page; | |
67 | } | |
68 | ||
69 | #endif | |
70 | ||
71 | ||
72 |