• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (C) 2005-2017 Andes Technology Corporation
3 
4 #include <linux/export.h>
5 #include <linux/highmem.h>
6 #include <linux/sched.h>
7 #include <linux/smp.h>
8 #include <linux/interrupt.h>
9 #include <linux/memblock.h>
10 #include <asm/fixmap.h>
11 #include <asm/tlbflush.h>
12 
kmap_atomic_high_prot(struct page * page,pgprot_t prot)13 void *kmap_atomic_high_prot(struct page *page, pgprot_t prot)
14 {
15 	unsigned int idx;
16 	unsigned long vaddr, pte;
17 	int type;
18 	pte_t *ptep;
19 
20 	type = kmap_atomic_idx_push();
21 
22 	idx = type + KM_TYPE_NR * smp_processor_id();
23 	vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
24 	pte = (page_to_pfn(page) << PAGE_SHIFT) | prot;
25 	ptep = pte_offset_kernel(pmd_off_k(vaddr), vaddr);
26 	set_pte(ptep, pte);
27 
28 	__nds32__tlbop_inv(vaddr);
29 	__nds32__mtsr_dsb(vaddr, NDS32_SR_TLB_VPN);
30 	__nds32__tlbop_rwr(pte);
31 	__nds32__isb();
32 	return (void *)vaddr;
33 }
34 EXPORT_SYMBOL(kmap_atomic_high_prot);
35 
kunmap_atomic_high(void * kvaddr)36 void kunmap_atomic_high(void *kvaddr)
37 {
38 	if (kvaddr >= (void *)FIXADDR_START) {
39 		unsigned long vaddr = (unsigned long)kvaddr;
40 		pte_t *ptep;
41 		kmap_atomic_idx_pop();
42 		__nds32__tlbop_inv(vaddr);
43 		__nds32__isb();
44 		ptep = pte_offset_kernel(pmd_off_k(vaddr), vaddr);
45 		set_pte(ptep, 0);
46 	}
47 }
48 EXPORT_SYMBOL(kunmap_atomic_high);
49