mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Robin Murphy <robin.murphy@arm.com>
To: Nicolin Chen <nicolinc@nvidia.com>, Peng Fan <peng.fan@oss.nxp.com>
Cc: Will Deacon <will@kernel.org>,
	"Joerg Roedel (AMD)" <joro@8bytes.org>,
	Jean-Philippe Brucker <jpb@kernel.org>,
	Jason Gunthorpe <jgg@ziepe.ca>,
	Thierry Reding <thierry.reding@kernel.org>,
	Krishna Reddy <vdumpa@nvidia.com>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	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 v6 5/5] iommu/arm-smmu-v3: Wire up shared-SID STE ordering and feature gating
Date: Tue, 13 Oct 2026 12:22:06 +0100	[thread overview]
Message-ID: <e8c22eb2-ed1f-47c7-b2ac-c56ead1cba8b@arm.com> (raw)
In-Reply-To: <as1zR1wc7ERxvR1F@nvidia.com>

On 13/10/2026 12:54 am, Nicolin Chen wrote:
> On Mon, Oct 12, 2026 at 09:23:32PM +0800, Peng Fan wrote:
>>> +static bool arm_smmu_skip_shared_ste(struct arm_smmu_device *smmu,
>>> +				     u32 sid, bool is_abort)
>>> +{
>>> +	struct arm_smmu_stream *stream;
>>> +
>>> +	lockdep_assert_held(&smmu->streams_mutex);
>>> +
>>> +	stream = arm_smmu_find_stream(smmu, sid);
>>> +	if (!stream || list_empty(&stream->shared_masters))
>>> +		return false;
>>> +
>>> +	if (is_abort) {
>>> +		stream->ste_installed = false;
>>> +		return true;
>>> +	}
>>> +	if (stream->ste_installed)
>>> +		return true;
>>> +	stream->ste_installed = true;
>>> +	return false;
>>
>> sashiko has comments: https://sashiko.dev/#/patchset/20261011-smmu-shared-sid-v6-0-cb76b89dc612%40nxp.com
>>
>> We just need to support a simple case that platform devices(single SID) which
>> could share there SIDs, such as MMC-0 and MMC-1 share one SID.
>>
>> Shared-SID masters are restricted to platform devices sharing a single SID.
>> SVA, IOPF, and vSMMU nesting are all rejected for shared-SID masters (patch 5),
>> so VFIO passthrough and direct domain replacement scenarios do not apply.
>> The only domain transitions are the default DMA domain attach at probe time
>> and ABORT on unbind. Or I may miss something.
>   
> Domain can be switched between DMA and IDENTITY via sysfs.
> 
> I think there should be a way to support that. But, without a concrete
> use case, it might be easier to add this into the attach_dev callbacks
> (except arm_smmu_attach_dev_blocked):
> 
> 	if (arm_smmu_master_shares_sid(master) &&
> 	    old_domain && old_domain != domain &&
> 	    old_domain != &arm_smmu_blocked_domain)
> 		return -EBUSY;
> 
> And Sashiko's second remark does reveal a real bug:
> "Additionally, when devices are detached from a domain, is_abort is true.
>   arm_smmu_skip_shared_ste() clears ste_installed but unconditionally returns
>   true for all masters. Will this cause the ABORT STE to never be written to
>   hardware?"
> 
> Given that your use case always group SID-sharing masters in the same
> iommu_group and attach/replace a domain on those masters together, I
> think a simpler solution can be to always let stream->master install
> the shared STE.
> 
> One pitfall would be the release domain's attach_dev, which would go
> through arm_smmu_attach_dev_blocked() just like a blocked domain. So,
> it has to skip correctly if the shared stream->master == master. This
> means we might have to add a separate arm_smmu_attach_dev_release().

Hmm, but in fact why are we worrying about skipping things at all? Yes 
originally trying to rewrite a "live" STE was a problem, but since 
Jason's redesign, isn't arm_smmu_write_ste() just going to see that the 
"new" entry is identical to what's already there and happily do nothing?

> And I realized that there is another problem in your design: the CD
> table is still allocated per master; see arm_smmu_alloc_cd_ptr(). If
> STE is shared, its CD table must be shared too.

If we're not going to support PASID for shared streams (which I suggest 
we don't...) than we shouldn't strictly need to worry about CD tables 
anyway. So rather than having to special-case CD table sharing for 
shared streams, perhaps it might make sense to generalise back to a 
"default" per-domain CD for non-PASID use, which can then get switched 
for the private per-stream cd_table if and when a device does enable PASID?

Thanks,
Robin.

> You'd need to redirect all the master->cd_table with something like:
> 
> static struct arm_smmu_master *arm_smmu_cd_owner(struct arm_smmu_master *master)
> {
> 	if (arm_smmu_master_shares_sid(master)) {
> 		int i;
> 
> 		for (i = 0; i < master->num_streams; i++) {
> 			struct arm_smmu_stream *stream = master->streams[i];
> 
> 			if (!list_empty(&stream->shared_masters))
> 				return stream->master;
> 		}
> 	}
> 
> 	return master;
> }
> 
>>> @@ -4360,9 +4391,11 @@ static int arm_smmu_insert_master(struct arm_smmu_device *smmu,
>> I am thinking to simplify reject if stall_enabled is true:
>>   			if (list_empty(&stream->shared_masters)) {
>> +				if (stream->master->stall_enabled) {
>> +					dev_warn(master->dev,
>> +						 "Shared StreamID 0x%x rejected: existing master has stall enabled\n",
>> +						 sid);
>> +					ret = -EBUSY;
>> +					break;
>> +				}
>   
> I'd move it upwards: next to the existing "num_streams != 1" guard.
> 
> Nicolin


  reply	other threads:[~2026-10-13 11:22 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-11 11:31 [PATCH RFC v6 0/5] iommu/arm-smmu-v3: Support shared Stream IDs Peng Fan (OSS)
2026-10-11 11:31 ` [PATCH RFC v6 1/5] iommu/arm-smmu-v3: Allocate streams individually Peng Fan (OSS)
2026-10-11 11:31 ` [PATCH RFC v6 2/5] iommu/arm-smmu-v3: Delay stream allocation to inside the mutex Peng Fan (OSS)
2026-10-12 20:36   ` Nicolin Chen
2026-10-11 11:31 ` [PATCH RFC v6 3/5] iommu/arm-smmu-v3: Support shared SIDs in insert/remove_master Peng Fan (OSS)
2026-10-12 20:48   ` Nicolin Chen
2026-10-11 11:31 ` [PATCH RFC v6 4/5] iommu/arm-smmu-v3: Group aliasing devices into the same IOMMU group Peng Fan (OSS)
2026-10-12 12:24   ` Peng Fan
2026-10-12 13:05     ` Robin Murphy
2026-10-11 11:31 ` [PATCH RFC v6 5/5] iommu/arm-smmu-v3: Wire up shared-SID STE ordering and feature gating Peng Fan (OSS)
2026-10-12 13:23   ` Peng Fan
2026-10-12 23:54     ` Nicolin Chen
2026-10-13 11:22       ` Robin Murphy [this message]
2026-10-13 12:44         ` 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=e8c22eb2-ed1f-47c7-b2ac-c56ead1cba8b@arm.com \
    --to=robin.murphy@arm.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=nicolinc@nvidia.com \
    --cc=peng.fan@nxp.com \
    --cc=peng.fan@oss.nxp.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®