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>
11
#include <linux/preempt.h>
13
#include <asm/pgtable.h>
14
#include <asm/pgalloc.h>
15
#include <asm/tlbflush.h>
16
#include <asm/cacheflush.h>
17
#include <asm/mmu_context.h>
20
/* Heavily inspired by the ppc64 code. */
22
static DEFINE_PER_CPU(struct tlb_batch, tlb_batch);
24
void flush_tlb_pending(void)
26
struct tlb_batch *tb = &get_cpu_var(tlb_batch);
31
if (CTX_VALID(tb->mm->context)) {
33
smp_flush_tlb_pending(tb->mm, tb->tlb_nr,
36
__flush_tlb_pending(CTX_HWBITS(tb->mm->context),
37
tb->tlb_nr, &tb->vaddrs[0]);
43
put_cpu_var(tlb_batch);
46
void tlb_batch_add(struct mm_struct *mm, unsigned long vaddr,
47
pte_t *ptep, pte_t orig, int fullmm)
49
struct tlb_batch *tb = &get_cpu_var(tlb_batch);
56
if (tlb_type != hypervisor &&
58
unsigned long paddr, pfn = pte_pfn(orig);
59
struct address_space *mapping;
65
page = pfn_to_page(pfn);
66
if (PageReserved(page))
69
/* A real file page? */
70
mapping = page_mapping(page);
74
paddr = (unsigned long) page_address(page);
75
if ((paddr ^ vaddr) & (1 << 13))
76
flush_dcache_page_all(mm, page);
82
put_cpu_var(tlb_batch);
88
if (unlikely(nr != 0 && mm != tb->mm)) {
96
tb->vaddrs[nr] = vaddr;
98
if (nr >= TLB_BATCH_NR)
101
put_cpu_var(tlb_batch);