1 /* SPDX-License-Identifier: GPL-2.0 */ 2 // Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd. 3 4 #ifndef __ASM_CSKY_MMU_CONTEXT_H 5 #define __ASM_CSKY_MMU_CONTEXT_H 6 7 #include <asm-generic/mm_hooks.h> 8 #include <asm/setup.h> 9 #include <asm/page.h> 10 #include <asm/cacheflush.h> 11 #include <asm/tlbflush.h> 12 13 #include <linux/errno.h> 14 #include <linux/sched.h> 15 #include <abi/ckmmu.h> 16 17 #define ASID_MASK ((1 << CONFIG_CPU_ASID_BITS) - 1) 18 #define cpu_asid(mm) (atomic64_read(&mm->context.asid) & ASID_MASK) 19 20 #define init_new_context(tsk,mm) ({ atomic64_set(&(mm)->context.asid, 0); 0; }) 21 22 void check_and_switch_context(struct mm_struct *mm, unsigned int cpu); 23 24 static inline void 25 switch_mm(struct mm_struct *prev, struct mm_struct *next, 26 struct task_struct *tsk) 27 { 28 unsigned int cpu = smp_processor_id(); 29 30 if (prev != next) 31 check_and_switch_context(next, cpu); 32 33 setup_pgd(next->pgd); 34 write_mmu_entryhi(next->context.asid.counter); 35 36 flush_icache_deferred(next); 37 } 38 39 #include <asm-generic/mmu_context.h> 40 41 #endif /* __ASM_CSKY_MMU_CONTEXT_H */ 42