spi: efm32: Convert to use GPIO descriptors
[linux/fpc-iii.git] / arch / csky / mm / context.c
blob0d95bdd93846e26041663c3693065462f7a010ce
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
4 #include <linux/bitops.h>
5 #include <linux/sched.h>
6 #include <linux/slab.h>
7 #include <linux/mm.h>
9 #include <asm/asid.h>
10 #include <asm/mmu_context.h>
11 #include <asm/smp.h>
12 #include <asm/tlbflush.h>
14 static DEFINE_PER_CPU(atomic64_t, active_asids);
15 static DEFINE_PER_CPU(u64, reserved_asids);
17 struct asid_info asid_info;
19 void check_and_switch_context(struct mm_struct *mm, unsigned int cpu)
21 asid_check_context(&asid_info, &mm->context.asid, cpu, mm);
24 static void asid_flush_cpu_ctxt(void)
26 local_tlb_invalid_all();
29 static int asids_init(void)
31 BUG_ON(((1 << CONFIG_CPU_ASID_BITS) - 1) <= num_possible_cpus());
33 if (asid_allocator_init(&asid_info, CONFIG_CPU_ASID_BITS, 1,
34 asid_flush_cpu_ctxt))
35 panic("Unable to initialize ASID allocator for %lu ASIDs\n",
36 NUM_ASIDS(&asid_info));
38 asid_info.active = &active_asids;
39 asid_info.reserved = &reserved_asids;
41 pr_info("ASID allocator initialised with %lu entries\n",
42 NUM_CTXT_ASIDS(&asid_info));
44 return 0;
46 early_initcall(asids_init);