]> git.ipfire.org Git - people/arne_f/kernel.git/blame - arch/powerpc/include/asm/book3s/64/hugetlb.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[people/arne_f/kernel.git] / arch / powerpc / include / asm / book3s / 64 / hugetlb.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
bee8b3b5
AK
2#ifndef _ASM_POWERPC_BOOK3S_64_HUGETLB_H
3#define _ASM_POWERPC_BOOK3S_64_HUGETLB_H
48483760
AK
4/*
5 * For radix we want generic code to handle hugetlb. But then if we want
6 * both hash and radix to be enabled together we need to workaround the
7 * limitations.
8 */
9void radix__flush_hugetlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
10void radix__local_flush_hugetlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
11extern unsigned long
12radix__hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
13 unsigned long len, unsigned long pgoff,
14 unsigned long flags);
fbfa26d8
AK
15
16static inline int hstate_get_psize(struct hstate *hstate)
17{
18 unsigned long shift;
19
20 shift = huge_page_shift(hstate);
21 if (shift == mmu_psize_defs[MMU_PAGE_2M].shift)
22 return MMU_PAGE_2M;
23 else if (shift == mmu_psize_defs[MMU_PAGE_1G].shift)
24 return MMU_PAGE_1G;
ccf17c8b
AK
25 else if (shift == mmu_psize_defs[MMU_PAGE_16M].shift)
26 return MMU_PAGE_16M;
27 else if (shift == mmu_psize_defs[MMU_PAGE_16G].shift)
28 return MMU_PAGE_16G;
fbfa26d8
AK
29 else {
30 WARN(1, "Wrong huge page shift\n");
31 return mmu_virtual_psize;
32 }
33}
049d567a
AK
34
35#define arch_make_huge_pte arch_make_huge_pte
36static inline pte_t arch_make_huge_pte(pte_t entry, struct vm_area_struct *vma,
37 struct page *page, int writable)
38{
39 unsigned long page_shift;
40
41 if (!cpu_has_feature(CPU_FTR_POWER9_DD1))
42 return entry;
43
44 page_shift = huge_page_shift(hstate_vma(vma));
45 /*
46 * We don't support 1G hugetlb pages yet.
47 */
48 VM_WARN_ON(page_shift == mmu_psize_defs[MMU_PAGE_1G].shift);
49 if (page_shift == mmu_psize_defs[MMU_PAGE_2M].shift)
ddb014b6 50 return __pte(pte_val(entry) | R_PAGE_LARGE);
049d567a
AK
51 else
52 return entry;
53}
40692eb5
AK
54
55#ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE
56static inline bool gigantic_page_supported(void)
57{
4ae279c2 58 return true;
40692eb5
AK
59}
60#endif
61
48483760 62#endif