All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: iommu@lists.linux.dev, linux-media@vger.kernel.org,
	linux-arm-msm@vger.kernel.org, kvm@vger.kernel.org,
	linux-kernel@vger.kernel.org, Robin Murphy <robin.murphy@arm.com>,
	Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
	Leon Romanovsky <leon@kernel.org>,
	Sibi Sankar <sibi.sankar@oss.qualcomm.com>,
	Honglei Huang <honghuan@amd.com>,
	prakash.gupta@oss.qualcomm.com,
	Alex Williamson <alex@shazbot.org>,
	Vikash Garodia <vikash.garodia@oss.qualcomm.com>,
	Dikshita Agarwal <dikshita.agarwal@oss.qualcomm.com>,
	Abhinav Kumar <abhinav.kumar@linux.dev>,
	Bryan O'Donoghue <bod@kernel.org>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Hans Verkuil <hverkuil+cisco@kernel.org>,
	stable@vger.kernel.org
Subject: Re: [PATCH 4/4] iommu/dma: restore flush queue use in dma_iova_destroy()
Date: Fri, 27 Nov 2026 10:37:40 -0400	[thread overview]
Message-ID: <20261127143740.GM114472@nvidia.com> (raw)
In-Reply-To: <20261127115849.2780625-5-m.szyprowski@samsung.com>

On Fri, Nov 27, 2026 at 12:58:48PM +0100, Marek Szyprowski wrote:
> Commit 1acce29926d9 ("iommu/dma: simplify dma_iova_destroy() and drop
> the free_iova helper") turned dma_iova_destroy() into dma_iova_unlink()
> followed by dma_iova_free(). Before it, the destroy path marked its
> IOTLB gather as queued for DMA-FQ domains, skipped iommu_iotlb_sync()
> and handed the IOVA over to the flush queue, exactly like
> __iommu_dma_unmap(). After it:
> 
>   - dma_iova_unlink() never queues its gather and always calls
>     iommu_iotlb_sync() after iommu_unmap_fast(),
>   - dma_iova_free() passes a NULL gather to iommu_dma_free_iova(), so
>     the IOVA goes straight back to the allocator via free_iova_fast().
> 
> DMA-FQ domains therefore get strict invalidation on this path. This
> includes blk_rq_dma_map(), which NVMe uses for all data transfers, so
> iommu.strict=0 has no effect on NVMe I/O. On a Qualcomm Glymur CRD
> (SMMUv3 without RANGE_INV, 4K pages, NVMe on PCIe Gen5 x4) sequential
> fio throughput drops from 10.6/11.9 GiB/s (write/read) to the strict
> mode level of ~2.7 GiB/s.
> 
> Instead of reverting, decide once in dma_iova_try_alloc() whether the
> IOVA space is going to be released through the flush queue and record
> it in a new DMA_IOVA_USE_FQ flag in dma_iova_state::__size, next to
> DMA_IOVA_USE_SWIOTLB, so struct dma_iova_state does not grow.
> dma_iova_destroy() then unmaps with a gather queued according to that
> flag, skipping the sync for flush queue domains, and passes the same
> gather to the IOVA free, so the IOVA space (and any page table pages
> released by the unmap) goes through queue_iova() again. dma_iova_free()
> honours the flag as well. The whole reservation is still freed, keeping
> the size fix of the reverted commit.
> 
> A gather must always be retired, either by iommu_iotlb_sync() or by
> handing it to the flush queue together with the IOVA, and the IOVA must
> never be returned to the allocator while a queued invalidation for it is
> still pending. To keep that obvious, the internal unlink helper only
> unmaps into a gather supplied by its caller, and each caller retires it
> right away: dma_iova_destroy() syncs or queues it together with the IOVA
> free, exactly like __iommu_dma_unmap(), while dma_iova_unlink() always
> uses a never queued gather and syncs it, as the unlinked range remains
> owned by the caller and may be linked again immediately.
> 
> Fixes: 1acce29926d9 ("iommu/dma: simplify dma_iova_destroy() and drop the free_iova helper")
> Reported-by: Sibi Sankar <sibi.sankar@oss.qualcomm.com>
> Closes: https://lore.kernel.org/all/20261125135120.1126571-1-sibi.sankar@oss.qualcomm.com/
> Suggested-by: Leon Romanovsky <leon@kernel.org>
> Cc: stable@vger.kernel.org # v7.3+
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> ---
>  drivers/iommu/dma-iommu.c   | 103 ++++++++++++++++++++++++++----------
>  include/linux/dma-mapping.h |   8 ++-
>  2 files changed, 83 insertions(+), 28 deletions(-)

Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>

Jason

  parent reply	other threads:[~2026-11-27 14:37 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20261127115858eucas1p1ac63e4ce0f221453e8666ab9723a2ae0@eucas1p1.samsung.com>
2026-11-27 11:58 ` [PATCH 0/4] iommu/dma: restore flush queue use in dma_iova_destroy() Marek Szyprowski
2026-11-27 11:58   ` [PATCH 1/4] media: venus: use dma_iova_size() to check the reserved IOVA size Marek Szyprowski
2026-11-27 12:41     ` Vikash Garodia
2026-11-27 14:29     ` Jason Gunthorpe
2026-11-27 15:24       ` Leon Romanovsky
2026-11-27 17:21       ` Bryan O'Donoghue
2026-11-27 17:26         ` Jason Gunthorpe
2026-11-28  8:55           ` Bryan O'Donoghue
2026-11-30 19:52             ` Jason Gunthorpe
2026-11-29 14:19           ` Vikash Garodia
2026-11-30  1:10             ` Bryan O'Donoghue
2026-11-30  6:15               ` Vikash Garodia
2026-11-30  9:09               ` Marek Szyprowski
2026-11-30 19:54               ` Jason Gunthorpe
2026-11-29 13:41         ` Bryan O'Donoghue
2026-11-27 11:58   ` [PATCH 2/4] media: iris: " Marek Szyprowski
2026-11-27 12:41     ` Vikash Garodia
2026-11-27 11:58   ` [PATCH 3/4] dma-mapping: add DMA_IOVA_FLAGS mask for the dma_iova_state size flags Marek Szyprowski
2026-11-27 14:37     ` Jason Gunthorpe
2026-11-27 11:58   ` [PATCH 4/4] iommu/dma: restore flush queue use in dma_iova_destroy() Marek Szyprowski
2026-11-27 12:12     ` sashiko-bot
2026-11-27 14:37     ` Jason Gunthorpe [this message]
2026-11-27 14:45       ` Marek Szyprowski
2026-11-27 15:17         ` Jason Gunthorpe
2026-11-27 16:29           ` Marek Szyprowski
2026-11-27 17:18             ` Marek Szyprowski
2026-11-27 15:31     ` Leon Romanovsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261127143740.GM114472@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=abhinav.kumar@linux.dev \
    --cc=alex@shazbot.org \
    --cc=bod@kernel.org \
    --cc=dikshita.agarwal@oss.qualcomm.com \
    --cc=honghuan@amd.com \
    --cc=hverkuil+cisco@kernel.org \
    --cc=iommu@lists.linux.dev \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=mchehab@kernel.org \
    --cc=prakash.gupta@oss.qualcomm.com \
    --cc=robin.murphy@arm.com \
    --cc=sibi.sankar@oss.qualcomm.com \
    --cc=stable@vger.kernel.org \
    --cc=vikash.garodia@oss.qualcomm.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.