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-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * PGD allocation/freeing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * Copyright (C) 2012 ARM Ltd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  * Author: Catalin Marinas <catalin.marinas@arm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/gfp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/highmem.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <asm/pgalloc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <asm/page.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <asm/tlbflush.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) static struct kmem_cache *pgd_cache __ro_after_init;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) pgd_t *pgd_alloc(struct mm_struct *mm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 	gfp_t gfp = GFP_PGTABLE_USER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 	if (PGD_SIZE == PAGE_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 		return (pgd_t *)__get_free_page(gfp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 		return kmem_cache_alloc(pgd_cache, gfp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) void pgd_free(struct mm_struct *mm, pgd_t *pgd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 	if (PGD_SIZE == PAGE_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 		free_page((unsigned long)pgd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 		kmem_cache_free(pgd_cache, pgd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) void __init pgtable_cache_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 	if (PGD_SIZE == PAGE_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #ifdef CONFIG_ARM64_PA_BITS_52
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	 * With 52-bit physical addresses, the architecture requires the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	 * top-level table to be aligned to at least 64 bytes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 	BUILD_BUG_ON(PGD_SIZE < 64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 	 * Naturally aligned pgds required by the architecture.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 	pgd_cache = kmem_cache_create("pgd_cache", PGD_SIZE, PGD_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 				      SLAB_PANIC, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) }