1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (C) 2005-2017 Andes Technology Corporation
4 #ifndef __ASM_NDS32_MMU_CONTEXT_H
5 #define __ASM_NDS32_MMU_CONTEXT_H
7 #include <linux/spinlock.h>
8 #include <asm/tlbflush.h>
9 #include <asm/proc-fns.h>
10 #include <asm-generic/mm_hooks.h>
13 init_new_context(struct task_struct *tsk, struct mm_struct *mm)
19 #define destroy_context(mm) do { } while(0)
22 extern spinlock_t cid_lock;
23 extern unsigned int cpu_last_cid;
25 static inline void __new_context(struct mm_struct *mm)
30 spin_lock_irqsave(&cid_lock, flags);
32 cpu_last_cid += 1 << TLB_MISC_offCID;
33 if (cpu_last_cid == 0)
34 cpu_last_cid = 1 << TLB_MISC_offCID << CID_BITS;
36 if ((cid & TLB_MISC_mskCID) == 0)
38 spin_unlock_irqrestore(&cid_lock, flags);
43 static inline void check_context(struct mm_struct *mm)
46 ((mm->context.id ^ cpu_last_cid) >> TLB_MISC_offCID >> CID_BITS))
50 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
54 static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
55 struct task_struct *tsk)
57 unsigned int cpu = smp_processor_id();
59 if (!cpumask_test_and_set_cpu(cpu, mm_cpumask(next)) || prev != next) {
65 #define deactivate_mm(tsk,mm) do { } while (0)
66 #define activate_mm(prev,next) switch_mm(prev, next, NULL)