From 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5 Mon Sep 17 00:00:00 2001 From: hc <hc@nodka.com> Date: Tue, 22 Oct 2024 10:36:11 +0000 Subject: [PATCH] 修改4g拨号为QMI,需要在系统里后台执行quectel-CM --- kernel/arch/xtensa/mm/highmem.c | 50 +++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 43 insertions(+), 7 deletions(-) diff --git a/kernel/arch/xtensa/mm/highmem.c b/kernel/arch/xtensa/mm/highmem.c index 0735ca5..673196f 100644 --- a/kernel/arch/xtensa/mm/highmem.c +++ b/kernel/arch/xtensa/mm/highmem.c @@ -12,6 +12,8 @@ #include <linux/highmem.h> #include <asm/tlbflush.h> +static pte_t *kmap_pte; + #if DCACHE_WAY_SIZE > PAGE_SIZE unsigned int last_pkmap_nr_arr[DCACHE_N_COLORS]; wait_queue_head_t pkmap_map_wait_arr[DCACHE_N_COLORS]; @@ -31,25 +33,59 @@ static inline enum fixed_addresses kmap_idx(int type, unsigned long color) { - return (type + KM_MAX_IDX * smp_processor_id()) * DCACHE_N_COLORS + + return (type + KM_TYPE_NR * smp_processor_id()) * DCACHE_N_COLORS + color; } -enum fixed_addresses kmap_local_map_idx(int type, unsigned long pfn) +void *kmap_atomic_high_prot(struct page *page, pgprot_t prot) { - return kmap_idx(type, DCACHE_ALIAS(pfn << PAGE_SHIFT)); -} + enum fixed_addresses idx; + unsigned long vaddr; -enum fixed_addresses kmap_local_unmap_idx(int type, unsigned long addr) -{ - return kmap_idx(type, DCACHE_ALIAS(addr)); + idx = kmap_idx(kmap_atomic_idx_push(), + DCACHE_ALIAS(page_to_phys(page))); + vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx); +#ifdef CONFIG_DEBUG_HIGHMEM + BUG_ON(!pte_none(*(kmap_pte + idx))); +#endif + set_pte(kmap_pte + idx, mk_pte(page, prot)); + + return (void *)vaddr; } +EXPORT_SYMBOL(kmap_atomic_high_prot); + +void kunmap_atomic_high(void *kvaddr) +{ + if (kvaddr >= (void *)FIXADDR_START && + kvaddr < (void *)FIXADDR_TOP) { + int idx = kmap_idx(kmap_atomic_idx(), + DCACHE_ALIAS((unsigned long)kvaddr)); + + /* + * Force other mappings to Oops if they'll try to access this + * pte without first remap it. Keeping stale mappings around + * is a bad idea also, in case the page changes cacheability + * attributes or becomes a protected page in a hypervisor. + */ + pte_clear(&init_mm, kvaddr, kmap_pte + idx); + local_flush_tlb_kernel_range((unsigned long)kvaddr, + (unsigned long)kvaddr + PAGE_SIZE); + + kmap_atomic_idx_pop(); + } +} +EXPORT_SYMBOL(kunmap_atomic_high); void __init kmap_init(void) { + unsigned long kmap_vstart; + /* Check if this memory layout is broken because PKMAP overlaps * page table. */ BUILD_BUG_ON(PKMAP_BASE < TLBTEMP_BASE_1 + TLBTEMP_SIZE); + /* cache the first kmap pte */ + kmap_vstart = __fix_to_virt(FIX_KMAP_BEGIN); + kmap_pte = virt_to_kpte(kmap_vstart); kmap_waitqueues_init(); } -- Gitblit v1.6.2