public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Nicolin Chen <nicolinc@nvidia.com>
Cc: will@kernel.org, robin.murphy@arm.com, joro@8bytes.org,
	jpb@kernel.org, praan@google.com, smostafa@google.com,
	linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev,
	linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org,
	jonathan.cameron@huawei.com
Subject: Re: [PATCH v4 09/10] iommu/arm-smmu-v3: Remove ASID/VMID from arm_smmu_domain
Date: Fri, 10 Apr 2026 20:25:00 -0300	[thread overview]
Message-ID: <20260410232500.GD2588311@nvidia.com> (raw)
In-Reply-To: <adl0aEfBAKmBsMs6@Asurada-Nvidia>

On Fri, Apr 10, 2026 at 03:06:32PM -0700, Nicolin Chen wrote:
> On Thu, Apr 09, 2026 at 09:27:34PM -0300, Jason Gunthorpe wrote:
> > On Thu, Mar 19, 2026 at 12:51:55PM -0700, Nicolin Chen wrote:
> > > 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 846a278fa5469..0e48264ccd01b 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
> > > @@ -300,14 +300,6 @@ static void arm_smmu_sva_domain_free(struct iommu_domain *domain)
> > >  	 */
> > >  	arm_smmu_domain_inv(smmu_domain);
> > >  
> > > -	/*
> > > -	 * Notice that the arm_smmu_mm_arch_invalidate_secondary_tlbs op can
> > > -	 * still be called/running at this point. We allow the ASID to be
> > > -	 * reused, and if there is a race then it just suffers harmless
> > > -	 * unnecessary invalidation.
> > > -	 */
> > > -	xa_erase(&arm_smmu_asid_xa, smmu_domain->cd.asid);
> > > -
> > 
> > I don't think this artifact has disappeared so the comment should
> > probably remain too. It has become slightly different because it is
> > now running under RCU protections so it will clear alot faster.
> 
> By taking a closer look, I think either the arm_smmu_domain_inv call
> above or any concurrent arm_smmu_mm_arch_invalidate_secondary_tlbs
> call is a NOP now?

That sounds right, with all the changes there should be no cache
flushing on the free path since it is now always flushed on detach, so
the arm_smmu_domain_inv() should be deleted here too.

> We reworked the ASID lifecycle, which now ends when the last device
> detaches. So, ASID was free-ed in arm_smmu_iotlb_tag_free() that did
> a per-ASID flush also.

Yes, so the comment is:

 Notice that the arm_smmu_mm_arch_invalidate_secondary_tlbs() op can
 still be called/running at this point. Like the normal detach flow
 the RCU protected ASID may still experiance harmless invalidation.
 However unlike normal domains the SVA invalidation will continue
 into free until the mmu_notifier_put().

> So, when freeing the SVA domain here, the domain should have an empty
> invalidation array and the HW cache is flushed as well, right?

Yes, but the parallel thread is still possible even in free which is
unusual compared to normal domains where it is illegal to call
map/unmap concurrently with free.

Jason


  reply	other threads:[~2026-04-10 23:25 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-19 19:51 [PATCH v4 00/10] iommu/arm-smmu-v3: Share domain across SMMU/vSMMU instances Nicolin Chen
2026-03-19 19:51 ` [PATCH v4 01/10] iommu/arm-smmu-v3: Add a wrapper for arm_smmu_make_sva_cd() Nicolin Chen
2026-04-09 23:14   ` Jason Gunthorpe
2026-03-19 19:51 ` [PATCH v4 02/10] iommu/arm-smmu-v3: Pass in arm_smmu_make_cd_fn to arm_smmu_set_pasid() Nicolin Chen
2026-04-09 23:17   ` Jason Gunthorpe
2026-03-19 19:51 ` [PATCH v4 03/10] iommu/arm-smmu-v3: Store IOTLB cache tags in struct arm_smmu_attach_state Nicolin Chen
2026-04-09 23:42   ` Jason Gunthorpe
2026-04-10 18:52     ` Nicolin Chen
2026-04-10 20:47       ` Jason Gunthorpe
2026-04-10 21:23         ` Nicolin Chen
2026-04-10 21:41           ` Jason Gunthorpe
2026-04-10 23:04             ` Nicolin Chen
2026-03-19 19:51 ` [PATCH v4 04/10] iommu/arm-smmu-v3: Pass in IOTLB cache tag to arm_smmu_master_build_invs() Nicolin Chen
2026-04-09 23:43   ` Jason Gunthorpe
2026-03-19 19:51 ` [PATCH v4 05/10] iommu/arm-smmu-v3: Pass in IOTLB cache tag to CD and STE Nicolin Chen
2026-03-19 19:51 ` [PATCH v4 06/10] iommu/arm-smmu-v3: Introduce INV_TYPE_S2_VMID_VSMMU Nicolin Chen
2026-04-09 23:59   ` Jason Gunthorpe
2026-04-10 22:32     ` Nicolin Chen
2026-03-19 19:51 ` [PATCH v4 07/10] iommu/arm-smmu-v3: Allocate IOTLB cache tag if no id to reuse Nicolin Chen
2026-04-10  0:04   ` Jason Gunthorpe
2026-03-19 19:51 ` [PATCH v4 08/10] iommu/arm-smmu-v3: Allocate INV_TYPE_S2_VMID_VSMMU in arm_vsmmu_init Nicolin Chen
2026-04-10  0:19   ` Jason Gunthorpe
2026-03-19 19:51 ` [PATCH v4 09/10] iommu/arm-smmu-v3: Remove ASID/VMID from arm_smmu_domain Nicolin Chen
2026-04-10  0:27   ` Jason Gunthorpe
2026-04-10 22:06     ` Nicolin Chen
2026-04-10 23:25       ` Jason Gunthorpe [this message]
2026-04-11  0:06         ` Nicolin Chen
2026-03-19 19:51 ` [PATCH v4 10/10] iommu/arm-smmu-v3: Allow sharing domain across SMMUs Nicolin Chen
2026-04-10  0:32   ` Jason Gunthorpe
2026-04-10  0:36     ` Jason Gunthorpe
2026-04-10  1:18       ` Nicolin Chen

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=20260410232500.GD2588311@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=iommu@lists.linux.dev \
    --cc=jonathan.cameron@huawei.com \
    --cc=joro@8bytes.org \
    --cc=jpb@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=nicolinc@nvidia.com \
    --cc=praan@google.com \
    --cc=robin.murphy@arm.com \
    --cc=smostafa@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox