18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef _ASM_POWERPC_TLBFLUSH_RADIX_H
38c2ecf20Sopenharmony_ci#define _ASM_POWERPC_TLBFLUSH_RADIX_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#include <asm/hvcall.h>
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_cistruct vm_area_struct;
88c2ecf20Sopenharmony_cistruct mm_struct;
98c2ecf20Sopenharmony_cistruct mmu_gather;
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_cistatic inline u64 psize_to_rpti_pgsize(unsigned long psize)
128c2ecf20Sopenharmony_ci{
138c2ecf20Sopenharmony_ci	if (psize == MMU_PAGE_4K)
148c2ecf20Sopenharmony_ci		return H_RPTI_PAGE_4K;
158c2ecf20Sopenharmony_ci	if (psize == MMU_PAGE_64K)
168c2ecf20Sopenharmony_ci		return H_RPTI_PAGE_64K;
178c2ecf20Sopenharmony_ci	if (psize == MMU_PAGE_2M)
188c2ecf20Sopenharmony_ci		return H_RPTI_PAGE_2M;
198c2ecf20Sopenharmony_ci	if (psize == MMU_PAGE_1G)
208c2ecf20Sopenharmony_ci		return H_RPTI_PAGE_1G;
218c2ecf20Sopenharmony_ci	return H_RPTI_PAGE_ALL;
228c2ecf20Sopenharmony_ci}
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_cistatic inline int mmu_get_ap(int psize)
258c2ecf20Sopenharmony_ci{
268c2ecf20Sopenharmony_ci	return mmu_psize_defs[psize].ap;
278c2ecf20Sopenharmony_ci}
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci#ifdef CONFIG_PPC_RADIX_MMU
308c2ecf20Sopenharmony_ciextern void radix__tlbiel_all(unsigned int action);
318c2ecf20Sopenharmony_ciextern void radix__flush_tlb_lpid_page(unsigned int lpid,
328c2ecf20Sopenharmony_ci					unsigned long addr,
338c2ecf20Sopenharmony_ci					unsigned long page_size);
348c2ecf20Sopenharmony_ciextern void radix__flush_pwc_lpid(unsigned int lpid);
358c2ecf20Sopenharmony_ciextern void radix__flush_all_lpid(unsigned int lpid);
368c2ecf20Sopenharmony_ciextern void radix__flush_all_lpid_guest(unsigned int lpid);
378c2ecf20Sopenharmony_ci#else
388c2ecf20Sopenharmony_cistatic inline void radix__tlbiel_all(unsigned int action) { WARN_ON(1); };
398c2ecf20Sopenharmony_cistatic inline void radix__flush_tlb_lpid_page(unsigned int lpid,
408c2ecf20Sopenharmony_ci					unsigned long addr,
418c2ecf20Sopenharmony_ci					unsigned long page_size)
428c2ecf20Sopenharmony_ci{
438c2ecf20Sopenharmony_ci	WARN_ON(1);
448c2ecf20Sopenharmony_ci}
458c2ecf20Sopenharmony_cistatic inline void radix__flush_pwc_lpid(unsigned int lpid)
468c2ecf20Sopenharmony_ci{
478c2ecf20Sopenharmony_ci	WARN_ON(1);
488c2ecf20Sopenharmony_ci}
498c2ecf20Sopenharmony_cistatic inline void radix__flush_all_lpid(unsigned int lpid)
508c2ecf20Sopenharmony_ci{
518c2ecf20Sopenharmony_ci	WARN_ON(1);
528c2ecf20Sopenharmony_ci}
538c2ecf20Sopenharmony_cistatic inline void radix__flush_all_lpid_guest(unsigned int lpid)
548c2ecf20Sopenharmony_ci{
558c2ecf20Sopenharmony_ci	WARN_ON(1);
568c2ecf20Sopenharmony_ci}
578c2ecf20Sopenharmony_ci#endif
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ciextern void radix__flush_hugetlb_tlb_range(struct vm_area_struct *vma,
608c2ecf20Sopenharmony_ci					   unsigned long start, unsigned long end);
618c2ecf20Sopenharmony_ciextern void radix__flush_tlb_range_psize(struct mm_struct *mm, unsigned long start,
628c2ecf20Sopenharmony_ci					 unsigned long end, int psize);
638c2ecf20Sopenharmony_ciextern void radix__flush_pmd_tlb_range(struct vm_area_struct *vma,
648c2ecf20Sopenharmony_ci				       unsigned long start, unsigned long end);
658c2ecf20Sopenharmony_ciextern void radix__flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
668c2ecf20Sopenharmony_ci			    unsigned long end);
678c2ecf20Sopenharmony_ciextern void radix__flush_tlb_kernel_range(unsigned long start, unsigned long end);
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ciextern void radix__local_flush_tlb_mm(struct mm_struct *mm);
708c2ecf20Sopenharmony_ciextern void radix__local_flush_all_mm(struct mm_struct *mm);
718c2ecf20Sopenharmony_ciextern void radix__local_flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
728c2ecf20Sopenharmony_ciextern void radix__local_flush_tlb_page_psize(struct mm_struct *mm, unsigned long vmaddr,
738c2ecf20Sopenharmony_ci					      int psize);
748c2ecf20Sopenharmony_ciextern void radix__tlb_flush(struct mmu_gather *tlb);
758c2ecf20Sopenharmony_ci#ifdef CONFIG_SMP
768c2ecf20Sopenharmony_ciextern void radix__flush_tlb_mm(struct mm_struct *mm);
778c2ecf20Sopenharmony_ciextern void radix__flush_all_mm(struct mm_struct *mm);
788c2ecf20Sopenharmony_ciextern void radix__flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
798c2ecf20Sopenharmony_ciextern void radix__flush_tlb_page_psize(struct mm_struct *mm, unsigned long vmaddr,
808c2ecf20Sopenharmony_ci					int psize);
818c2ecf20Sopenharmony_ci#else
828c2ecf20Sopenharmony_ci#define radix__flush_tlb_mm(mm)		radix__local_flush_tlb_mm(mm)
838c2ecf20Sopenharmony_ci#define radix__flush_all_mm(mm)		radix__local_flush_all_mm(mm)
848c2ecf20Sopenharmony_ci#define radix__flush_tlb_page(vma,addr)	radix__local_flush_tlb_page(vma,addr)
858c2ecf20Sopenharmony_ci#define radix__flush_tlb_page_psize(mm,addr,p) radix__local_flush_tlb_page_psize(mm,addr,p)
868c2ecf20Sopenharmony_ci#endif
878c2ecf20Sopenharmony_ciextern void radix__flush_tlb_pwc(struct mmu_gather *tlb, unsigned long addr);
888c2ecf20Sopenharmony_ciextern void radix__flush_tlb_collapsed_pmd(struct mm_struct *mm, unsigned long addr);
898c2ecf20Sopenharmony_ciextern void radix__flush_tlb_all(void);
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci#endif
92