Re: [PATCH v3 07/13] mm: introduce io_remap_pfn_range_[prepare, complete]()

Jason Gunthorpe
2025-09-16T17:19:36Z

On Tue, Sep 16, 2025 at 03:11:53PM +0100, Lorenzo Stoakes wrote:
>
> -int io_remap_pfn_range(struct vm_area_struct *vma, unsigned long vaddr,
> - unsigned long pfn, unsigned long size, pgprot_t prot)
> +static unsigned long calc_pfn(unsigned long pfn, unsigned long size)
> {
> phys_addr_t phys_addr = fixup_bigphys_addr(pfn << PAGE_SHIFT, size);
>
> - return remap_pfn_range(vma, vaddr, phys_addr >> PAGE_SHIFT, size, prot);
> + return phys_addr >> PAGE_SHIFT;
> +}

Given you changed all of these to add a calc_pfn why not make that
the arch abstraction?

static unsigned long arch_io_remap_remap_pfn(unsigned long pfn, unsigned long size)
{
..
}
#define arch_io_remap_remap_pfn arch_io_remap_remap_pfn

[..]

#ifndef arch_io_remap_remap_pfn
static inline unsigned long arch_io_remap_remap_pfn(unsigned long pfn, unsigned long size)
{
return pfn;
}
#endif

static inline void io_remap_pfn_range_prepare(struct vm_area_desc *desc, unsigned long pfn,
unsigned long size)
{
return remap_pfn_range_prepare(desc, arch_io_remap_remap_pfn(pfn));
}

etc

Removes alot of the maze here.

Jason