[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Z/qc7vdko9bU3otR@Asurada-Nvidia>
Date: Sat, 12 Apr 2025 10:03:42 -0700
From: Nicolin Chen <nicolinc@...dia.com>
To: Jason Gunthorpe <jgg@...dia.com>
CC: Robin Murphy <robin.murphy@....com>, <will@...nel.org>, <joro@...tes.org>,
<jsnitsel@...hat.com>, <praan@...gle.com>,
<linux-arm-kernel@...ts.infradead.org>, <iommu@...ts.linux.dev>,
<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] iommu/arm-smmu-v3: Allow stream table to have nodes with
the same ID
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
Powered by blists - more mailing lists