.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * OpenRISC tlb.c |
---|
3 | 4 | * |
---|
.. | .. |
---|
9 | 10 | * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com> |
---|
10 | 11 | * Copyright (C) 2010-2011 Julius Baxter <julius.baxter@orsoc.se> |
---|
11 | 12 | * 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. |
---|
17 | 13 | */ |
---|
18 | 14 | |
---|
19 | 15 | #include <linux/sched.h> |
---|
.. | .. |
---|
26 | 22 | #include <linux/mm.h> |
---|
27 | 23 | #include <linux/init.h> |
---|
28 | 24 | |
---|
29 | | -#include <asm/segment.h> |
---|
30 | 25 | #include <asm/tlbflush.h> |
---|
31 | | -#include <asm/pgtable.h> |
---|
32 | 26 | #include <asm/mmu_context.h> |
---|
33 | 27 | #include <asm/spr_defs.h> |
---|
34 | 28 | |
---|
.. | .. |
---|
143 | 137 | void switch_mm(struct mm_struct *prev, struct mm_struct *next, |
---|
144 | 138 | struct task_struct *next_tsk) |
---|
145 | 139 | { |
---|
| 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 | + |
---|
146 | 150 | /* remember the pgd for the fault handlers |
---|
147 | 151 | * this is similar to the pgd register in some other CPU's. |
---|
148 | 152 | * we need our own copy of it because current and active_mm |
---|
149 | 153 | * might be invalid at points where we still need to derefer |
---|
150 | 154 | * the pgd. |
---|
151 | 155 | */ |
---|
152 | | - current_pgd[smp_processor_id()] = next->pgd; |
---|
| 156 | + current_pgd[cpu] = next->pgd; |
---|
153 | 157 | |
---|
154 | 158 | /* We don't have context support implemented, so flush all |
---|
155 | 159 | * entries belonging to previous map |
---|
156 | 160 | */ |
---|
157 | | - |
---|
158 | | - if (prev != next) |
---|
159 | | - local_flush_tlb_mm(prev); |
---|
160 | | - |
---|
| 161 | + local_flush_tlb_mm(prev); |
---|
161 | 162 | } |
---|
162 | 163 | |
---|
163 | 164 | /* |
---|