File: tlb.c

package info (click to toggle)
linux 4.19.20-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 954,852 kB
  • sloc: ansic: 16,749,828; asm: 271,286; makefile: 38,257; sh: 32,808; perl: 27,671; python: 21,022; cpp: 5,063; yacc: 4,648; lex: 2,585; awk: 1,385; ruby: 25; sed: 5
file content (50 lines) | stat: -rw-r--r-- 1,359 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// SPDX-License-Identifier: GPL-2.0
// Copyright (C) 2005-2017 Andes Technology Corporation

#include <linux/spinlock_types.h>
#include <linux/mm.h>
#include <linux/sched.h>
#include <asm/nds32.h>
#include <nds32_intrinsic.h>

unsigned int cpu_last_cid = { TLB_MISC_mskCID + (2 << TLB_MISC_offCID) };

DEFINE_SPINLOCK(cid_lock);

void local_flush_tlb_range(struct vm_area_struct *vma,
			   unsigned long start, unsigned long end)
{
	unsigned long flags, ocid, ncid;

	if ((end - start) > 0x400000) {
		__nds32__tlbop_flua();
		__nds32__isb();
		return;
	}

	spin_lock_irqsave(&cid_lock, flags);
	ocid = __nds32__mfsr(NDS32_SR_TLB_MISC);
	ncid = (ocid & ~TLB_MISC_mskCID) | vma->vm_mm->context.id;
	__nds32__mtsr_dsb(ncid, NDS32_SR_TLB_MISC);
	while (start < end) {
		__nds32__tlbop_inv(start);
		__nds32__isb();
		start += PAGE_SIZE;
	}
	__nds32__mtsr_dsb(ocid, NDS32_SR_TLB_MISC);
	spin_unlock_irqrestore(&cid_lock, flags);
}

void local_flush_tlb_page(struct vm_area_struct *vma, unsigned long addr)
{
	unsigned long flags, ocid, ncid;

	spin_lock_irqsave(&cid_lock, flags);
	ocid = __nds32__mfsr(NDS32_SR_TLB_MISC);
	ncid = (ocid & ~TLB_MISC_mskCID) | vma->vm_mm->context.id;
	__nds32__mtsr_dsb(ncid, NDS32_SR_TLB_MISC);
	__nds32__tlbop_inv(addr);
	__nds32__isb();
	__nds32__mtsr_dsb(ocid, NDS32_SR_TLB_MISC);
	spin_unlock_irqrestore(&cid_lock, flags);
}