All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicolin Chen <nicolinc@nvidia.com>
To: Peng Fan <peng.fan@linux.dev>
Cc: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>,
	Will Deacon <will@kernel.org>,
	Robin Murphy <robin.murphy@arm.com>,
	Jason Gunthorpe <jgg@ziepe.ca>,
	"Joerg Roedel (AMD)" <joro@8bytes.org>,
	Thierry Reding <thierry.reding@kernel.org>,
	Krishna Reddy <vdumpa@nvidia.com>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	Jean-Philippe Brucker <jpb@kernel.org>,
	<linux-arm-kernel@lists.infradead.org>, <iommu@lists.linux.dev>,
	<linux-kernel@vger.kernel.org>, <linux-tegra@vger.kernel.org>,
	Peng Fan <peng.fan@nxp.com>
Subject: Re: [PATCH RFC v7 4/7] iommu/arm-smmu-v3: Use a per-domain CD table for non-PASID streams
Date: Mon, 9 Nov 2026 11:41:49 -0800	[thread overview]
Message-ID: <avIh/TUA3rPsytWw@nvidia.com> (raw)
In-Reply-To: <au8iwj68zXO1us_8@fedora>

On Sat, Nov 07, 2026 at 09:08:18PM +0800, Peng Fan wrote:
> On Fri, Oct 30, 2026 at 06:07:16PM -0700, Nicolin Chen wrote:
> >On Fri, Oct 30, 2026 at 08:09:36PM +0800, Peng Fan (OSS) wrote:
> >>  	if (!arm_smmu_ssids_in_use(&master->cd_table)) {
> >>  		struct iommu_domain *sid_domain =
> >>  			iommu_driver_get_domain_for_dev(master->dev);
> >>  		bool ats_always_on = master->ats_always_on &&
> >>  				     sid_domain->type != IOMMU_DOMAIN_BLOCKED;
> >> -		bool downgrade = sid_domain->type == IOMMU_DOMAIN_IDENTITY ||
> >> -				 sid_domain->type == IOMMU_DOMAIN_BLOCKED;
> >> +		bool s1 = (sid_domain->type & __IOMMU_DOMAIN_PAGING) &&
> >> +			  to_smmu_domain(sid_domain)->stage ==
> >> +				  ARM_SMMU_DOMAIN_S1;
> >>  
> >> -		if (!ats_always_on && downgrade)
> >> -			sid_domain->ops->attach_dev(sid_domain, dev,
> >> -						    sid_domain);
> >> +		if (!ats_always_on &&
> >> +		    (s1 || sid_domain->type == IOMMU_DOMAIN_IDENTITY ||
> >> +		     sid_domain->type == IOMMU_DOMAIN_BLOCKED))
> >> +			ret = sid_domain->ops->attach_dev(sid_domain, dev,
> >> +							  sid_domain);
> >
> >This covers almost all the possible domain types here. So, just
> >drop that downgrade, and it should cover the other cases:
> >
> >		if (!ats_always_on)
> 
> Thanks, I agree the reachable set here is only S1/identity/blocked, and the
> outer condition is effectively !ats_always_on. The separate downgrade
> check is gone in v8.
> 
> However, I don't think we can fold the inner check into a single
> attach_dev() call for all cases. For an S1 RID domain this is a PASID
> teardown path, and arm_smmu_attach_dev() -> arm_smmu_attach_prepare() can
> allocate with GFP_KERNEL and return -ENOMEM. The IOMMU core requires
> set_dev_pasid() not to fail here,

You got the point that S1 shouldn't propagate the return code.

The non-S1 case is the previous "downgrade" path, which didn't
propagate the return code either.

So what I was saying is simply:
-		if (!ats_always_on && downgrade)
+		if (!ats_always_on)
 			sid_domain->ops->attach_dev(sid_domain, dev,
 						    sid_domain);

Nicolin

  reply	other threads:[~2026-11-09 19:42 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-30 12:09 [PATCH RFC v7 0/7] iommu/arm-smmu-v3: Support shared Stream IDs Peng Fan (OSS)
2026-10-30 12:09 ` [PATCH RFC v7 1/7] iommu/arm-smmu-v3: Allocate streams individually Peng Fan (OSS)
2026-10-30 12:09 ` [PATCH RFC v7 2/7] iommu/arm-smmu-v3: Delay stream allocation to inside the mutex Peng Fan (OSS)
2026-10-30 12:09 ` [PATCH RFC v7 3/7] iommu/arm-smmu-v3: Plumb the CD table into the CD helpers Peng Fan (OSS)
2026-10-30 20:54   ` Nicolin Chen
2026-10-30 12:09 ` [PATCH RFC v7 4/7] iommu/arm-smmu-v3: Use a per-domain CD table for non-PASID streams Peng Fan (OSS)
2026-10-31  1:07   ` Nicolin Chen
2026-11-07 13:08     ` Peng Fan
2026-11-09 19:41       ` Nicolin Chen [this message]
2026-10-30 12:09 ` [PATCH RFC v7 5/7] iommu/arm-smmu-v3: Support shared SIDs in insert/remove_master Peng Fan (OSS)
2026-10-30 12:09 ` [PATCH RFC v7 6/7] iommu/arm-smmu-v3: Group aliasing devices into the same IOMMU group Peng Fan (OSS)
2026-11-02 18:31   ` Nicolin Chen
2026-10-30 12:09 ` [PATCH RFC v7 7/7] iommu/arm-smmu-v3: Wire up shared-SID STE ordering and feature gating Peng Fan (OSS)
2026-11-02 18:49   ` Nicolin Chen
2026-11-07 13:14     ` Peng Fan

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=avIh/TUA3rPsytWw@nvidia.com \
    --to=nicolinc@nvidia.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@ziepe.ca \
    --cc=jonathanh@nvidia.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=peng.fan@linux.dev \
    --cc=peng.fan@nxp.com \
    --cc=peng.fan@oss.nxp.com \
    --cc=robin.murphy@arm.com \
    --cc=thierry.reding@kernel.org \
    --cc=vdumpa@nvidia.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.