xref: /openbmc/linux/arch/parisc/include/asm/tlbflush.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2deae26bfSKyle McMartin #ifndef _PARISC_TLBFLUSH_H
3deae26bfSKyle McMartin #define _PARISC_TLBFLUSH_H
4deae26bfSKyle McMartin 
5deae26bfSKyle McMartin /* TLB flushing routines.... */
6deae26bfSKyle McMartin 
7deae26bfSKyle McMartin #include <linux/mm.h>
8deae26bfSKyle McMartin #include <linux/sched.h>
9deae26bfSKyle McMartin #include <asm/mmu_context.h>
10deae26bfSKyle McMartin 
11deae26bfSKyle McMartin extern void flush_tlb_all(void);
12deae26bfSKyle McMartin extern void flush_tlb_all_local(void *);
13deae26bfSKyle McMartin 
140fc537d1SHelge Deller #define smp_flush_tlb_all()	flush_tlb_all()
150fc537d1SHelge Deller 
1601ab6057SJohn David Anglin int __flush_tlb_range(unsigned long sid,
1701ab6057SJohn David Anglin 	unsigned long start, unsigned long end);
1801ab6057SJohn David Anglin 
1901ab6057SJohn David Anglin #define flush_tlb_range(vma, start, end) \
20*df24e178SHelge Deller 	__flush_tlb_range((vma)->vm_mm->context.space_id, start, end)
2101ab6057SJohn David Anglin 
2201ab6057SJohn David Anglin #define flush_tlb_kernel_range(start, end) \
2301ab6057SJohn David Anglin 	__flush_tlb_range(0, start, end)
2401ab6057SJohn David Anglin 
25deae26bfSKyle McMartin /*
26deae26bfSKyle McMartin  * flush_tlb_mm()
27deae26bfSKyle McMartin  *
2801ab6057SJohn David Anglin  * The code to switch to a new context is NOT valid for processes
2901ab6057SJohn David Anglin  * which play with the space id's.  Thus, we have to preserve the
3001ab6057SJohn David Anglin  * space and just flush the entire tlb.  However, the compilers,
3101ab6057SJohn David Anglin  * dynamic linker, etc, do not manipulate space id's, so there
3201ab6057SJohn David Anglin  * could be a significant performance benefit in switching contexts
3301ab6057SJohn David Anglin  * and not flushing the whole tlb.
34deae26bfSKyle McMartin  */
35deae26bfSKyle McMartin 
flush_tlb_mm(struct mm_struct * mm)36deae26bfSKyle McMartin static inline void flush_tlb_mm(struct mm_struct *mm)
37deae26bfSKyle McMartin {
38deae26bfSKyle McMartin 	BUG_ON(mm == &init_mm); /* Should never happen */
39deae26bfSKyle McMartin 
405289f46bSKyle McMartin #if 1 || defined(CONFIG_SMP)
4101ab6057SJohn David Anglin 	/* Except for very small threads, flushing the whole TLB is
4201ab6057SJohn David Anglin 	 * faster than using __flush_tlb_range.  The pdtlb and pitlb
4301ab6057SJohn David Anglin 	 * instructions are very slow because of the TLB broadcast.
4401ab6057SJohn David Anglin 	 * It might be faster to do local range flushes on all CPUs
4501ab6057SJohn David Anglin 	 * on PA 2.0 systems.
4601ab6057SJohn David Anglin 	 */
47deae26bfSKyle McMartin 	flush_tlb_all();
48deae26bfSKyle McMartin #else
495289f46bSKyle McMartin 	/* FIXME: currently broken, causing space id and protection ids
505289f46bSKyle McMartin 	 * to go out of sync, resulting in faults on userspace accesses.
5101ab6057SJohn David Anglin 	 * This approach needs further investigation since running many
5201ab6057SJohn David Anglin 	 * small applications (e.g., GCC testsuite) is faster on HP-UX.
535289f46bSKyle McMartin 	 */
54deae26bfSKyle McMartin 	if (mm) {
55deae26bfSKyle McMartin 		if (mm->context != 0)
56deae26bfSKyle McMartin 			free_sid(mm->context);
57deae26bfSKyle McMartin 		mm->context = alloc_sid();
58deae26bfSKyle McMartin 		if (mm == current->active_mm)
59deae26bfSKyle McMartin 			load_context(mm->context);
60deae26bfSKyle McMartin 	}
61deae26bfSKyle McMartin #endif
62deae26bfSKyle McMartin }
63deae26bfSKyle McMartin 
flush_tlb_page(struct vm_area_struct * vma,unsigned long addr)64deae26bfSKyle McMartin static inline void flush_tlb_page(struct vm_area_struct *vma,
65deae26bfSKyle McMartin 	unsigned long addr)
66deae26bfSKyle McMartin {
67b37d1c18SMikulas Patocka 	purge_tlb_entries(vma->vm_mm, addr);
68deae26bfSKyle McMartin }
69deae26bfSKyle McMartin #endif
70