Re: [PATCH v5 5/9] iommufd: Add an ioctl to query PA from IOVA for noiommu mode
From: Jason Gunthorpe
Date: Wed May 13 2026 - 19:26:32 EST
On Wed, May 13, 2026 at 03:20:14PM -0700, Jacob Pan wrote:
> Hi Jason,
>
> On Wed, 13 May 2026 09:22:21 -0300
> Jason Gunthorpe <jgg@xxxxxxxxxx> wrote:
>
> > On Wed, May 13, 2026 at 03:53:43PM +0800, Baolu Lu wrote:
> > > > #define IOMMU_IOAS_MAP _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_MAP)
> > > > +/**
> > > > + * struct iommu_ioas_noiommu_get_pa -
> > > > ioctl(IOMMU_IOAS_NOIOMMU_GET_PA)
> > > > + * @size: sizeof(struct iommu_ioas_noiommu_get_pa)
> > > > + * @flags: Reserved, must be 0 for now
> > > > + * @ioas_id: IOAS ID to query IOVA to PA mapping from
> > > > + * @__reserved: Must be 0
> > > > + * @iova: IOVA to query
> > > > + * @out_length: Number of bytes contiguous physical address
> > > > starting from phys
> > >
> > > Nit: Instead of making this behavior mandatory, would it be
> > > valuable to allocate a bit in @flags to toggle this behavior? For
> > > extremely large mappings (e.g., several GBs of contiguous
> > > hugepages), the loop to determine the contiguous physical addresses
> > > might take a long time. A very long scan could theoretically delay
> > > userspace DMA setup.
> >
> > If we are worrying about that then a iova/length pair would be
> > appropriate such that out_len doesn't exceed the length. Right now it
> > stops at the area boundary IIRC.
> >
>
> Yes, it stops at area boundary. How about renaming out_length to
> length, then use it as both input (cap on the scan range) and output
> (actual contiguous bytes found)? When length == 0 on input, it could
> mean "no limit" to keep the current behavior as default.
That sounds Ok, document it carefully it is tricky!
Jason