diff options
Diffstat (limited to 'arch/sh/mm/kmap.c')
-rw-r--r-- | arch/sh/mm/kmap.c | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/arch/sh/mm/kmap.c b/arch/sh/mm/kmap.c index 3eecf0d42f1a..c52cd8c40a64 100644 --- a/arch/sh/mm/kmap.c +++ b/arch/sh/mm/kmap.c | |||
@@ -24,9 +24,6 @@ void __init kmap_coherent_init(void) | |||
24 | { | 24 | { |
25 | unsigned long vaddr; | 25 | unsigned long vaddr; |
26 | 26 | ||
27 | if (!boot_cpu_data.dcache.n_aliases) | ||
28 | return; | ||
29 | |||
30 | /* cache the first coherent kmap pte */ | 27 | /* cache the first coherent kmap pte */ |
31 | vaddr = __fix_to_virt(FIX_CMAP_BEGIN); | 28 | vaddr = __fix_to_virt(FIX_CMAP_BEGIN); |
32 | kmap_coherent_pte = kmap_get_fixmap_pte(vaddr); | 29 | kmap_coherent_pte = kmap_get_fixmap_pte(vaddr); |
@@ -35,30 +32,31 @@ void __init kmap_coherent_init(void) | |||
35 | void *kmap_coherent(struct page *page, unsigned long addr) | 32 | void *kmap_coherent(struct page *page, unsigned long addr) |
36 | { | 33 | { |
37 | enum fixed_addresses idx; | 34 | enum fixed_addresses idx; |
38 | unsigned long vaddr, flags; | 35 | unsigned long vaddr; |
39 | pte_t pte; | ||
40 | 36 | ||
41 | BUG_ON(test_bit(PG_dcache_dirty, &page->flags)); | 37 | BUG_ON(test_bit(PG_dcache_dirty, &page->flags)); |
42 | 38 | ||
43 | inc_preempt_count(); | 39 | pagefault_disable(); |
44 | |||
45 | idx = (addr & current_cpu_data.dcache.alias_mask) >> PAGE_SHIFT; | ||
46 | vaddr = __fix_to_virt(FIX_CMAP_END - idx); | ||
47 | pte = mk_pte(page, PAGE_KERNEL); | ||
48 | 40 | ||
49 | local_irq_save(flags); | 41 | idx = FIX_CMAP_END - |
50 | flush_tlb_one(get_asid(), vaddr); | 42 | ((addr & current_cpu_data.dcache.alias_mask) >> PAGE_SHIFT); |
51 | local_irq_restore(flags); | 43 | vaddr = __fix_to_virt(idx); |
52 | 44 | ||
53 | update_mmu_cache(NULL, vaddr, pte); | 45 | BUG_ON(!pte_none(*(kmap_coherent_pte - idx))); |
54 | 46 | set_pte(kmap_coherent_pte - idx, mk_pte(page, PAGE_KERNEL)); | |
55 | set_pte(kmap_coherent_pte - (FIX_CMAP_END - idx), pte); | ||
56 | 47 | ||
57 | return (void *)vaddr; | 48 | return (void *)vaddr; |
58 | } | 49 | } |
59 | 50 | ||
60 | void kunmap_coherent(void) | 51 | void kunmap_coherent(void *kvaddr) |
61 | { | 52 | { |
62 | dec_preempt_count(); | 53 | if (kvaddr >= (void *)FIXADDR_START) { |
63 | preempt_check_resched(); | 54 | unsigned long vaddr = (unsigned long)kvaddr & PAGE_MASK; |
55 | enum fixed_addresses idx = __virt_to_fix(vaddr); | ||
56 | |||
57 | pte_clear(&init_mm, vaddr, kmap_coherent_pte - idx); | ||
58 | local_flush_tlb_one(get_asid(), vaddr); | ||
59 | } | ||
60 | |||
61 | pagefault_enable(); | ||
64 | } | 62 | } |