Linux Audio

Check our new training course

Embedded Linux training

Mar 10-20, 2025, special US time zones
Register
Loading...
v4.17
 
 1/*
 2 * Hexagon Virtual Machine TLB functions
 3 *
 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
 5 *
 6 * This program is free software; you can redistribute it and/or modify
 7 * it under the terms of the GNU General Public License version 2 and
 8 * only version 2 as published by the Free Software Foundation.
 9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA.
19 */
20
21/*
22 * The Hexagon Virtual Machine conceals the real workings of
23 * the TLB, but there are one or two functions that need to
24 * be instantiated for it, differently from a native build.
25 */
26#include <linux/mm.h>
27#include <linux/sched.h>
28#include <asm/page.h>
29#include <asm/hexagon_vm.h>
30
31/*
32 * Initial VM implementation has only one map active at a time, with
33 * TLB purgings on changes.  So either we're nuking the current map,
34 * or it's a no-op.  This operation is messy on true SMPs where other
35 * processors must be induced to flush the copies in their local TLBs,
36 * but Hexagon thread-based virtual processors share the same MMU.
37 */
38void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
39			unsigned long end)
40{
41	struct mm_struct *mm = vma->vm_mm;
42
43	if (mm->context.ptbase == current->active_mm->context.ptbase)
44		__vmclrmap((void *)start, end - start);
45}
46
47/*
48 * Flush a page from the kernel virtual map - used by highmem
49 */
50void flush_tlb_one(unsigned long vaddr)
51{
52	__vmclrmap((void *)vaddr, PAGE_SIZE);
53}
54
55/*
56 * Flush all TLBs across all CPUs, virtual or real.
57 * A single Hexagon core has 6 thread contexts but
58 * only one TLB.
59 */
60void tlb_flush_all(void)
61{
62	/*  should probably use that fixaddr end or whateve label  */
63	__vmclrmap(0, 0xffff0000);
64}
65
66/*
67 * Flush TLB entries associated with a given mm_struct mapping.
68 */
69void flush_tlb_mm(struct mm_struct *mm)
70{
71	/* Current Virtual Machine has only one map active at a time */
72	if (current->active_mm->context.ptbase == mm->context.ptbase)
73		tlb_flush_all();
74}
75
76/*
77 * Flush TLB state associated with a page of a vma.
78 */
79void flush_tlb_page(struct vm_area_struct *vma, unsigned long vaddr)
80{
81	struct mm_struct *mm = vma->vm_mm;
82
83	if (mm->context.ptbase  == current->active_mm->context.ptbase)
84		__vmclrmap((void *)vaddr, PAGE_SIZE);
85}
86
87/*
88 * Flush TLB entries associated with a kernel address range.
89 * Like flush range, but without the check on the vma->vm_mm.
90 */
91void flush_tlb_kernel_range(unsigned long start, unsigned long end)
92{
93		__vmclrmap((void *)start, end - start);
94}
v5.4
 1// SPDX-License-Identifier: GPL-2.0-only
 2/*
 3 * Hexagon Virtual Machine TLB functions
 4 *
 5 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 6 */
 7
 8/*
 9 * The Hexagon Virtual Machine conceals the real workings of
10 * the TLB, but there are one or two functions that need to
11 * be instantiated for it, differently from a native build.
12 */
13#include <linux/mm.h>
14#include <linux/sched.h>
15#include <asm/page.h>
16#include <asm/hexagon_vm.h>
17
18/*
19 * Initial VM implementation has only one map active at a time, with
20 * TLB purgings on changes.  So either we're nuking the current map,
21 * or it's a no-op.  This operation is messy on true SMPs where other
22 * processors must be induced to flush the copies in their local TLBs,
23 * but Hexagon thread-based virtual processors share the same MMU.
24 */
25void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
26			unsigned long end)
27{
28	struct mm_struct *mm = vma->vm_mm;
29
30	if (mm->context.ptbase == current->active_mm->context.ptbase)
31		__vmclrmap((void *)start, end - start);
32}
33
34/*
35 * Flush a page from the kernel virtual map - used by highmem
36 */
37void flush_tlb_one(unsigned long vaddr)
38{
39	__vmclrmap((void *)vaddr, PAGE_SIZE);
40}
41
42/*
43 * Flush all TLBs across all CPUs, virtual or real.
44 * A single Hexagon core has 6 thread contexts but
45 * only one TLB.
46 */
47void tlb_flush_all(void)
48{
49	/*  should probably use that fixaddr end or whateve label  */
50	__vmclrmap(0, 0xffff0000);
51}
52
53/*
54 * Flush TLB entries associated with a given mm_struct mapping.
55 */
56void flush_tlb_mm(struct mm_struct *mm)
57{
58	/* Current Virtual Machine has only one map active at a time */
59	if (current->active_mm->context.ptbase == mm->context.ptbase)
60		tlb_flush_all();
61}
62
63/*
64 * Flush TLB state associated with a page of a vma.
65 */
66void flush_tlb_page(struct vm_area_struct *vma, unsigned long vaddr)
67{
68	struct mm_struct *mm = vma->vm_mm;
69
70	if (mm->context.ptbase  == current->active_mm->context.ptbase)
71		__vmclrmap((void *)vaddr, PAGE_SIZE);
72}
73
74/*
75 * Flush TLB entries associated with a kernel address range.
76 * Like flush range, but without the check on the vma->vm_mm.
77 */
78void flush_tlb_kernel_range(unsigned long start, unsigned long end)
79{
80		__vmclrmap((void *)start, end - start);
81}