Skip to content

Commit c653bd0

Browse files
committed
MIPS: mm: Define activate_mm() using switch_mm()
MIPS has separate definitions of activate_mm() & switch_mm() which are identical apart from switch_mm() checking that the ASID is valid before acquiring a new one. We know that when activate_mm() is called cpu_context(X, mm) will be zero, and this will never be considered a valid ASID because we never allow the ASID version number to be zero, instead beginning with version 1 using asid_first_version(). Therefore switch_mm() will always allocate a new ASID when called for a new task, meaning that it will behave identically to activate_mm(). Take advantage of this to remove the duplication & define activate_mm() using switch_mm() just like many other architectures do. Signed-off-by: Paul Burton <paul.burton@mips.com> Cc: linux-mips@vger.kernel.org
1 parent ce680c8 commit c653bd0

File tree

1 file changed

+1
-27
lines changed

1 file changed

+1
-27
lines changed

arch/mips/include/asm/mmu_context.h

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -166,35 +166,9 @@ static inline void destroy_context(struct mm_struct *mm)
166166
dsemul_mm_cleanup(mm);
167167
}
168168

169+
#define activate_mm(prev, next) switch_mm(prev, next, current)
169170
#define deactivate_mm(tsk, mm) do { } while (0)
170171

171-
/*
172-
* After we have set current->mm to a new value, this activates
173-
* the context for the new mm so we see the new mappings.
174-
*/
175-
static inline void
176-
activate_mm(struct mm_struct *prev, struct mm_struct *next)
177-
{
178-
unsigned long flags;
179-
unsigned int cpu = smp_processor_id();
180-
181-
local_irq_save(flags);
182-
183-
htw_stop();
184-
/* Unconditionally get a new ASID. */
185-
get_new_mmu_context(next, cpu);
186-
187-
write_c0_entryhi(cpu_asid(cpu, next));
188-
TLBMISS_HANDLER_SETUP_PGD(next->pgd);
189-
190-
/* mark mmu ownership change */
191-
cpumask_clear_cpu(cpu, mm_cpumask(prev));
192-
cpumask_set_cpu(cpu, mm_cpumask(next));
193-
htw_start();
194-
195-
local_irq_restore(flags);
196-
}
197-
198172
/*
199173
* If mm is currently active_mm, we can't really drop it. Instead,
200174
* we will get a new one for it.

0 commit comments

Comments
 (0)