Merge remote-tracking branches 'asoc/topic/mc13783', 'asoc/topic/msm8916', 'asoc...
[linux-2.6-block.git] / arch / riscv / include / asm / tlbflush.h
CommitLineData
fab957c1
PD
1/*
2 * Copyright (C) 2009 Chen Liqin <liqin.chen@sunplusct.com>
3 * Copyright (C) 2012 Regents of the University of California
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation, version 2.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15#ifndef _ASM_RISCV_TLBFLUSH_H
16#define _ASM_RISCV_TLBFLUSH_H
17
18#ifdef CONFIG_MMU
19
08f051ed
AW
20#include <linux/mm_types.h>
21
c901e45a
PD
22/*
23 * Flush entire local TLB. 'sfence.vma' implicitly fences with the instruction
24 * cache as well, so a 'fence.i' is not necessary.
25 */
fab957c1
PD
26static inline void local_flush_tlb_all(void)
27{
28 __asm__ __volatile__ ("sfence.vma" : : : "memory");
29}
30
31/* Flush one page from local TLB */
32static inline void local_flush_tlb_page(unsigned long addr)
33{
34 __asm__ __volatile__ ("sfence.vma %0" : : "r" (addr) : "memory");
35}
36
37#ifndef CONFIG_SMP
38
39#define flush_tlb_all() local_flush_tlb_all()
40#define flush_tlb_page(vma, addr) local_flush_tlb_page(addr)
41#define flush_tlb_range(vma, start, end) local_flush_tlb_all()
42
43#else /* CONFIG_SMP */
44
45#include <asm/sbi.h>
46
47#define flush_tlb_all() sbi_remote_sfence_vma(0, 0, -1)
48#define flush_tlb_page(vma, addr) flush_tlb_range(vma, addr, 0)
49#define flush_tlb_range(vma, start, end) \
50 sbi_remote_sfence_vma(0, start, (end) - (start))
51
52#endif /* CONFIG_SMP */
53
54/* Flush the TLB entries of the specified mm context */
55static inline void flush_tlb_mm(struct mm_struct *mm)
56{
57 flush_tlb_all();
58}
59
60/* Flush a range of kernel pages */
61static inline void flush_tlb_kernel_range(unsigned long start,
62 unsigned long end)
63{
64 flush_tlb_all();
65}
66
67#endif /* CONFIG_MMU */
68
69#endif /* _ASM_RISCV_TLBFLUSH_H */