| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2009 Chen Liqin <liqin.chen@sunplusct.com> |
|---|
| 3 | 4 | * 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 | 5 | */ |
|---|
| 14 | 6 | |
|---|
| 15 | 7 | #ifndef _ASM_RISCV_TLBFLUSH_H |
|---|
| 16 | 8 | #define _ASM_RISCV_TLBFLUSH_H |
|---|
| 17 | 9 | |
|---|
| 18 | 10 | #include <linux/mm_types.h> |
|---|
| 11 | +#include <asm/smp.h> |
|---|
| 19 | 12 | |
|---|
| 20 | | -/* |
|---|
| 21 | | - * Flush entire local TLB. 'sfence.vma' implicitly fences with the instruction |
|---|
| 22 | | - * cache as well, so a 'fence.i' is not necessary. |
|---|
| 23 | | - */ |
|---|
| 13 | +#ifdef CONFIG_MMU |
|---|
| 24 | 14 | static inline void local_flush_tlb_all(void) |
|---|
| 25 | 15 | { |
|---|
| 26 | 16 | __asm__ __volatile__ ("sfence.vma" : : : "memory"); |
|---|
| .. | .. |
|---|
| 31 | 21 | { |
|---|
| 32 | 22 | __asm__ __volatile__ ("sfence.vma %0" : : "r" (addr) : "memory"); |
|---|
| 33 | 23 | } |
|---|
| 24 | +#else /* CONFIG_MMU */ |
|---|
| 25 | +#define local_flush_tlb_all() do { } while (0) |
|---|
| 26 | +#define local_flush_tlb_page(addr) do { } while (0) |
|---|
| 27 | +#endif /* CONFIG_MMU */ |
|---|
| 34 | 28 | |
|---|
| 35 | | -#ifndef CONFIG_SMP |
|---|
| 29 | +#if defined(CONFIG_SMP) && defined(CONFIG_MMU) |
|---|
| 30 | +void flush_tlb_all(void); |
|---|
| 31 | +void flush_tlb_mm(struct mm_struct *mm); |
|---|
| 32 | +void flush_tlb_page(struct vm_area_struct *vma, unsigned long addr); |
|---|
| 33 | +void flush_tlb_range(struct vm_area_struct *vma, unsigned long start, |
|---|
| 34 | + unsigned long end); |
|---|
| 35 | +#else /* CONFIG_SMP && CONFIG_MMU */ |
|---|
| 36 | 36 | |
|---|
| 37 | 37 | #define flush_tlb_all() local_flush_tlb_all() |
|---|
| 38 | 38 | #define flush_tlb_page(vma, addr) local_flush_tlb_page(addr) |
|---|
| .. | .. |
|---|
| 44 | 44 | } |
|---|
| 45 | 45 | |
|---|
| 46 | 46 | #define flush_tlb_mm(mm) flush_tlb_all() |
|---|
| 47 | | - |
|---|
| 48 | | -#else /* CONFIG_SMP */ |
|---|
| 49 | | - |
|---|
| 50 | | -#include <asm/sbi.h> |
|---|
| 51 | | - |
|---|
| 52 | | -#define flush_tlb_all() sbi_remote_sfence_vma(NULL, 0, -1) |
|---|
| 53 | | -#define flush_tlb_page(vma, addr) flush_tlb_range(vma, addr, 0) |
|---|
| 54 | | -#define flush_tlb_range(vma, start, end) \ |
|---|
| 55 | | - sbi_remote_sfence_vma(mm_cpumask((vma)->vm_mm)->bits, \ |
|---|
| 56 | | - start, (end) - (start)) |
|---|
| 57 | | -#define flush_tlb_mm(mm) \ |
|---|
| 58 | | - sbi_remote_sfence_vma(mm_cpumask(mm)->bits, 0, -1) |
|---|
| 59 | | - |
|---|
| 60 | | -#endif /* CONFIG_SMP */ |
|---|
| 47 | +#endif /* !CONFIG_SMP || !CONFIG_MMU */ |
|---|
| 61 | 48 | |
|---|
| 62 | 49 | /* Flush a range of kernel pages */ |
|---|
| 63 | 50 | static inline void flush_tlb_kernel_range(unsigned long start, |
|---|