From: Pranjal Shrivastava <praan@google.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: Alexandre Ghiti <alex@ghiti.fr>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Albert Ou <aou@eecs.berkeley.edu>,
asahi@lists.linux.dev,
Baolin Wang <baolin.wang@linux.alibaba.com>,
iommu@lists.linux.dev, Janne Grunau <j@jannau.net>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Joerg Roedel <joro@8bytes.org>,
Jean-Philippe Brucker <jpb@kernel.org>,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org,
linux-riscv@lists.infradead.org, linux-sunxi@lists.linux.dev,
Matthias Brugger <matthias.bgg@gmail.com>,
Neal Gompa <neal@gompa.dev>, Orson Zhai <orsonzhai@gmail.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Paul Walmsley <pjw@kernel.org>,
Samuel Holland <samuel@sholland.org>,
Sven Peter <sven@kernel.org>,
virtualization@lists.linux.dev, Chen-Yu Tsai <wens@kernel.org>,
Will Deacon <will@kernel.org>, Yong Wu <yong.wu@mediatek.com>,
Chunyan Zhang <zhang.lyra@gmail.com>,
Lu Baolu <baolu.lu@linux.intel.com>,
Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>,
Joerg Roedel <joerg.roedel@amd.com>,
Jon Hunter <jonathanh@nvidia.com>,
patches@lists.linux.dev, Robin Murphy <robin.murphy@arm.com>,
Samiullah Khawaja <skhawaja@google.com>,
stable@vger.kernel.org, Vasant Hegde <vasant.hegde@amd.com>
Subject: Re: [PATCH] iommu: Always fill in gather when unmapping
Date: Wed, 1 Apr 2026 11:23:23 +0000 [thread overview]
Message-ID: <ac0AKyvHMYHlqL5i@google.com> (raw)
In-Reply-To: <0-v1-664d3acaabb9+78b-iommu_gather_always_jgg@nvidia.com>
On Tue, Mar 31, 2026 at 04:56:22PM -0300, Jason Gunthorpe wrote:
> The fixed commit assumed that the gather would always be populated if
> an iotlb_sync was required.
>
> arm-smmu-v3, amd, VT-d, riscv, s390, mtk all use information from the
> gather during their iotlb_sync() and this approach works for them.
>
> However, arm-smmu, qcom_iommu, ipmmu-vmsa, sun50i, sprd, virtio,
> apple-dart all ignore the gather during their iotlb_sync(). They
> mostly issue a full flush.
>
> Unfortunately the latter set of drivers often don't bother to add
> anything to the gather since they don't intend on using it. Since the
> core code now blocks gathers that were never filled, this caused those
> drivers to stop getting their iotlb_sync() calls and breaks them.
>
> Since it is impossible to tell the difference between gathers that are
> empty because there is nothing to do and gathers that are empty
> because they are not used, fill in the gathers for the missing cases.
>
I believe the problem is a fundamental disagreement between the core
layer and these drivers. The core assumes an empty gather means there
is no work to do, while these drivers expect a sync regardless. With
this, it seems we're forcing the drivers to lie to the core by
populating a gather they don't actually use just to trigger the sync.
I was wondering if, as a longer-term direction, having an explicit flag
for these drivers to indicate they always require a sync would be a
cleaner way to handle this than the trivial population?
Just a thought, not a hard disagreement with the current approach..
> io-pgtable might have intended to allow the driver to choose between
> gather or immediate flush because it passed gather to
> ops->tlb_add_page(), however no driver does anything with it.
>
> mtk uses io-pgtable-arm-v7s but added the range to the gather in the
> unmap callback. Move this into the io-pgtable-arm unmap itself. That
> will fix all the armv7 using drivers (arm-smmu, qcom_iommu,
> ipmmu-vmsa).
>
> arm-smmu uses both ARM_V7S and ARM LPAE formats. The LPAE formats
> already have the gather population because SMMUv3 requires it, so it
> becomes consistent.
>
> Add a trivial gather population to io-pgtable-dart.
>
> Add trivial populations to sprd, sun50i and virtio-iommu in their
> unmap functions.
>
> Fixes: 90c5def10bea ("iommu: Do not call drivers for empty gathers")
> Reported-by: Jon Hunter <jonathanh@nvidia.com>
> Closes: https://lore.kernel.org/r/8800a38b-8515-4bbe-af15-0dae81274bf7@nvidia.com
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> ---
> drivers/iommu/io-pgtable-arm.c | 4 +++-
> drivers/iommu/io-pgtable-dart.c | 3 +++
> drivers/iommu/mtk_iommu.c | 1 -
> drivers/iommu/sprd-iommu.c | 1 +
> drivers/iommu/sun50i-iommu.c | 1 +
> drivers/iommu/virtio-iommu.c | 2 ++
> 6 files changed, 10 insertions(+), 2 deletions(-)
>
Acked-by: Pranjal Shrivastava <praan@google.com>
Thanks,
Praan
WARNING: multiple messages have this Message-ID (diff)
From: Pranjal Shrivastava <praan@google.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: Alexandre Ghiti <alex@ghiti.fr>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Albert Ou <aou@eecs.berkeley.edu>,
asahi@lists.linux.dev,
Baolin Wang <baolin.wang@linux.alibaba.com>,
iommu@lists.linux.dev, Janne Grunau <j@jannau.net>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Joerg Roedel <joro@8bytes.org>,
Jean-Philippe Brucker <jpb@kernel.org>,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org,
linux-riscv@lists.infradead.org, linux-sunxi@lists.linux.dev,
Matthias Brugger <matthias.bgg@gmail.com>,
Neal Gompa <neal@gompa.dev>, Orson Zhai <orsonzhai@gmail.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Paul Walmsley <pjw@kernel.org>,
Samuel Holland <samuel@sholland.org>,
Sven Peter <sven@kernel.org>,
virtualization@lists.linux.dev, Chen-Yu Tsai <wens@kernel.org>,
Will Deacon <will@kernel.org>, Yong Wu <yong.wu@mediatek.com>,
Chunyan Zhang <zhang.lyra@gmail.com>,
Lu Baolu <baolu.lu@linux.intel.com>,
Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>,
Joerg Roedel <joerg.roedel@amd.com>,
Jon Hunter <jonathanh@nvidia.com>,
patches@lists.linux.dev, Robin Murphy <robin.murphy@arm.com>,
Samiullah Khawaja <skhawaja@google.com>,
stable@vger.kernel.org, Vasant Hegde <vasant.hegde@amd.com>
Subject: Re: [PATCH] iommu: Always fill in gather when unmapping
Date: Wed, 1 Apr 2026 11:23:23 +0000 [thread overview]
Message-ID: <ac0AKyvHMYHlqL5i@google.com> (raw)
In-Reply-To: <0-v1-664d3acaabb9+78b-iommu_gather_always_jgg@nvidia.com>
On Tue, Mar 31, 2026 at 04:56:22PM -0300, Jason Gunthorpe wrote:
> The fixed commit assumed that the gather would always be populated if
> an iotlb_sync was required.
>
> arm-smmu-v3, amd, VT-d, riscv, s390, mtk all use information from the
> gather during their iotlb_sync() and this approach works for them.
>
> However, arm-smmu, qcom_iommu, ipmmu-vmsa, sun50i, sprd, virtio,
> apple-dart all ignore the gather during their iotlb_sync(). They
> mostly issue a full flush.
>
> Unfortunately the latter set of drivers often don't bother to add
> anything to the gather since they don't intend on using it. Since the
> core code now blocks gathers that were never filled, this caused those
> drivers to stop getting their iotlb_sync() calls and breaks them.
>
> Since it is impossible to tell the difference between gathers that are
> empty because there is nothing to do and gathers that are empty
> because they are not used, fill in the gathers for the missing cases.
>
I believe the problem is a fundamental disagreement between the core
layer and these drivers. The core assumes an empty gather means there
is no work to do, while these drivers expect a sync regardless. With
this, it seems we're forcing the drivers to lie to the core by
populating a gather they don't actually use just to trigger the sync.
I was wondering if, as a longer-term direction, having an explicit flag
for these drivers to indicate they always require a sync would be a
cleaner way to handle this than the trivial population?
Just a thought, not a hard disagreement with the current approach..
> io-pgtable might have intended to allow the driver to choose between
> gather or immediate flush because it passed gather to
> ops->tlb_add_page(), however no driver does anything with it.
>
> mtk uses io-pgtable-arm-v7s but added the range to the gather in the
> unmap callback. Move this into the io-pgtable-arm unmap itself. That
> will fix all the armv7 using drivers (arm-smmu, qcom_iommu,
> ipmmu-vmsa).
>
> arm-smmu uses both ARM_V7S and ARM LPAE formats. The LPAE formats
> already have the gather population because SMMUv3 requires it, so it
> becomes consistent.
>
> Add a trivial gather population to io-pgtable-dart.
>
> Add trivial populations to sprd, sun50i and virtio-iommu in their
> unmap functions.
>
> Fixes: 90c5def10bea ("iommu: Do not call drivers for empty gathers")
> Reported-by: Jon Hunter <jonathanh@nvidia.com>
> Closes: https://lore.kernel.org/r/8800a38b-8515-4bbe-af15-0dae81274bf7@nvidia.com
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> ---
> drivers/iommu/io-pgtable-arm.c | 4 +++-
> drivers/iommu/io-pgtable-dart.c | 3 +++
> drivers/iommu/mtk_iommu.c | 1 -
> drivers/iommu/sprd-iommu.c | 1 +
> drivers/iommu/sun50i-iommu.c | 1 +
> drivers/iommu/virtio-iommu.c | 2 ++
> 6 files changed, 10 insertions(+), 2 deletions(-)
>
Acked-by: Pranjal Shrivastava <praan@google.com>
Thanks,
Praan
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2026-04-01 11:23 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-31 19:56 [PATCH] iommu: Always fill in gather when unmapping Jason Gunthorpe
2026-03-31 19:56 ` Jason Gunthorpe
2026-04-01 10:40 ` Jon Hunter
2026-04-01 10:40 ` Jon Hunter
2026-04-01 11:23 ` Pranjal Shrivastava [this message]
2026-04-01 11:23 ` Pranjal Shrivastava
2026-04-01 12:58 ` Jason Gunthorpe
2026-04-01 12:58 ` Jason Gunthorpe
2026-04-01 16:33 ` Robin Murphy
2026-04-01 16:33 ` Robin Murphy
2026-04-01 17:36 ` Jason Gunthorpe
2026-04-01 17:36 ` Jason Gunthorpe
2026-04-02 18:11 ` Robin Murphy
2026-04-02 18:11 ` Robin Murphy
2026-04-02 22:51 ` Jason Gunthorpe
2026-04-02 22:51 ` Jason Gunthorpe
2026-04-08 8:42 ` Jon Hunter
2026-04-08 8:42 ` Jon Hunter
2026-04-08 13:34 ` Jon Hunter
2026-04-08 13:34 ` Jon Hunter
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=ac0AKyvHMYHlqL5i@google.com \
--to=praan@google.com \
--cc=alex@ghiti.fr \
--cc=angelogioacchino.delregno@collabora.com \
--cc=aou@eecs.berkeley.edu \
--cc=asahi@lists.linux.dev \
--cc=baolin.wang@linux.alibaba.com \
--cc=baolu.lu@linux.intel.com \
--cc=iommu@lists.linux.dev \
--cc=j@jannau.net \
--cc=janusz.krzysztofik@linux.intel.com \
--cc=jernej.skrabec@gmail.com \
--cc=jgg@nvidia.com \
--cc=joerg.roedel@amd.com \
--cc=jonathanh@nvidia.com \
--cc=joro@8bytes.org \
--cc=jpb@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=matthias.bgg@gmail.com \
--cc=neal@gompa.dev \
--cc=orsonzhai@gmail.com \
--cc=palmer@dabbelt.com \
--cc=patches@lists.linux.dev \
--cc=pjw@kernel.org \
--cc=robin.murphy@arm.com \
--cc=samuel@sholland.org \
--cc=skhawaja@google.com \
--cc=stable@vger.kernel.org \
--cc=sven@kernel.org \
--cc=vasant.hegde@amd.com \
--cc=virtualization@lists.linux.dev \
--cc=wens@kernel.org \
--cc=will@kernel.org \
--cc=yong.wu@mediatek.com \
--cc=zhang.lyra@gmail.com \
/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.