1 /* arch/sparc64/mm/tlb.c
3 * Copyright (C) 2004 David S. Miller <davem@redhat.com>
6 #include <linux/kernel.h>
7 #include <linux/init.h>
8 #include <linux/percpu.h>
10 #include <linux/swap.h>
12 #include <asm/pgtable.h>
13 #include <asm/pgalloc.h>
14 #include <asm/tlbflush.h>
15 #include <asm/cacheflush.h>
16 #include <asm/mmu_context.h>
19 /* Heavily inspired by the ppc64 code. */
21 DEFINE_PER_CPU(struct mmu_gather, mmu_gathers) = { 0, };
23 void flush_tlb_pending(void)
25 struct mmu_gather *mp = &__get_cpu_var(mmu_gathers);
30 if (CTX_VALID(mp->mm->context)) {
32 smp_flush_tlb_pending(mp->mm, mp->tlb_nr,
35 __flush_tlb_pending(CTX_HWBITS(mp->mm->context),
36 mp->tlb_nr, &mp->vaddrs[0]);
43 void tlb_batch_add(struct mm_struct *mm, unsigned long vaddr, pte_t *ptep, pte_t orig)
45 struct mmu_gather *mp = &__get_cpu_var(mmu_gathers);
52 if (tlb_type != hypervisor &&
54 unsigned long paddr, pfn = pte_pfn(orig);
55 struct address_space *mapping;
61 page = pfn_to_page(pfn);
62 if (PageReserved(page))
65 /* A real file page? */
66 mapping = page_mapping(page);
70 paddr = (unsigned long) page_address(page);
71 if ((paddr ^ vaddr) & (1 << 13))
72 flush_dcache_page_all(mm, page);
82 if (unlikely(nr != 0 && mm != mp->mm)) {
90 mp->vaddrs[nr] = vaddr;
92 if (nr >= TLB_BATCH_NR)