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>
10 #include <asm/mmu_context.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,
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
));
46 early_initcall(asids_init
);