1 #ifndef _ASM_RISCV_VMALLOC_H
2 #define _ASM_RISCV_VMALLOC_H
4 #ifdef CONFIG_HAVE_ARCH_HUGE_VMAP
6 #define IOREMAP_MAX_ORDER (PUD_SHIFT)
8 #define arch_vmap_pud_supported arch_vmap_pud_supported
9 static inline bool arch_vmap_pud_supported(pgprot_t prot)
14 #define arch_vmap_pmd_supported arch_vmap_pmd_supported
15 static inline bool arch_vmap_pmd_supported(pgprot_t prot)
20 #ifdef CONFIG_RISCV_ISA_SVNAPOT
21 #include <linux/pgtable.h>
23 #define arch_vmap_pte_range_map_size arch_vmap_pte_range_map_size
24 static inline unsigned long arch_vmap_pte_range_map_size(unsigned long addr, unsigned long end,
25 u64 pfn, unsigned int max_page_shift)
27 unsigned long map_size = PAGE_SIZE;
28 unsigned long size, order;
33 for_each_napot_order_rev(order) {
34 if (napot_cont_shift(order) > max_page_shift)
37 size = napot_cont_size(order);
38 if (end - addr < size)
41 if (!IS_ALIGNED(addr, size))
44 if (!IS_ALIGNED(PFN_PHYS(pfn), size))
54 #define arch_vmap_pte_supported_shift arch_vmap_pte_supported_shift
55 static inline int arch_vmap_pte_supported_shift(unsigned long size)
57 int shift = PAGE_SHIFT;
63 WARN_ON_ONCE(size >= PMD_SIZE);
65 for_each_napot_order_rev(order) {
66 if (napot_cont_size(order) > size)
69 if (!IS_ALIGNED(size, napot_cont_size(order)))
72 shift = napot_cont_shift(order);
79 #endif /* CONFIG_RISCV_ISA_SVNAPOT */
80 #endif /* CONFIG_HAVE_ARCH_HUGE_VMAP */
81 #endif /* _ASM_RISCV_VMALLOC_H */