18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef _SPARC64_TLBFLUSH_H
38c2ecf20Sopenharmony_ci#define _SPARC64_TLBFLUSH_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#include <asm/mmu_context.h>
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci/* TSB flush operations. */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#define TLB_BATCH_NR	192
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_cistruct tlb_batch {
128c2ecf20Sopenharmony_ci	unsigned int hugepage_shift;
138c2ecf20Sopenharmony_ci	struct mm_struct *mm;
148c2ecf20Sopenharmony_ci	unsigned long tlb_nr;
158c2ecf20Sopenharmony_ci	unsigned long active;
168c2ecf20Sopenharmony_ci	unsigned long vaddrs[TLB_BATCH_NR];
178c2ecf20Sopenharmony_ci};
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_civoid flush_tsb_kernel_range(unsigned long start, unsigned long end);
208c2ecf20Sopenharmony_civoid flush_tsb_user(struct tlb_batch *tb);
218c2ecf20Sopenharmony_civoid flush_tsb_user_page(struct mm_struct *mm, unsigned long vaddr,
228c2ecf20Sopenharmony_ci			 unsigned int hugepage_shift);
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci/* TLB flush operations. */
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_cistatic inline void flush_tlb_mm(struct mm_struct *mm)
278c2ecf20Sopenharmony_ci{
288c2ecf20Sopenharmony_ci}
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_cistatic inline void flush_tlb_page(struct vm_area_struct *vma,
318c2ecf20Sopenharmony_ci				  unsigned long vmaddr)
328c2ecf20Sopenharmony_ci{
338c2ecf20Sopenharmony_ci}
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_cistatic inline void flush_tlb_range(struct vm_area_struct *vma,
368c2ecf20Sopenharmony_ci				   unsigned long start, unsigned long end)
378c2ecf20Sopenharmony_ci{
388c2ecf20Sopenharmony_ci}
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_civoid flush_tlb_kernel_range(unsigned long start, unsigned long end);
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci#define __HAVE_ARCH_ENTER_LAZY_MMU_MODE
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_civoid flush_tlb_pending(void);
458c2ecf20Sopenharmony_civoid arch_enter_lazy_mmu_mode(void);
468c2ecf20Sopenharmony_civoid arch_leave_lazy_mmu_mode(void);
478c2ecf20Sopenharmony_ci#define arch_flush_lazy_mmu_mode()      do {} while (0)
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci/* Local cpu only.  */
508c2ecf20Sopenharmony_civoid __flush_tlb_all(void);
518c2ecf20Sopenharmony_civoid __flush_tlb_page(unsigned long context, unsigned long vaddr);
528c2ecf20Sopenharmony_civoid __flush_tlb_kernel_range(unsigned long start, unsigned long end);
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci#ifndef CONFIG_SMP
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_cistatic inline void global_flush_tlb_page(struct mm_struct *mm, unsigned long vaddr)
578c2ecf20Sopenharmony_ci{
588c2ecf20Sopenharmony_ci	__flush_tlb_page(CTX_HWBITS(mm->context), vaddr);
598c2ecf20Sopenharmony_ci}
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci#else /* CONFIG_SMP */
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_civoid smp_flush_tlb_kernel_range(unsigned long start, unsigned long end);
648c2ecf20Sopenharmony_civoid smp_flush_tlb_page(struct mm_struct *mm, unsigned long vaddr);
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci#define global_flush_tlb_page(mm, vaddr) \
678c2ecf20Sopenharmony_ci	smp_flush_tlb_page(mm, vaddr)
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci#endif /* ! CONFIG_SMP */
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci#endif /* _SPARC64_TLBFLUSH_H */
72