From: Mostafa Saleh <smostafa@google.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: iommu@lists.linux.dev, "Joerg Roedel (AMD)" <joro@8bytes.org>,
Jean-Philippe Brucker <jpb@kernel.org>,
linux-arm-kernel@lists.infradead.org,
Robin Murphy <robin.murphy@arm.com>,
Will Deacon <will@kernel.org>,
David Matlack <dmatlack@google.com>,
Pasha Tatashin <pasha.tatashin@soleen.com>,
patches@lists.linux.dev, Pranjal Shrivastava <praan@google.com>,
Samiullah Khawaja <skhawaja@google.com>
Subject: Re: [PATCH v2 6/8] iommu/arm-smmu-v3: Populate the tlbi at the top of the call chain
Date: Tue, 7 Jul 2026 11:57:41 +0000 [thread overview]
Message-ID: <akzptWVIihnH79Hb@google.com> (raw)
In-Reply-To: <6-v2-43074a57a53a+fb95-smmu_tlbi_jgg@nvidia.com>
On Mon, Jul 06, 2026 at 01:26:43PM -0300, Jason Gunthorpe wrote:
> Each of these has their own unique situation, populate the tlbi right
> at the top and pass it into arm_smmu_domain_inv_range(). They will
> diverge further when the iommupt invalidation scheme is introduced.
>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> ---
> .../iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 21 ++++----
> drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 51 +++++++++----------
> drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 13 +++--
> 3 files changed, 45 insertions(+), 40 deletions(-)
>
> diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c
> index 5d4dde3d1cfe87..e6001913e2b043 100644
> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c
> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c
> @@ -139,16 +139,19 @@ static void arm_smmu_mm_arch_invalidate_secondary_tlbs(struct mmu_notifier *mn,
> {
> struct arm_smmu_domain *smmu_domain =
> container_of(mn, struct arm_smmu_domain, mmu_notifier);
> - size_t size;
> + struct arm_smmu_tlbi tlbi = {
> + .smmu_domain = smmu_domain,
> + .iova = start,
> + /*
> + * The mm_types defines vm_end as the first byte after the end
> + * address, different from IOMMU subsystem using the last
> + * address of an address range.
> + */
> + .size = end - start,
> + .iopte_granule = PAGE_SIZE,
> + };
>
> - /*
> - * The mm_types defines vm_end as the first byte after the end address,
> - * different from IOMMU subsystem using the last address of an address
> - * range. So do a simple translation here by calculating size correctly.
> - */
> - size = end - start;
> -
> - arm_smmu_domain_inv_range(smmu_domain, start, size, PAGE_SIZE, false);
> + arm_smmu_domain_tlbi(&tlbi);
> }
>
> static void arm_smmu_mm_release(struct mmu_notifier *mn, struct mm_struct *mm)
> diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> index fbe3e5dc42f964..2e477f15080148 100644
> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> @@ -2661,25 +2661,12 @@ static void arm_smmu_domain_tlbi_inv(struct arm_smmu_tlbi *tlbi,
> }
> }
>
> -void arm_smmu_domain_inv_range(struct arm_smmu_domain *smmu_domain,
> - unsigned long iova, size_t size,
> - unsigned int granule, bool leaf)
> +void arm_smmu_domain_tlbi(struct arm_smmu_tlbi *tlbi)
> {
> - struct arm_smmu_tlbi tlbi = {
> - .smmu_domain = smmu_domain,
> - .iova = iova,
> - .size = size,
> - .iopte_granule = granule,
> - .leaf_only = leaf,
> - };
> struct arm_smmu_invs *invs;
>
> - if (!size || size == SIZE_MAX) {
> - tlbi.single.use_full_inv = true;
> - tlbi.range.use_full_inv = true;
> - } else {
> - arm_smmu_tlbi_calc_single(&tlbi);
> - }
> + if (!tlbi->single.use_full_inv)
> + arm_smmu_tlbi_calc_single(tlbi);
>
> /*
> * An invalidation request must follow some IOPTE change and then load
The rest of the comment still refers to the old name
arm_smmu_domain_inv_range()
> @@ -2709,14 +2696,14 @@ void arm_smmu_domain_inv_range(struct arm_smmu_domain *smmu_domain,
> smp_mb();
>
> rcu_read_lock();
> - invs = rcu_dereference(smmu_domain->invs);
> + invs = rcu_dereference(tlbi->smmu_domain->invs);
>
> /* Only precaculate RIL if it will be used. */
> if (invs->has_range_inv) {
> - if (!tlbi.range.use_full_inv)
> - arm_smmu_tlbi_calc_range(&tlbi);
> + if (!tlbi->range.use_full_inv)
> + arm_smmu_tlbi_calc_range(tlbi);
> } else {
> - tlbi.range.use_full_inv = true;
> + tlbi->range.use_full_inv = true;
> }
>
> /*
> @@ -2727,10 +2714,10 @@ void arm_smmu_domain_inv_range(struct arm_smmu_domain *smmu_domain,
> unsigned long flags;
>
> read_lock_irqsave(&invs->rwlock, flags);
> - arm_smmu_domain_tlbi_inv(&tlbi, invs);
> + arm_smmu_domain_tlbi_inv(tlbi, invs);
> read_unlock_irqrestore(&invs->rwlock, flags);
> } else {
> - arm_smmu_domain_tlbi_inv(&tlbi, invs);
> + arm_smmu_domain_tlbi_inv(tlbi, invs);
> }
>
> rcu_read_unlock();
> @@ -2750,8 +2737,14 @@ static void arm_smmu_tlb_inv_walk(unsigned long iova, size_t size,
> size_t granule, void *cookie)
> {
> struct arm_smmu_domain *smmu_domain = cookie;
> + struct arm_smmu_tlbi tlbi = {
> + .smmu_domain = smmu_domain,
> + .iova = iova,
> + .size = size,
> + .iopte_granule = granule,
> + };
>
> - arm_smmu_domain_inv_range(smmu_domain, iova, size, granule, false);
> + arm_smmu_domain_tlbi(&tlbi);
> }
>
> static const struct iommu_flush_ops arm_smmu_flush_ops = {
> @@ -4018,14 +4011,18 @@ static void arm_smmu_flush_iotlb_all(struct iommu_domain *domain)
> static void arm_smmu_iotlb_sync(struct iommu_domain *domain,
> struct iommu_iotlb_gather *gather)
> {
> - struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
> + struct arm_smmu_tlbi tlbi = {
> + .smmu_domain = to_smmu_domain(domain),
> + .iova = gather->start,
> + .size = gather->end - gather->start + 1,
> + .iopte_granule = gather->pgsize,
> + .leaf_only = true,
> + };
>
> if (!gather->pgsize)
> return;
>
> - arm_smmu_domain_inv_range(smmu_domain, gather->start,
> - gather->end - gather->start + 1,
> - gather->pgsize, true);
> + arm_smmu_domain_tlbi(&tlbi);
> }
>
> static phys_addr_t
> diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h
> index 9d262ef6076225..5f97d1a63ebbfd 100644
> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h
> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h
> @@ -1169,13 +1169,18 @@ int arm_smmu_set_pasid(struct arm_smmu_master *master,
> struct arm_smmu_domain *smmu_domain, ioasid_t pasid,
> struct arm_smmu_cd *cd, struct iommu_domain *old);
>
> -void arm_smmu_domain_inv_range(struct arm_smmu_domain *smmu_domain,
> - unsigned long iova, size_t size,
> - unsigned int granule, bool leaf);
> +void arm_smmu_domain_tlbi(struct arm_smmu_tlbi *tlbi);
>
> static inline void arm_smmu_domain_inv(struct arm_smmu_domain *smmu_domain)
> {
> - arm_smmu_domain_inv_range(smmu_domain, 0, 0, 0, false);
> + /* Prefilled for invalidate all */
> + struct arm_smmu_tlbi tlbi = {
> + .smmu_domain = smmu_domain,
> + .single.use_full_inv = true,
> + .range.use_full_inv = true,
Those were introduced last patch, but I am wondering if use_full_inv
should be a common field instead of having it in both single and range.
Thanks,
Mostafa
> + };
> +
> + arm_smmu_domain_tlbi(&tlbi);
> }
>
> void __arm_smmu_cmdq_skip_err(struct arm_smmu_device *smmu,
> --
> 2.43.0
>
next prev parent reply other threads:[~2026-07-07 11:57 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 16:26 [PATCH v2 0/8] Organize the SMMUv3 invalidation flow so iommupt can use it Jason Gunthorpe
2026-07-06 16:26 ` [PATCH v2 1/8] iommu/arm-smmu-v3: Pass the parameters for the invalidation in a struct Jason Gunthorpe
2026-07-07 3:04 ` Nicolin Chen
2026-07-07 11:18 ` Mostafa Saleh
2026-07-06 16:26 ` [PATCH v2 2/8] iommu/arm-smmu-v3: Move pgsize out of arm_smmu_inv Jason Gunthorpe
2026-07-07 3:57 ` Nicolin Chen
2026-07-07 16:15 ` Jason Gunthorpe
2026-07-07 17:21 ` Nicolin Chen
2026-07-08 18:43 ` Jason Gunthorpe
2026-07-07 11:24 ` Mostafa Saleh
2026-07-07 18:08 ` Jason Gunthorpe
2026-07-11 17:38 ` Daniel Mentz
2026-07-10 4:06 ` Daniel Mentz
2026-07-10 14:28 ` Jason Gunthorpe
2026-07-06 16:26 ` [PATCH v2 3/8] iommu/arm-smmu-v3: Optimize range invalidation for latency Jason Gunthorpe
2026-07-07 7:27 ` Nicolin Chen
2026-07-07 19:13 ` Jason Gunthorpe
2026-07-07 21:07 ` Nicolin Chen
2026-07-07 11:45 ` Mostafa Saleh
2026-07-08 0:10 ` Jason Gunthorpe
2026-07-06 16:26 ` [PATCH v2 4/8] iommu/arm-smmu-v3: Keep track in the arm_smmu_invs if RIL is used Jason Gunthorpe
2026-07-07 7:27 ` Nicolin Chen
2026-07-07 11:46 ` Mostafa Saleh
2026-07-06 16:26 ` [PATCH v2 5/8] iommu/arm-smmu-v3: Precompute the invalidation commands Jason Gunthorpe
2026-07-07 11:52 ` Mostafa Saleh
2026-07-07 14:58 ` Jason Gunthorpe
2026-07-08 9:00 ` Mostafa Saleh
2026-07-08 13:15 ` Jason Gunthorpe
2026-07-07 20:31 ` Nicolin Chen
2026-07-09 12:07 ` Jason Gunthorpe
2026-07-09 19:10 ` Nicolin Chen
2026-07-06 16:26 ` [PATCH v2 6/8] iommu/arm-smmu-v3: Populate the tlbi at the top of the call chain Jason Gunthorpe
2026-07-07 11:57 ` Mostafa Saleh [this message]
2026-07-08 18:09 ` Jason Gunthorpe
2026-07-07 21:51 ` Nicolin Chen
2026-07-08 18:40 ` Jason Gunthorpe
2026-07-06 16:26 ` [PATCH v2 7/8] iommu/arm-smmu-v3: Change how the tlbi describes the invalidation Jason Gunthorpe
2026-07-06 18:00 ` Robin Murphy
2026-07-06 19:45 ` Jason Gunthorpe
2026-07-08 1:41 ` Nicolin Chen
2026-07-08 18:27 ` Jason Gunthorpe
2026-07-08 5:29 ` Nicolin Chen
2026-07-09 18:25 ` Jason Gunthorpe
2026-07-09 21:32 ` Nicolin Chen
2026-07-06 16:26 ` [PATCH v2 8/8] iommu/arm-smmu-v3: Support the DS expansion of RIL's SCALE Jason Gunthorpe
2026-07-07 23:20 ` Nicolin Chen
2026-07-08 0:02 ` Jason Gunthorpe
2026-07-08 2:10 ` Nicolin Chen
2026-07-08 13:05 ` Jason Gunthorpe
2026-07-07 12:25 ` [PATCH v2 0/8] Organize the SMMUv3 invalidation flow so iommupt can use it Mostafa Saleh
2026-07-07 15:00 ` 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=akzptWVIihnH79Hb@google.com \
--to=smostafa@google.com \
--cc=dmatlack@google.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@nvidia.com \
--cc=joro@8bytes.org \
--cc=jpb@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=pasha.tatashin@soleen.com \
--cc=patches@lists.linux.dev \
--cc=praan@google.com \
--cc=robin.murphy@arm.com \
--cc=skhawaja@google.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.