Re: [PATCH] iommu: Always fill in gather when unmapping

Jason Gunthorpe
2026-04-02T22:51:45Z

On Thu, Apr 02, 2026 at 07:11:13PM +0100, Robin Murphy wrote:
> > > @@ -2714,6 +2714,10 @@ static size_t __iommu_unmap(struct iommu_domain *domain,
> > > pr_debug("unmapped: iova 0x%lx size 0x%zx\n",
> > > iova, unmapped_page);
> > > + /* If the driver itself isn't using the gather, mark it used */
> > > + if (iotlb_gather->end <= iotlb_gather->start)
> > > + iommu_iotlb_gather_add_range(&iotlb_gather, iova, unmapped_page);
> >
> > The gathers can be joined across unmaps and now we are inviting subtly
> > ill-formed gathers as only the first unmap will get included.

> > We do have error cases where the gather is legitimately empty, and
> > this would squash that, it probably needs to check unmapped_page for 0
> > too, at least.
>
> Maybe try looking at the rest of the code around these lines...

Okay, well lets do this one, do you want to send it since it is your
idea?

Jason