From: Nicolin Chen <nicolinc@nvidia.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: Robin Murphy <robin.murphy@arm.com>, <will@kernel.org>,
<joro@8bytes.org>, <jsnitsel@redhat.com>, <praan@google.com>,
<linux-arm-kernel@lists.infradead.org>, <iommu@lists.linux.dev>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] iommu/arm-smmu-v3: Allow stream table to have nodes with the same ID
Date: Sat, 12 Apr 2025 10:03:42 -0700 [thread overview]
Message-ID: <Z/qc7vdko9bU3otR@Asurada-Nvidia> (raw)
In-Reply-To: <20250412135514.GA329420@nvidia.com>
On Sat, Apr 12, 2025 at 10:55:14AM -0300, Jason Gunthorpe wrote:
> On Fri, Apr 11, 2025 at 08:39:36PM -0700, Nicolin Chen wrote:
> 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 b4c21aaed1266a..97b9f8d7fb3340 100644
> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> @@ -3389,6 +3389,7 @@ static int arm_smmu_insert_master(struct arm_smmu_device *smmu,
> for (i = 0; i < fwspec->num_ids; i++) {
> struct arm_smmu_stream *new_stream = &master->streams[i];
> u32 sid = fwspec->ids[i];
> + struct rb_node *existing;
>
> new_stream->id = sid;
> new_stream->master = master;
> @@ -3398,10 +3399,20 @@ static int arm_smmu_insert_master(struct arm_smmu_device *smmu,
> break;
>
> /* Insert into SID tree */
> - if (rb_find_add(&new_stream->node, &smmu->streams,
> - arm_smmu_streams_cmp_node)) {
> - dev_warn(master->dev, "stream %u already in tree\n",
> - sid);
> + existing = rb_find_add(&new_stream->node, &smmu->streams,
> + arm_smmu_streams_cmp_node);
Oh right, it does find() already.
> + if (existing) {
> + struct arm_smmu_master *existing_master =
> + rb_entry(existing, struct arm_smmu_stream, node)
> + ->master;
> +
> + /* Bridged PCI devices may end up with duplicated IDs */
> + if (existing_master == master)
> + continue;
> +
> + dev_warn(master->dev,
> + "stream %u already in tree from dev %s\n", sid,
> + dev_name(existing_master->dev));
> ret = -EINVAL;
> break;
> }
>
> It seems like a reasonable rc fix, and if nobody has cared about DMA
> Alias support since it was broken in 2021 maybe we just leave it.
I will wrap it up and make a note with that.
Thanks!
Nicolin
prev parent reply other threads:[~2025-04-12 17:06 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-11 4:47 [PATCH] iommu/arm-smmu-v3: Allow stream table to have nodes with the same ID Nicolin Chen
2025-04-11 11:45 ` Jason Gunthorpe
2025-04-11 12:10 ` Robin Murphy
2025-04-11 13:01 ` Jason Gunthorpe
2025-04-11 13:35 ` Pranjal Shrivastava
2025-04-11 13:42 ` Jason Gunthorpe
2025-04-11 15:13 ` Robin Murphy
2025-04-11 23:33 ` Nicolin Chen
2025-04-11 23:44 ` Jason Gunthorpe
2025-04-12 0:07 ` Nicolin Chen
2025-04-12 3:39 ` Nicolin Chen
2025-04-12 13:55 ` Jason Gunthorpe
2025-04-12 17:03 ` Nicolin Chen [this message]
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=Z/qc7vdko9bU3otR@Asurada-Nvidia \
--to=nicolinc@nvidia.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@nvidia.com \
--cc=joro@8bytes.org \
--cc=jsnitsel@redhat.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=praan@google.com \
--cc=robin.murphy@arm.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