Re: [PATCH 4/4] iommu/dma: restore flush queue use in dma_iova_destroy()

From: Marek Szyprowski

Date: Fri Nov 27 2026 - 12:18:29 EST


On 27.11.2026 17:29, Marek Szyprowski wrote:
> On 27.11.2026 16:17, Jason Gunthorpe wrote:
>> On Fri, Nov 27, 2026 at 03:45:15PM +0100, Marek Szyprowski wrote:
>>> diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
>>> index 0e329ecd7dfa..106da975bf0f 100644
>>> --- a/drivers/iommu/dma-iommu.c
>>> +++ b/drivers/iommu/dma-iommu.c
>>> @@ -1892,11 +1892,12 @@ static void __dma_iova_free(struct device *dev, struct dma_iova_state *state,
>>>   */
>>>  void dma_iova_free(struct device *dev, struct dma_iova_state *state)
>>>  {
>>> -       struct iommu_iotlb_gather iotlb_gather;
>>> -
>>> -       iommu_iotlb_gather_init(&iotlb_gather);
>>> -       iotlb_gather.queued = state->__size & DMA_IOVA_USE_FQ;
>>> -       __dma_iova_free(dev, state, &iotlb_gather);
>>> +       /*
>>> +        * Nothing is linked any more and every dma_iova_unlink() has already
>>> +        * invalidated the IOTLB synchronously, so there is no deferred
>>> +        * invalidation to wait for and the IOVA can be reused right away.
>>> +        */
>>> +       __dma_iova_free(dev, state, NULL);
>>>  }
>>>  EXPORT_SYMBOL_GPL(dma_iova_free);
>> That makes sense, but I'm a little lost why we needed the
>> DMA_IOVA_USE_FQ ?
>>
>> If any queued gather was ever created then the ultimate free has to
>> also be queued. But the comment implies that queued gathers were never
>> created in this case?
> Indeed there is no point caching domain->iova_cookie->fq_domain once the
> dma_iova_free() doesn't use the gather. Now fq_domain can be directly
> checked in dma_iova_destroy(). This simplifies things a lot. I will send v2
> soon.

v2:

https://lore.kernel.org/all/20261127171529.2917893-1-m.szyprowski@xxxxxxxxxxx/

Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland