Skip to content

Commit c9b2a3d

Browse files
committed
MIPS: mm: Consolidate drop_mmu_context() has-ASID checks
If an mm does not have an ASID on the local CPU then drop_mmu_context() is always redundant, since there's no context to "drop". Various callers of drop_mmu_context() check whether the mm has been allocated an ASID before making the call. Move that check into drop_mmu_context() and remove it from callers to simplify them. Signed-off-by: Paul Burton <paul.burton@mips.com> Cc: linux-mips@vger.kernel.org
1 parent 67741ba commit c9b2a3d

File tree

5 files changed

+10
-22
lines changed

5 files changed

+10
-22
lines changed

arch/mips/include/asm/mmu_context.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,9 @@ drop_mmu_context(struct mm_struct *mm)
186186
local_irq_save(flags);
187187

188188
cpu = smp_processor_id();
189-
if (cpumask_test_cpu(cpu, mm_cpumask(mm))) {
189+
if (!cpu_context(cpu, mm)) {
190+
/* no-op */
191+
} else if (cpumask_test_cpu(cpu, mm_cpumask(mm))) {
190192
htw_stop();
191193
get_new_mmu_context(mm);
192194
write_c0_entryhi(cpu_asid(cpu, mm));

arch/mips/mm/c-r4k.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -697,10 +697,7 @@ static inline void local_r4k_flush_cache_page(void *args)
697697
}
698698
if (exec) {
699699
if (vaddr && cpu_has_vtag_icache && mm == current->active_mm) {
700-
int cpu = smp_processor_id();
701-
702-
if (cpu_context(cpu, mm) != 0)
703-
drop_mmu_context(mm);
700+
drop_mmu_context(mm);
704701
} else
705702
vaddr ? r4k_blast_icache_page(addr) :
706703
r4k_blast_icache_user_page(addr);

arch/mips/mm/tlb-r3k.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ void local_flush_tlb_all(void)
6969

7070
void local_flush_tlb_mm(struct mm_struct *mm)
7171
{
72+
#ifdef DEBUG_TLB
7273
int cpu = smp_processor_id();
7374

74-
if (cpu_context(cpu, mm) != 0) {
75-
#ifdef DEBUG_TLB
75+
if (cpu_context(cpu, mm) != 0)
7676
printk("[tlbmm<%lu>]", (unsigned long)cpu_context(cpu, mm));
7777
#endif
78-
drop_mmu_context(mm);
79-
}
78+
79+
drop_mmu_context(mm);
8080
}
8181

8282
void local_flush_tlb_range(struct vm_area_struct *vma, unsigned long start,

arch/mips/mm/tlb-r4k.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,8 @@ EXPORT_SYMBOL(local_flush_tlb_all);
108108
these entries, we just bump the asid. */
109109
void local_flush_tlb_mm(struct mm_struct *mm)
110110
{
111-
int cpu;
112-
113111
preempt_disable();
114-
115-
cpu = smp_processor_id();
116-
117-
if (cpu_context(cpu, mm) != 0) {
118-
drop_mmu_context(mm);
119-
}
120-
112+
drop_mmu_context(mm);
121113
preempt_enable();
122114
}
123115

arch/mips/mm/tlb-r8k.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,7 @@ void local_flush_tlb_all(void)
5252

5353
void local_flush_tlb_mm(struct mm_struct *mm)
5454
{
55-
int cpu = smp_processor_id();
56-
57-
if (cpu_context(cpu, mm) != 0)
58-
drop_mmu_context(mm);
55+
drop_mmu_context(mm);
5956
}
6057

6158
void local_flush_tlb_range(struct vm_area_struct *vma, unsigned long start,

0 commit comments

Comments
 (0)