Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) // Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4) #include <linux/bitops.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <asm/asid.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <asm/mmu_context.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <asm/smp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <asm/tlbflush.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) static DEFINE_PER_CPU(atomic64_t, active_asids);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) static DEFINE_PER_CPU(u64, reserved_asids);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) struct asid_info asid_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) void check_and_switch_context(struct mm_struct *mm, unsigned int cpu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 	asid_check_context(&asid_info, &mm->context.asid, cpu, mm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) static void asid_flush_cpu_ctxt(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 	local_tlb_invalid_all();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) static int asids_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	BUG_ON(((1 << CONFIG_CPU_ASID_BITS) - 1) <= num_possible_cpus());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	if (asid_allocator_init(&asid_info, CONFIG_CPU_ASID_BITS, 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 				asid_flush_cpu_ctxt))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 		panic("Unable to initialize ASID allocator for %lu ASIDs\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 		      NUM_ASIDS(&asid_info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	asid_info.active = &active_asids;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	asid_info.reserved = &reserved_asids;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	pr_info("ASID allocator initialised with %lu entries\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 		NUM_CTXT_ASIDS(&asid_info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) early_initcall(asids_init);