2 * TLB flushing operations for SH with an MMU.
4 * Copyright (C) 1999 Niibe Yutaka
5 * Copyright (C) 2003 Paul Mundt
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive
12 #include <asm/mmu_context.h>
13 #include <asm/tlbflush.h>
15 void flush_tlb_page(struct vm_area_struct *vma, unsigned long page)
17 if (vma->vm_mm && vma->vm_mm->context.id != NO_CONTEXT) {
20 unsigned long saved_asid = MMU_NO_ASID;
22 asid = vma->vm_mm->context.id & MMU_CONTEXT_ASID_MASK;
25 local_irq_save(flags);
26 if (vma->vm_mm != current->mm) {
27 saved_asid = get_asid();
30 __flush_tlb_page(asid, page);
31 if (saved_asid != MMU_NO_ASID)
33 local_irq_restore(flags);
37 void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
40 struct mm_struct *mm = vma->vm_mm;
42 if (mm->context.id != NO_CONTEXT) {
46 local_irq_save(flags);
47 size = (end - start + (PAGE_SIZE - 1)) >> PAGE_SHIFT;
48 if (size > (MMU_NTLB_ENTRIES/4)) { /* Too many TLB to flush */
49 mm->context.id = NO_CONTEXT;
50 if (mm == current->mm)
54 unsigned long saved_asid = MMU_NO_ASID;
56 asid = mm->context.id & MMU_CONTEXT_ASID_MASK;
58 end += (PAGE_SIZE - 1);
60 if (mm != current->mm) {
61 saved_asid = get_asid();
65 __flush_tlb_page(asid, start);
68 if (saved_asid != MMU_NO_ASID)
71 local_irq_restore(flags);
75 void flush_tlb_kernel_range(unsigned long start, unsigned long end)
80 local_irq_save(flags);
81 size = (end - start + (PAGE_SIZE - 1)) >> PAGE_SHIFT;
82 if (size > (MMU_NTLB_ENTRIES/4)) { /* Too many TLB to flush */
86 unsigned long saved_asid = get_asid();
88 asid = init_mm.context.id & MMU_CONTEXT_ASID_MASK;
90 end += (PAGE_SIZE - 1);
94 __flush_tlb_page(asid, start);
99 local_irq_restore(flags);
102 void flush_tlb_mm(struct mm_struct *mm)
104 /* Invalidate all TLB of this process. */
105 /* Instead of invalidating each TLB, we get new MMU context. */
106 if (mm->context.id != NO_CONTEXT) {
109 local_irq_save(flags);
110 mm->context.id = NO_CONTEXT;
111 if (mm == current->mm)
112 activate_context(mm);
113 local_irq_restore(flags);
117 void flush_tlb_all(void)
119 unsigned long flags, status;
124 * Write to the MMU control register's bit:
125 * TF-bit for SH-3, TI-bit for SH-4.
126 * It's same position, bit #2.
128 local_irq_save(flags);
129 status = ctrl_inl(MMUCR);
131 ctrl_outl(status, MMUCR);
133 local_irq_restore(flags);