Merge tag 'locking-urgent-2020-12-27' of git://git.kernel.org/pub/scm/linux/kernel...
[linux/fpc-iii.git] / arch / csky / include / asm / mmu_context.h
blobb227d29393a8fc5b92c6ea753d7444f4ea6701f2
1 /* SPDX-License-Identifier: GPL-2.0 */
2 // Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
4 #ifndef __ASM_CSKY_MMU_CONTEXT_H
5 #define __ASM_CSKY_MMU_CONTEXT_H
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>
13 #include <linux/errno.h>
14 #include <linux/sched.h>
15 #include <abi/ckmmu.h>
17 #define TLBMISS_HANDLER_SETUP_PGD(pgd) \
18 setup_pgd(__pa(pgd), false)
20 #define TLBMISS_HANDLER_SETUP_PGD_KERNEL(pgd) \
21 setup_pgd(__pa(pgd), true)
23 #define ASID_MASK ((1 << CONFIG_CPU_ASID_BITS) - 1)
24 #define cpu_asid(mm) (atomic64_read(&mm->context.asid) & ASID_MASK)
26 #define init_new_context(tsk,mm) ({ atomic64_set(&(mm)->context.asid, 0); 0; })
28 void check_and_switch_context(struct mm_struct *mm, unsigned int cpu);
30 static inline void
31 switch_mm(struct mm_struct *prev, struct mm_struct *next,
32 struct task_struct *tsk)
34 unsigned int cpu = smp_processor_id();
36 if (prev != next)
37 check_and_switch_context(next, cpu);
39 TLBMISS_HANDLER_SETUP_PGD(next->pgd);
40 write_mmu_entryhi(next->context.asid.counter);
42 flush_icache_deferred(next);
45 #include <asm-generic/mmu_context.h>
47 #endif /* __ASM_CSKY_MMU_CONTEXT_H */