2006-09-27 08:13:36 +02:00
|
|
|
/*
|
|
|
|
* TLB flushing operations for SH with an MMU.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1999 Niibe Yutaka
|
|
|
|
* Copyright (C) 2003 Paul Mundt
|
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
|
|
* License. See the file "COPYING" in the main directory of this archive
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <asm/mmu_context.h>
|
|
|
|
#include <asm/tlbflush.h>
|
|
|
|
|
|
|
|
void flush_tlb_page(struct vm_area_struct *vma, unsigned long page)
|
|
|
|
{
|
2006-09-27 11:33:49 +02:00
|
|
|
if (vma->vm_mm && vma->vm_mm->context.id != NO_CONTEXT) {
|
2006-09-27 08:13:36 +02:00
|
|
|
unsigned long flags;
|
|
|
|
unsigned long asid;
|
|
|
|
unsigned long saved_asid = MMU_NO_ASID;
|
|
|
|
|
2006-09-27 11:33:49 +02:00
|
|
|
asid = vma->vm_mm->context.id & MMU_CONTEXT_ASID_MASK;
|
2006-09-27 08:13:36 +02:00
|
|
|
page &= PAGE_MASK;
|
|
|
|
|
|
|
|
local_irq_save(flags);
|
|
|
|
if (vma->vm_mm != current->mm) {
|
|
|
|
saved_asid = get_asid();
|
|
|
|
set_asid(asid);
|
|
|
|
}
|
|
|
|
__flush_tlb_page(asid, page);
|
|
|
|
if (saved_asid != MMU_NO_ASID)
|
|
|
|
set_asid(saved_asid);
|
|
|
|
local_irq_restore(flags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
|
|
|
|
unsigned long end)
|
|
|
|
{
|
|
|
|
struct mm_struct *mm = vma->vm_mm;
|
|
|
|
|
2006-09-27 11:33:49 +02:00
|
|
|
if (mm->context.id != NO_CONTEXT) {
|
2006-09-27 08:13:36 +02:00
|
|
|
unsigned long flags;
|
|
|
|
int size;
|
|
|
|
|
|
|
|
local_irq_save(flags);
|
|
|
|
size = (end - start + (PAGE_SIZE - 1)) >> PAGE_SHIFT;
|
|
|
|
if (size > (MMU_NTLB_ENTRIES/4)) { /* Too many TLB to flush */
|
2006-09-27 11:33:49 +02:00
|
|
|
mm->context.id = NO_CONTEXT;
|
2006-09-27 08:13:36 +02:00
|
|
|
if (mm == current->mm)
|
|
|
|
activate_context(mm);
|
|
|
|
} else {
|
2006-09-27 11:33:49 +02:00
|
|
|
unsigned long asid;
|
2006-09-27 08:13:36 +02:00
|
|
|
unsigned long saved_asid = MMU_NO_ASID;
|
|
|
|
|
2006-09-27 11:33:49 +02:00
|
|
|
asid = mm->context.id & MMU_CONTEXT_ASID_MASK;
|
2006-09-27 08:13:36 +02:00
|
|
|
start &= PAGE_MASK;
|
|
|
|
end += (PAGE_SIZE - 1);
|
|
|
|
end &= PAGE_MASK;
|
|
|
|
if (mm != current->mm) {
|
|
|
|
saved_asid = get_asid();
|
|
|
|
set_asid(asid);
|
|
|
|
}
|
|
|
|
while (start < end) {
|
|
|
|
__flush_tlb_page(asid, start);
|
|
|
|
start += PAGE_SIZE;
|
|
|
|
}
|
|
|
|
if (saved_asid != MMU_NO_ASID)
|
|
|
|
set_asid(saved_asid);
|
|
|
|
}
|
|
|
|
local_irq_restore(flags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void flush_tlb_kernel_range(unsigned long start, unsigned long end)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
int size;
|
|
|
|
|
|
|
|
local_irq_save(flags);
|
|
|
|
size = (end - start + (PAGE_SIZE - 1)) >> PAGE_SHIFT;
|
|
|
|
if (size > (MMU_NTLB_ENTRIES/4)) { /* Too many TLB to flush */
|
|
|
|
flush_tlb_all();
|
|
|
|
} else {
|
2006-09-27 11:33:49 +02:00
|
|
|
unsigned long asid;
|
2006-09-27 08:13:36 +02:00
|
|
|
unsigned long saved_asid = get_asid();
|
|
|
|
|
2006-09-27 11:33:49 +02:00
|
|
|
asid = init_mm.context.id & MMU_CONTEXT_ASID_MASK;
|
2006-09-27 08:13:36 +02:00
|
|
|
start &= PAGE_MASK;
|
|
|
|
end += (PAGE_SIZE - 1);
|
|
|
|
end &= PAGE_MASK;
|
|
|
|
set_asid(asid);
|
|
|
|
while (start < end) {
|
|
|
|
__flush_tlb_page(asid, start);
|
|
|
|
start += PAGE_SIZE;
|
|
|
|
}
|
|
|
|
set_asid(saved_asid);
|
|
|
|
}
|
|
|
|
local_irq_restore(flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
void flush_tlb_mm(struct mm_struct *mm)
|
|
|
|
{
|
|
|
|
/* Invalidate all TLB of this process. */
|
|
|
|
/* Instead of invalidating each TLB, we get new MMU context. */
|
2006-09-27 11:33:49 +02:00
|
|
|
if (mm->context.id != NO_CONTEXT) {
|
2006-09-27 08:13:36 +02:00
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
local_irq_save(flags);
|
2006-09-27 11:33:49 +02:00
|
|
|
mm->context.id = NO_CONTEXT;
|
2006-09-27 08:13:36 +02:00
|
|
|
if (mm == current->mm)
|
|
|
|
activate_context(mm);
|
|
|
|
local_irq_restore(flags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void flush_tlb_all(void)
|
|
|
|
{
|
|
|
|
unsigned long flags, status;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Flush all the TLB.
|
|
|
|
*
|
|
|
|
* Write to the MMU control register's bit:
|
|
|
|
* TF-bit for SH-3, TI-bit for SH-4.
|
|
|
|
* It's same position, bit #2.
|
|
|
|
*/
|
|
|
|
local_irq_save(flags);
|
|
|
|
status = ctrl_inl(MMUCR);
|
|
|
|
status |= 0x04;
|
|
|
|
ctrl_outl(status, MMUCR);
|
|
|
|
ctrl_barrier();
|
|
|
|
local_irq_restore(flags);
|
|
|
|
}
|