forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-09-20 a36159eec6ca17402b0e146b86efaf76568dc353
kernel/arch/openrisc/mm/tlb.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * OpenRISC tlb.c
34 *
....@@ -9,11 +10,6 @@
910 * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>
1011 * Copyright (C) 2010-2011 Julius Baxter <julius.baxter@orsoc.se>
1112 * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
12
- *
13
- * This program is free software; you can redistribute it and/or
14
- * modify it under the terms of the GNU General Public License
15
- * as published by the Free Software Foundation; either version
16
- * 2 of the License, or (at your option) any later version.
1713 */
1814
1915 #include <linux/sched.h>
....@@ -26,9 +22,7 @@
2622 #include <linux/mm.h>
2723 #include <linux/init.h>
2824
29
-#include <asm/segment.h>
3025 #include <asm/tlbflush.h>
31
-#include <asm/pgtable.h>
3226 #include <asm/mmu_context.h>
3327 #include <asm/spr_defs.h>
3428
....@@ -143,21 +137,28 @@
143137 void switch_mm(struct mm_struct *prev, struct mm_struct *next,
144138 struct task_struct *next_tsk)
145139 {
140
+ unsigned int cpu;
141
+
142
+ if (unlikely(prev == next))
143
+ return;
144
+
145
+ cpu = smp_processor_id();
146
+
147
+ cpumask_clear_cpu(cpu, mm_cpumask(prev));
148
+ cpumask_set_cpu(cpu, mm_cpumask(next));
149
+
146150 /* remember the pgd for the fault handlers
147151 * this is similar to the pgd register in some other CPU's.
148152 * we need our own copy of it because current and active_mm
149153 * might be invalid at points where we still need to derefer
150154 * the pgd.
151155 */
152
- current_pgd[smp_processor_id()] = next->pgd;
156
+ current_pgd[cpu] = next->pgd;
153157
154158 /* We don't have context support implemented, so flush all
155159 * entries belonging to previous map
156160 */
157
-
158
- if (prev != next)
159
- local_flush_tlb_mm(prev);
160
-
161
+ local_flush_tlb_mm(prev);
161162 }
162163
163164 /*