From: Jason Gunthorpe <jgg@nvidia.com>
To: Catalin Marinas <catalin.marinas@arm.com>,
Jonathan Corbet <corbet@lwn.net>,
iommu@lists.linux.dev, "Joerg Roedel (AMD)" <joro@8bytes.org>,
Jean-Philippe Brucker <jpb@kernel.org>,
linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org,
Mark Rutland <mark.rutland@arm.com>,
Randy Dunlap <rdunlap@infradead.org>,
Robin Murphy <robin.murphy@arm.com>,
Shuah Khan <skhan@linuxfoundation.org>,
Will Deacon <will@kernel.org>
Cc: David Matlack <dmatlack@google.com>,
Jean-Philippe Brucker <jean-philippe@linaro.org>,
Jonathan Cameron <Jonathan.Cameron@huawei.com>,
Nicolin Chen <nicolinc@nvidia.com>,
Pasha Tatashin <pasha.tatashin@soleen.com>,
patches@lists.linux.dev, Pranjal Shrivastava <praan@google.com>,
Samiullah Khawaja <skhawaja@google.com>,
Mostafa Saleh <smostafa@google.com>,
stable@vger.kernel.org,
Vijayanand Jitta <vijayanand.jitta@oss.qualcomm.com>
Subject: [PATCH v5 0/9] Organize the SMMUv3 invalidation flow so iommupt can use it
Date: Tue, 1 Sep 2026 14:49:49 -0300 [thread overview]
Message-ID: <0-v5-b810cf379bfc+13d738-smmu_tlbi_jgg@nvidia.com> (raw)
[ This is part of the patch pile to move SMMUv3 over to the generic page
table, the precursor patches have been merged now:
1) Organize the SMMUv3 invalidation flow so iommupt can use it
2) Use the generic iommu page table for SMMUv3
The first patch should ideally go to -rc
The whole branch is here:
https://github.com/jgunthorpe/linux/commits/iommu_pt_arm64/
]
iommupt has a design that focuses on building a single iommu_iotlb_gather
for arbitary batches of map/unmap operations. The gather uses the free
list and it captures invalidations of tables, leaves and supports mixed
levels.
The introduction of PT_FEAT_DETAILED_GATHER provides some additional
information that is useful for ARM: the damage bitmaps for the table and
leaf changes.
Prior to switching SMMUv3 over to use iommupt prepare for this by
reworking the internal invalidation to work on the same data format that
iommupt will produce. Bridge the invalidations generated by io-pgtable
into the new format. The conversion is simple enough, io-pgtable generates
invalidation operations that have only a single set bit in
table_levels_bitmap/leaf_levels_bitmap, so we can convert the io-pgtable
provided size into the proper level leaf or table bit.
When iommupt uses this mechanism it will fill in full bitmaps reflecting
the union of all invalidations contained in the gather, and this series
provides an implementation that can work this way.
Like the other drivers the general algorithm focuses on trying to issue a quick
range command per gather or at most 512 single invalidations. If that isn't
possible then it falls back to full invalidation. Since table and leaf
invalidation are combined together there is no waste of invaliding tables prior
to performing an eventual full invalidation.
On its own this provides value as the invalidation has a number of
rough spots:
- Non-leaf invalidation actually expands into a TLBI for every
translation granule because the inner logic doesn't special case the
walk vs leaf condition. Now that a table_levels_bitmap is used to
describe the walk invalidation it properly generates a RIL with optimal
TTL or only one single invalidation.
- RIL doesn't calculate perfect hints for SVA because the SVA rules are
different from the io-pgtable-arm rules that the RIL algorithm works
with. SVA can now express the combined leaf and table invalidation that
the MM callback represents and get the right TTL, with an optimization
for the common 4k only scenario.
- RIL didn't generate a single invalidation like VT-d and AMD do, instead it
tries to generate an exact coverage with many smaller invalidations. Switch
it to more closely match the other drivers and produce at most 2 RILs.
The approach is to introduce a new struct arm_smmu_tlbi which
describes the invalidation, pre-compute into the tlbi the single and
range commands from the start/last and bitmaps, and then apply the
correct pre-computed command to each of items in the invalidation
list.
The RIL and single calculations are revised to use the new bitmaps and
accurately generate TTL/stride/etc. In the iommupt conversion series the
errata will be worked around in a way that is bounded to 3 RIL's using the
damage bitmaps.
Some of this design is to support another series to remove the batch on
the stack. Now that we have the invalidation list and the tlbi it is
simple to just expand the invs list directly into commands instead of
using the temporary on-stack batch array. Eventually removing batch will
save ~1k of stack usage here.
v5:
- Rebase to v7.3-rc1
- Fix the SVA CONT errata interaction
- Remove over invalidation, instead use two overlapping RILs
- Reflow patches around the errata work around
- Fix a race when eliding INV_TYPE_S2_VMID_S1_CLEAR
v4: https://patch.msgid.link/r/0-v4-1802653d8886+492-smmu_tlbi_jgg@nvidia.com
- Rebase on latest smmu branch (accomodate already merged IDR5_DS changes)
- Fix iopte_size typo in interior patches
- Tidy arm_smmu_ttl_addr_align() some more
v3: https://patch.msgid.link/r/0-v3-4e7f64f4e094+85e-smmu_tlbi_jgg@nvidia.com
- Carry the base translation granule in the TLBI description and pass the
domain separately
- Invalidate the leaves when doing a table invalidation too, corrects a
missed invalidation but means we don't do anything about the duplicate
invalidations.
- Simplify the control flow in a few places
- Clarify the TTL derivation and accomodate DS
v2: https://patch.msgid.link/r/0-v2-43074a57a53a+fb95-smmu_tlbi_jgg@nvidia.com
- Rebase to v7.2-rc1
v1: https://lore.kernel.org/all/0-v1-5b1ac97a5403+6588f-smmu_tlbi_jgg@nvidia.com/
Jason Gunthorpe (9):
iommu/arm-smmu-v3: Handle ARM erratum for CONT under invalidation with
SVA
iommu/arm-smmu-v3: Pass the parameters for the invalidation in a
struct
iommu/arm-smmu-v3: Move pgsize out of arm_smmu_inv
iommu/arm-smmu-v3: Optimize range invalidation for latency
iommu/arm-smmu-v3: Keep track in the arm_smmu_invs if RIL is used
iommu/arm-smmu-v3: Precompute the invalidation commands
iommu/arm-smmu-v3: Populate the tlbi at the top of the call chain
iommu/arm-smmu-v3: Change how the tlbi describes the invalidation
iommu/arm-smmu-v3: Support the DS expansion of RIL's SCALE
Documentation/arch/arm64/silicon-errata.rst | 3 +-
.../iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 40 +-
.../iommu/arm/arm-smmu-v3/arm-smmu-v3-test.c | 38 +-
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 537 +++++++++++++-----
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 67 ++-
5 files changed, 508 insertions(+), 177 deletions(-)
base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
--
2.43.0
next reply other threads:[~2026-09-01 17:50 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 17:49 Jason Gunthorpe [this message]
2026-09-01 17:49 ` [PATCH v5 1/9] iommu/arm-smmu-v3: Handle ARM erratum for CONT under invalidation with SVA Jason Gunthorpe
2026-09-07 14:21 ` Mostafa Saleh
2026-09-07 15:11 ` Jason Gunthorpe
2026-09-07 15:17 ` Mostafa Saleh
2026-09-07 15:18 ` Jason Gunthorpe
2026-09-01 17:49 ` [PATCH v5 2/9] iommu/arm-smmu-v3: Pass the parameters for the invalidation in a struct Jason Gunthorpe
2026-09-01 17:49 ` [PATCH v5 3/9] iommu/arm-smmu-v3: Move pgsize out of arm_smmu_inv Jason Gunthorpe
2026-09-07 14:22 ` Mostafa Saleh
2026-09-01 17:49 ` [PATCH v5 4/9] iommu/arm-smmu-v3: Optimize range invalidation for latency Jason Gunthorpe
2026-09-07 14:26 ` Mostafa Saleh
2026-09-07 15:23 ` Jason Gunthorpe
2026-09-07 19:34 ` Jason Gunthorpe
2026-09-01 17:49 ` [PATCH v5 5/9] iommu/arm-smmu-v3: Keep track in the arm_smmu_invs if RIL is used Jason Gunthorpe
2026-09-01 17:49 ` [PATCH v5 6/9] iommu/arm-smmu-v3: Precompute the invalidation commands Jason Gunthorpe
2026-09-07 14:27 ` Mostafa Saleh
2026-09-07 15:19 ` Jason Gunthorpe
2026-09-01 17:49 ` [PATCH v5 7/9] iommu/arm-smmu-v3: Populate the tlbi at the top of the call chain Jason Gunthorpe
2026-09-01 17:49 ` [PATCH v5 8/9] iommu/arm-smmu-v3: Change how the tlbi describes the invalidation Jason Gunthorpe
2026-09-07 14:42 ` Mostafa Saleh
2026-09-07 15:34 ` Jason Gunthorpe
2026-09-09 15:57 ` Jason Gunthorpe
2026-09-01 17:49 ` [PATCH v5 9/9] iommu/arm-smmu-v3: Support the DS expansion of RIL's SCALE Jason Gunthorpe
2026-09-07 14:44 ` Mostafa Saleh
2026-09-07 19:39 ` Jason Gunthorpe
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=0-v5-b810cf379bfc+13d738-smmu_tlbi_jgg@nvidia.com \
--to=jgg@nvidia.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=catalin.marinas@arm.com \
--cc=corbet@lwn.net \
--cc=dmatlack@google.com \
--cc=iommu@lists.linux.dev \
--cc=jean-philippe@linaro.org \
--cc=joro@8bytes.org \
--cc=jpb@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=nicolinc@nvidia.com \
--cc=pasha.tatashin@soleen.com \
--cc=patches@lists.linux.dev \
--cc=praan@google.com \
--cc=rdunlap@infradead.org \
--cc=robin.murphy@arm.com \
--cc=skhan@linuxfoundation.org \
--cc=skhawaja@google.com \
--cc=smostafa@google.com \
--cc=stable@vger.kernel.org \
--cc=vijayanand.jitta@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox