Skip to content

Commit e921050

Browse files
sm-scpalmer-dabbelt
authored andcommitted
Revert "riscv: mm: notify remote harts about mmu cache updates"
This reverts the remaining bits of commit 4bd1d80 ("riscv: mm: notify remote harts harts about mmu cache updates"). According to bug reports, suggested approach to fix stale TLB entries is not sufficient. It needs to be replaced by a more robust solution. Fixes: 4bd1d80 ("riscv: mm: notify remote harts about mmu cache updates") Reported-by: Zong Li <[email protected]> Reported-by: Lad Prabhakar <[email protected]> Signed-off-by: Sergey Matyukevich <[email protected]> Cc: [email protected] Reviewed-by: Guo Ren <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 1b929c0 commit e921050

File tree

4 files changed

+17
-41
lines changed

4 files changed

+17
-41
lines changed

arch/riscv/include/asm/mmu.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ typedef struct {
1919
#ifdef CONFIG_SMP
2020
/* A local icache flush is needed before user execution can resume. */
2121
cpumask_t icache_stale_mask;
22-
/* A local tlb flush is needed before user execution can resume. */
23-
cpumask_t tlb_stale_mask;
2422
#endif
2523
} mm_context_t;
2624

arch/riscv/include/asm/tlbflush.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,6 @@ static inline void local_flush_tlb_page(unsigned long addr)
2222
{
2323
ALT_FLUSH_TLB_PAGE(__asm__ __volatile__ ("sfence.vma %0" : : "r" (addr) : "memory"));
2424
}
25-
26-
static inline void local_flush_tlb_all_asid(unsigned long asid)
27-
{
28-
__asm__ __volatile__ ("sfence.vma x0, %0"
29-
:
30-
: "r" (asid)
31-
: "memory");
32-
}
33-
34-
static inline void local_flush_tlb_page_asid(unsigned long addr,
35-
unsigned long asid)
36-
{
37-
__asm__ __volatile__ ("sfence.vma %0, %1"
38-
:
39-
: "r" (addr), "r" (asid)
40-
: "memory");
41-
}
42-
4325
#else /* CONFIG_MMU */
4426
#define local_flush_tlb_all() do { } while (0)
4527
#define local_flush_tlb_page(addr) do { } while (0)

arch/riscv/mm/context.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -196,16 +196,6 @@ static void set_mm_asid(struct mm_struct *mm, unsigned int cpu)
196196

197197
if (need_flush_tlb)
198198
local_flush_tlb_all();
199-
#ifdef CONFIG_SMP
200-
else {
201-
cpumask_t *mask = &mm->context.tlb_stale_mask;
202-
203-
if (cpumask_test_cpu(cpu, mask)) {
204-
cpumask_clear_cpu(cpu, mask);
205-
local_flush_tlb_all_asid(cntx & asid_mask);
206-
}
207-
}
208-
#endif
209199
}
210200

211201
static void set_mm_noasid(struct mm_struct *mm)

arch/riscv/mm/tlbflush.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,23 @@
55
#include <linux/sched.h>
66
#include <asm/sbi.h>
77
#include <asm/mmu_context.h>
8-
#include <asm/tlbflush.h>
8+
9+
static inline void local_flush_tlb_all_asid(unsigned long asid)
10+
{
11+
__asm__ __volatile__ ("sfence.vma x0, %0"
12+
:
13+
: "r" (asid)
14+
: "memory");
15+
}
16+
17+
static inline void local_flush_tlb_page_asid(unsigned long addr,
18+
unsigned long asid)
19+
{
20+
__asm__ __volatile__ ("sfence.vma %0, %1"
21+
:
22+
: "r" (addr), "r" (asid)
23+
: "memory");
24+
}
925

1026
void flush_tlb_all(void)
1127
{
@@ -15,7 +31,6 @@ void flush_tlb_all(void)
1531
static void __sbi_tlb_flush_range(struct mm_struct *mm, unsigned long start,
1632
unsigned long size, unsigned long stride)
1733
{
18-
struct cpumask *pmask = &mm->context.tlb_stale_mask;
1934
struct cpumask *cmask = mm_cpumask(mm);
2035
unsigned int cpuid;
2136
bool broadcast;
@@ -29,15 +44,6 @@ static void __sbi_tlb_flush_range(struct mm_struct *mm, unsigned long start,
2944
if (static_branch_unlikely(&use_asid_allocator)) {
3045
unsigned long asid = atomic_long_read(&mm->context.id);
3146

32-
/*
33-
* TLB will be immediately flushed on harts concurrently
34-
* executing this MM context. TLB flush on other harts
35-
* is deferred until this MM context migrates there.
36-
*/
37-
cpumask_setall(pmask);
38-
cpumask_clear_cpu(cpuid, pmask);
39-
cpumask_andnot(pmask, pmask, cmask);
40-
4147
if (broadcast) {
4248
sbi_remote_sfence_vma_asid(cmask, start, size, asid);
4349
} else if (size <= stride) {

0 commit comments

Comments
 (0)