aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/mm/highmem.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/mips/mm/highmem.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/mips/mm/highmem.c')
-rw-r--r--arch/mips/mm/highmem.c103
1 files changed, 103 insertions, 0 deletions
diff --git a/arch/mips/mm/highmem.c b/arch/mips/mm/highmem.c
new file mode 100644
index 000000000000..dd5e2e31885b
--- /dev/null
+++ b/arch/mips/mm/highmem.c
@@ -0,0 +1,103 @@
1#include <linux/config.h>
2#include <linux/module.h>
3#include <linux/highmem.h>
4#include <asm/tlbflush.h>
5
6void *__kmap(struct page *page)
7{
8 void *addr;
9
10 might_sleep();
11 if (!PageHighMem(page))
12 return page_address(page);
13 addr = kmap_high(page);
14 flush_tlb_one((unsigned long)addr);
15
16 return addr;
17}
18
19void __kunmap(struct page *page)
20{
21 if (in_interrupt())
22 BUG();
23 if (!PageHighMem(page))
24 return;
25 kunmap_high(page);
26}
27
28/*
29 * kmap_atomic/kunmap_atomic is significantly faster than kmap/kunmap because
30 * no global lock is needed and because the kmap code must perform a global TLB
31 * invalidation when the kmap pool wraps.
32 *
33 * However when holding an atomic kmap is is not legal to sleep, so atomic
34 * kmaps are appropriate for short, tight code paths only.
35 */
36
37void *__kmap_atomic(struct page *page, enum km_type type)
38{
39 enum fixed_addresses idx;
40 unsigned long vaddr;
41
42 /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
43 inc_preempt_count();
44 if (!PageHighMem(page))
45 return page_address(page);
46
47 idx = type + KM_TYPE_NR*smp_processor_id();
48 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
49#ifdef CONFIG_DEBUG_HIGHMEM
50 if (!pte_none(*(kmap_pte-idx)))
51 BUG();
52#endif
53 set_pte(kmap_pte-idx, mk_pte(page, kmap_prot));
54 local_flush_tlb_one((unsigned long)vaddr);
55
56 return (void*) vaddr;
57}
58
59void __kunmap_atomic(void *kvaddr, enum km_type type)
60{
61#ifdef CONFIG_DEBUG_HIGHMEM
62 unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
63 enum fixed_addresses idx = type + KM_TYPE_NR*smp_processor_id();
64
65 if (vaddr < FIXADDR_START) { // FIXME
66 dec_preempt_count();
67 preempt_check_resched();
68 return;
69 }
70
71 if (vaddr != __fix_to_virt(FIX_KMAP_BEGIN+idx))
72 BUG();
73
74 /*
75 * force other mappings to Oops if they'll try to access
76 * this pte without first remap it
77 */
78 pte_clear(&init_mm, vaddr, kmap_pte-idx);
79 local_flush_tlb_one(vaddr);
80#endif
81
82 dec_preempt_count();
83 preempt_check_resched();
84}
85
86struct page *__kmap_atomic_to_page(void *ptr)
87{
88 unsigned long idx, vaddr = (unsigned long)ptr;
89 pte_t *pte;
90
91 if (vaddr < FIXADDR_START)
92 return virt_to_page(ptr);
93
94 idx = virt_to_fix(vaddr);
95 pte = kmap_pte - (idx - FIX_KMAP_BEGIN);
96 return pte_page(*pte);
97}
98
99EXPORT_SYMBOL(__kmap);
100EXPORT_SYMBOL(__kunmap);
101EXPORT_SYMBOL(__kmap_atomic);
102EXPORT_SYMBOL(__kunmap_atomic);
103EXPORT_SYMBOL(__kmap_atomic_to_page);