Message ID | 20210126044510.2491820-5-npiggin@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | huge vmalloc mappings | expand |
Looks good,
Reviewed-by: Christoph Hellwig <hch@lst.de>
Hi: On 2021/1/26 12:45, Nicholas Piggin wrote: > This will be used as a generic kernel virtual mapping function, so > re-name it in preparation. > Looks good to me. Thanks. Reviewed-by: Miaohe Lin <linmiaohe@huawei.com> > Signed-off-by: Nicholas Piggin <npiggin@gmail.com> > --- > mm/ioremap.c | 64 +++++++++++++++++++++++++++------------------------- > 1 file changed, 33 insertions(+), 31 deletions(-) > > diff --git a/mm/ioremap.c b/mm/ioremap.c > index 5fa1ab41d152..3f4d36f9745a 100644 > --- a/mm/ioremap.c > +++ b/mm/ioremap.c > @@ -61,9 +61,9 @@ static inline int ioremap_pud_enabled(void) { return 0; } > static inline int ioremap_pmd_enabled(void) { return 0; } > #endif /* CONFIG_HAVE_ARCH_HUGE_VMAP */ > > -static int ioremap_pte_range(pmd_t *pmd, unsigned long addr, > - unsigned long end, phys_addr_t phys_addr, pgprot_t prot, > - pgtbl_mod_mask *mask) > +static int vmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, > + phys_addr_t phys_addr, pgprot_t prot, > + pgtbl_mod_mask *mask) > { > pte_t *pte; > u64 pfn; > @@ -81,9 +81,8 @@ static int ioremap_pte_range(pmd_t *pmd, unsigned long addr, > return 0; > } > > -static int ioremap_try_huge_pmd(pmd_t *pmd, unsigned long addr, > - unsigned long end, phys_addr_t phys_addr, > - pgprot_t prot) > +static int vmap_try_huge_pmd(pmd_t *pmd, unsigned long addr, unsigned long end, > + phys_addr_t phys_addr, pgprot_t prot) > { > if (!ioremap_pmd_enabled()) > return 0; > @@ -103,9 +102,9 @@ static int ioremap_try_huge_pmd(pmd_t *pmd, unsigned long addr, > return pmd_set_huge(pmd, phys_addr, prot); > } > > -static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr, > - unsigned long end, phys_addr_t phys_addr, pgprot_t prot, > - pgtbl_mod_mask *mask) > +static int vmap_pmd_range(pud_t *pud, unsigned long addr, unsigned long end, > + phys_addr_t phys_addr, pgprot_t prot, > + pgtbl_mod_mask *mask) > { > pmd_t *pmd; > unsigned long next; > @@ -116,20 +115,19 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr, > do { > next = pmd_addr_end(addr, end); > > - if (ioremap_try_huge_pmd(pmd, addr, next, phys_addr, prot)) { > + if (vmap_try_huge_pmd(pmd, addr, next, phys_addr, prot)) { > *mask |= PGTBL_PMD_MODIFIED; > continue; > } > > - if (ioremap_pte_range(pmd, addr, next, phys_addr, prot, mask)) > + if (vmap_pte_range(pmd, addr, next, phys_addr, prot, mask)) > return -ENOMEM; > } while (pmd++, phys_addr += (next - addr), addr = next, addr != end); > return 0; > } > > -static int ioremap_try_huge_pud(pud_t *pud, unsigned long addr, > - unsigned long end, phys_addr_t phys_addr, > - pgprot_t prot) > +static int vmap_try_huge_pud(pud_t *pud, unsigned long addr, unsigned long end, > + phys_addr_t phys_addr, pgprot_t prot) > { > if (!ioremap_pud_enabled()) > return 0; > @@ -149,9 +147,9 @@ static int ioremap_try_huge_pud(pud_t *pud, unsigned long addr, > return pud_set_huge(pud, phys_addr, prot); > } > > -static inline int ioremap_pud_range(p4d_t *p4d, unsigned long addr, > - unsigned long end, phys_addr_t phys_addr, pgprot_t prot, > - pgtbl_mod_mask *mask) > +static int vmap_pud_range(p4d_t *p4d, unsigned long addr, unsigned long end, > + phys_addr_t phys_addr, pgprot_t prot, > + pgtbl_mod_mask *mask) > { > pud_t *pud; > unsigned long next; > @@ -162,20 +160,19 @@ static inline int ioremap_pud_range(p4d_t *p4d, unsigned long addr, > do { > next = pud_addr_end(addr, end); > > - if (ioremap_try_huge_pud(pud, addr, next, phys_addr, prot)) { > + if (vmap_try_huge_pud(pud, addr, next, phys_addr, prot)) { > *mask |= PGTBL_PUD_MODIFIED; > continue; > } > > - if (ioremap_pmd_range(pud, addr, next, phys_addr, prot, mask)) > + if (vmap_pmd_range(pud, addr, next, phys_addr, prot, mask)) > return -ENOMEM; > } while (pud++, phys_addr += (next - addr), addr = next, addr != end); > return 0; > } > > -static int ioremap_try_huge_p4d(p4d_t *p4d, unsigned long addr, > - unsigned long end, phys_addr_t phys_addr, > - pgprot_t prot) > +static int vmap_try_huge_p4d(p4d_t *p4d, unsigned long addr, unsigned long end, > + phys_addr_t phys_addr, pgprot_t prot) > { > if (!ioremap_p4d_enabled()) > return 0; > @@ -195,9 +192,9 @@ static int ioremap_try_huge_p4d(p4d_t *p4d, unsigned long addr, > return p4d_set_huge(p4d, phys_addr, prot); > } > > -static inline int ioremap_p4d_range(pgd_t *pgd, unsigned long addr, > - unsigned long end, phys_addr_t phys_addr, pgprot_t prot, > - pgtbl_mod_mask *mask) > +static int vmap_p4d_range(pgd_t *pgd, unsigned long addr, unsigned long end, > + phys_addr_t phys_addr, pgprot_t prot, > + pgtbl_mod_mask *mask) > { > p4d_t *p4d; > unsigned long next; > @@ -208,19 +205,19 @@ static inline int ioremap_p4d_range(pgd_t *pgd, unsigned long addr, > do { > next = p4d_addr_end(addr, end); > > - if (ioremap_try_huge_p4d(p4d, addr, next, phys_addr, prot)) { > + if (vmap_try_huge_p4d(p4d, addr, next, phys_addr, prot)) { > *mask |= PGTBL_P4D_MODIFIED; > continue; > } > > - if (ioremap_pud_range(p4d, addr, next, phys_addr, prot, mask)) > + if (vmap_pud_range(p4d, addr, next, phys_addr, prot, mask)) > return -ENOMEM; > } while (p4d++, phys_addr += (next - addr), addr = next, addr != end); > return 0; > } > > -int ioremap_page_range(unsigned long addr, > - unsigned long end, phys_addr_t phys_addr, pgprot_t prot) > +static int vmap_range(unsigned long addr, unsigned long end, > + phys_addr_t phys_addr, pgprot_t prot) > { > pgd_t *pgd; > unsigned long start; > @@ -235,8 +232,7 @@ int ioremap_page_range(unsigned long addr, > pgd = pgd_offset_k(addr); > do { > next = pgd_addr_end(addr, end); > - err = ioremap_p4d_range(pgd, addr, next, phys_addr, prot, > - &mask); > + err = vmap_p4d_range(pgd, addr, next, phys_addr, prot, &mask); > if (err) > break; > } while (pgd++, phys_addr += (next - addr), addr = next, addr != end); > @@ -249,6 +245,12 @@ int ioremap_page_range(unsigned long addr, > return err; > } > > +int ioremap_page_range(unsigned long addr, > + unsigned long end, phys_addr_t phys_addr, pgprot_t prot) > +{ > + return vmap_range(addr, end, phys_addr, prot); > +} > + > #ifdef CONFIG_GENERIC_IOREMAP > void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long prot) > { >
diff --git a/mm/ioremap.c b/mm/ioremap.c index 5fa1ab41d152..3f4d36f9745a 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -61,9 +61,9 @@ static inline int ioremap_pud_enabled(void) { return 0; } static inline int ioremap_pmd_enabled(void) { return 0; } #endif /* CONFIG_HAVE_ARCH_HUGE_VMAP */ -static int ioremap_pte_range(pmd_t *pmd, unsigned long addr, - unsigned long end, phys_addr_t phys_addr, pgprot_t prot, - pgtbl_mod_mask *mask) +static int vmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, + phys_addr_t phys_addr, pgprot_t prot, + pgtbl_mod_mask *mask) { pte_t *pte; u64 pfn; @@ -81,9 +81,8 @@ static int ioremap_pte_range(pmd_t *pmd, unsigned long addr, return 0; } -static int ioremap_try_huge_pmd(pmd_t *pmd, unsigned long addr, - unsigned long end, phys_addr_t phys_addr, - pgprot_t prot) +static int vmap_try_huge_pmd(pmd_t *pmd, unsigned long addr, unsigned long end, + phys_addr_t phys_addr, pgprot_t prot) { if (!ioremap_pmd_enabled()) return 0; @@ -103,9 +102,9 @@ static int ioremap_try_huge_pmd(pmd_t *pmd, unsigned long addr, return pmd_set_huge(pmd, phys_addr, prot); } -static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr, - unsigned long end, phys_addr_t phys_addr, pgprot_t prot, - pgtbl_mod_mask *mask) +static int vmap_pmd_range(pud_t *pud, unsigned long addr, unsigned long end, + phys_addr_t phys_addr, pgprot_t prot, + pgtbl_mod_mask *mask) { pmd_t *pmd; unsigned long next; @@ -116,20 +115,19 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr, do { next = pmd_addr_end(addr, end); - if (ioremap_try_huge_pmd(pmd, addr, next, phys_addr, prot)) { + if (vmap_try_huge_pmd(pmd, addr, next, phys_addr, prot)) { *mask |= PGTBL_PMD_MODIFIED; continue; } - if (ioremap_pte_range(pmd, addr, next, phys_addr, prot, mask)) + if (vmap_pte_range(pmd, addr, next, phys_addr, prot, mask)) return -ENOMEM; } while (pmd++, phys_addr += (next - addr), addr = next, addr != end); return 0; } -static int ioremap_try_huge_pud(pud_t *pud, unsigned long addr, - unsigned long end, phys_addr_t phys_addr, - pgprot_t prot) +static int vmap_try_huge_pud(pud_t *pud, unsigned long addr, unsigned long end, + phys_addr_t phys_addr, pgprot_t prot) { if (!ioremap_pud_enabled()) return 0; @@ -149,9 +147,9 @@ static int ioremap_try_huge_pud(pud_t *pud, unsigned long addr, return pud_set_huge(pud, phys_addr, prot); } -static inline int ioremap_pud_range(p4d_t *p4d, unsigned long addr, - unsigned long end, phys_addr_t phys_addr, pgprot_t prot, - pgtbl_mod_mask *mask) +static int vmap_pud_range(p4d_t *p4d, unsigned long addr, unsigned long end, + phys_addr_t phys_addr, pgprot_t prot, + pgtbl_mod_mask *mask) { pud_t *pud; unsigned long next; @@ -162,20 +160,19 @@ static inline int ioremap_pud_range(p4d_t *p4d, unsigned long addr, do { next = pud_addr_end(addr, end); - if (ioremap_try_huge_pud(pud, addr, next, phys_addr, prot)) { + if (vmap_try_huge_pud(pud, addr, next, phys_addr, prot)) { *mask |= PGTBL_PUD_MODIFIED; continue; } - if (ioremap_pmd_range(pud, addr, next, phys_addr, prot, mask)) + if (vmap_pmd_range(pud, addr, next, phys_addr, prot, mask)) return -ENOMEM; } while (pud++, phys_addr += (next - addr), addr = next, addr != end); return 0; } -static int ioremap_try_huge_p4d(p4d_t *p4d, unsigned long addr, - unsigned long end, phys_addr_t phys_addr, - pgprot_t prot) +static int vmap_try_huge_p4d(p4d_t *p4d, unsigned long addr, unsigned long end, + phys_addr_t phys_addr, pgprot_t prot) { if (!ioremap_p4d_enabled()) return 0; @@ -195,9 +192,9 @@ static int ioremap_try_huge_p4d(p4d_t *p4d, unsigned long addr, return p4d_set_huge(p4d, phys_addr, prot); } -static inline int ioremap_p4d_range(pgd_t *pgd, unsigned long addr, - unsigned long end, phys_addr_t phys_addr, pgprot_t prot, - pgtbl_mod_mask *mask) +static int vmap_p4d_range(pgd_t *pgd, unsigned long addr, unsigned long end, + phys_addr_t phys_addr, pgprot_t prot, + pgtbl_mod_mask *mask) { p4d_t *p4d; unsigned long next; @@ -208,19 +205,19 @@ static inline int ioremap_p4d_range(pgd_t *pgd, unsigned long addr, do { next = p4d_addr_end(addr, end); - if (ioremap_try_huge_p4d(p4d, addr, next, phys_addr, prot)) { + if (vmap_try_huge_p4d(p4d, addr, next, phys_addr, prot)) { *mask |= PGTBL_P4D_MODIFIED; continue; } - if (ioremap_pud_range(p4d, addr, next, phys_addr, prot, mask)) + if (vmap_pud_range(p4d, addr, next, phys_addr, prot, mask)) return -ENOMEM; } while (p4d++, phys_addr += (next - addr), addr = next, addr != end); return 0; } -int ioremap_page_range(unsigned long addr, - unsigned long end, phys_addr_t phys_addr, pgprot_t prot) +static int vmap_range(unsigned long addr, unsigned long end, + phys_addr_t phys_addr, pgprot_t prot) { pgd_t *pgd; unsigned long start; @@ -235,8 +232,7 @@ int ioremap_page_range(unsigned long addr, pgd = pgd_offset_k(addr); do { next = pgd_addr_end(addr, end); - err = ioremap_p4d_range(pgd, addr, next, phys_addr, prot, - &mask); + err = vmap_p4d_range(pgd, addr, next, phys_addr, prot, &mask); if (err) break; } while (pgd++, phys_addr += (next - addr), addr = next, addr != end); @@ -249,6 +245,12 @@ int ioremap_page_range(unsigned long addr, return err; } +int ioremap_page_range(unsigned long addr, + unsigned long end, phys_addr_t phys_addr, pgprot_t prot) +{ + return vmap_range(addr, end, phys_addr, prot); +} + #ifdef CONFIG_GENERIC_IOREMAP void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long prot) {
This will be used as a generic kernel virtual mapping function, so re-name it in preparation. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> --- mm/ioremap.c | 64 +++++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 31 deletions(-)