[TG3]: Set minimal hw interrupt mitigation.
[linux-2.6/verdex.git] / arch / i386 / mm / highmem.c
blobfc4c4cad4e98e440d3efd49b4ac808a0bf082cb1
1 #include <linux/highmem.h>
3 void *kmap(struct page *page)
5 might_sleep();
6 if (!PageHighMem(page))
7 return page_address(page);
8 return kmap_high(page);
11 void kunmap(struct page *page)
13 if (in_interrupt())
14 BUG();
15 if (!PageHighMem(page))
16 return;
17 kunmap_high(page);
21 * kmap_atomic/kunmap_atomic is significantly faster than kmap/kunmap because
22 * no global lock is needed and because the kmap code must perform a global TLB
23 * invalidation when the kmap pool wraps.
25 * However when holding an atomic kmap is is not legal to sleep, so atomic
26 * kmaps are appropriate for short, tight code paths only.
28 void *kmap_atomic(struct page *page, enum km_type type)
30 enum fixed_addresses idx;
31 unsigned long vaddr;
33 /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
34 inc_preempt_count();
35 if (!PageHighMem(page))
36 return page_address(page);
38 idx = type + KM_TYPE_NR*smp_processor_id();
39 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
40 #ifdef CONFIG_DEBUG_HIGHMEM
41 if (!pte_none(*(kmap_pte-idx)))
42 BUG();
43 #endif
44 set_pte(kmap_pte-idx, mk_pte(page, kmap_prot));
45 __flush_tlb_one(vaddr);
47 return (void*) vaddr;
50 void kunmap_atomic(void *kvaddr, enum km_type type)
52 #ifdef CONFIG_DEBUG_HIGHMEM
53 unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
54 enum fixed_addresses idx = type + KM_TYPE_NR*smp_processor_id();
56 if (vaddr < FIXADDR_START) { // FIXME
57 dec_preempt_count();
58 preempt_check_resched();
59 return;
62 if (vaddr != __fix_to_virt(FIX_KMAP_BEGIN+idx))
63 BUG();
66 * force other mappings to Oops if they'll try to access
67 * this pte without first remap it
69 pte_clear(&init_mm, vaddr, kmap_pte-idx);
70 __flush_tlb_one(vaddr);
71 #endif
73 dec_preempt_count();
74 preempt_check_resched();
77 struct page *kmap_atomic_to_page(void *ptr)
79 unsigned long idx, vaddr = (unsigned long)ptr;
80 pte_t *pte;
82 if (vaddr < FIXADDR_START)
83 return virt_to_page(ptr);
85 idx = virt_to_fix(vaddr);
86 pte = kmap_pte - (idx - FIX_KMAP_BEGIN);
87 return pte_page(*pte);