All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Robin Murphy <robin.murphy@arm.com>
Cc: joro@8bytes.org, will@kernel.org, iommu@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org, nicolinc@nvidia.com
Subject: Re: [PATCH] iommu/arm-smmu-v3: Fail aliasing StreamIDs more gracefully
Date: Fri, 11 Apr 2025 12:21:22 -0300	[thread overview]
Message-ID: <20250411152122.GF8423@nvidia.com> (raw)
In-Reply-To: <39d54e49c8476efc4653e352150d44b185d6d50f.1744380554.git.robin.murphy@arm.com>

On Fri, Apr 11, 2025 at 03:09:14PM +0100, Robin Murphy wrote:
> We've never supported StreamID aliasing between devices, and as such
> they will never have had functioning DMA, but this is not fatal to the
> SMMU itself. Although aliasing between hard-wired platform device
> StreamIDs would tend to raise questions about the whole system, in
> practice it's far more likely to occur relatively innocently due to
> legacy PCI bridges, where the underlying StreamID mappings are still
> perfectly reasonable.
> 
> As such, return a more benign -ENODEV when failing probe for such an
> unsupported device (and log a more obvious error message), so that it
> doesn't break the entire SMMU probe now that bus_iommu_probe() runs in
> the right order and can propagate that error back. The end result is
> still that the device doesn't get an IOMMU group and probably won't
> work, same as before.
> 
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> ---
>  drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> 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 b4c21aaed126..c06459f7077b 100644
> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> @@ -3400,9 +3400,9 @@ static int arm_smmu_insert_master(struct arm_smmu_device *smmu,
>  		/* 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",
> +			dev_warn(master->dev, "Aliasing StreamID 0x%x unsupported, expect DMA to be broken\n",
>  				 sid);
> -			ret = -EINVAL;
> +			ret = -ENODEV;
>  			break;

I don't think we should dillute the meaning of ENODEV here. It is
supposed to mean that the driver does not recognize the device and
this IOMMU instance doesn't translate for it.

That is different from the iommu instance owning the device but being
unable to probe it for some reason. The failure recovery in the core
code should be different.

IMHO it makes more sense to change this and related:

static int bus_iommu_probe(const struct bus_type *bus)
{
	struct iommu_group *group, *next;
	LIST_HEAD(group_list);
	int ret;

	ret = bus_for_each_dev(bus, NULL, &group_list, probe_iommu_group);
	if (ret)
		return ret;

So that recognized, but failed, devices are contained to only effect
that device and do not fail the entire iommu or bus registration,
which is more like how things used to work when the probe path would
ignore the per-driver failure codes.

I can't think of a reason why we'd want any per-device failure to also
abort the whole iommu registration??

It would be nice if the dev->iommu would record that the struct device
is inoperable and then we can fail
iommu_device_use_default_domain()/etc in a contained way.

Jason


  reply	other threads:[~2025-04-11 15:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-11 14:09 [PATCH] iommu/arm-smmu-v3: Fail aliasing StreamIDs more gracefully Robin Murphy
2025-04-11 15:21 ` Jason Gunthorpe [this message]
2025-04-11 15:50   ` Pranjal Shrivastava
2025-04-11 15:58     ` Jason Gunthorpe
2025-04-11 18:16   ` Robin Murphy
2025-04-11 18:46     ` Jason Gunthorpe
2025-04-17 14:27 ` Will Deacon

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=20250411152122.GF8423@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=iommu@lists.linux.dev \
    --cc=joro@8bytes.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=nicolinc@nvidia.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 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.