All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Will Deacon <will@kernel.org>
Cc: Nicolin Chen <nicolinc@nvidia.com>,
	joro@8bytes.org, robin.murphy@arm.com, kevin.tian@intel.com,
	quic_jjohnson@quicinc.com, suravee.suthikulpanit@amd.com,
	robdclark@gmail.com, dwmw2@infradead.org,
	baolu.lu@linux.intel.com, yong.wu@mediatek.com,
	matthias.bgg@gmail.com, orsonzhai@gmail.com,
	baolin.wang@linux.alibaba.com, zhang.lyra@gmail.com,
	thierry.reding@gmail.com, vdumpa@nvidia.com,
	jonathanh@nvidia.com, jean-philippe@linaro.org,
	tglx@linutronix.de, shameerali.kolothum.thodi@huawei.com,
	christophe.jaillet@wanadoo.fr, yangyicong@hisilicon.com,
	yangyingliang@huawei.com, quic_saipraka@quicinc.com,
	jon@solid-run.com, iommu@lists.linux.dev,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-arm-msm@vger.kernel.org,
	linux-mediatek@lists.infradead.org, linux-tegra@vger.kernel.org,
	virtualization@lists.linux-foundation.org
Subject: Re: [PATCH v7 4/5] iommu: Use EINVAL for incompatible device/domain in ->attach_dev
Date: Tue, 8 Nov 2022 09:23:10 -0400	[thread overview]
Message-ID: <Y2pYPnjMqrwDDwB/@nvidia.com> (raw)
In-Reply-To: <20221108132041.GB22816@willie-the-truck>

On Tue, Nov 08, 2022 at 01:20:42PM +0000, Will Deacon wrote:
> On Mon, Nov 07, 2022 at 04:14:32PM -0800, Nicolin Chen wrote:
> > On Mon, Nov 07, 2022 at 03:26:45PM +0000, Will Deacon 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 ba47c73f5b8c..01fd7df16cb9 100644
> > > > --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> > > > +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> > > > @@ -2430,23 +2430,14 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
> > > >                       goto out_unlock;
> > > >               }
> > > >       } else if (smmu_domain->smmu != smmu) {
> > > > -             dev_err(dev,
> > > > -                     "cannot attach to SMMU %s (upstream of %s)\n",
> > > > -                     dev_name(smmu_domain->smmu->dev),
> > > > -                     dev_name(smmu->dev));
> > > > -             ret = -ENXIO;
> > > > +             ret = -EINVAL;
> > > >               goto out_unlock;
> > > >       } else if (smmu_domain->stage == ARM_SMMU_DOMAIN_S1 &&
> > > >                  master->ssid_bits != smmu_domain->s1_cfg.s1cdmax) {
> > > > -             dev_err(dev,
> > > > -                     "cannot attach to incompatible domain (%u SSID bits != %u)\n",
> > > > -                     smmu_domain->s1_cfg.s1cdmax, master->ssid_bits);
> > > >               ret = -EINVAL;
> > > >               goto out_unlock;
> > > >       } else if (smmu_domain->stage == ARM_SMMU_DOMAIN_S1 &&
> > > >                  smmu_domain->stall_enabled != master->stall_enabled) {
> > > > -             dev_err(dev, "cannot attach to stall-%s domain\n",
> > > > -                     smmu_domain->stall_enabled ? "enabled" : "disabled");
> > > >               ret = -EINVAL;
> > > >               goto out_unlock;
> > > >       }
> > 
> > > I think it would be helpful to preserve these messages using
> > > dev_err_ratelimited() so that attach failure can be diagnosed without
> > > having to hack the messages back into the driver.
> > 
> > Thank you for the review.
> > 
> > The change is already picked up last week. Yet, I can add prints
> > back with a followup patch, if no one has a problem with that.
> 
> Sorry, I fell behind with upstream so I got to this late. A patch on top
> would be fantastic!
> 
> > Also, I am not quite sure what the use case would be to have an
> > error print. Perhaps dev_dbg() would be more fitting if it is
> > just for diagnosis?
> 
> Sure, that works for me. I think the messages are useful for folks
> triggering this path e.g. via sysfs but if they're limited to debug I think
> that's better than removing them altogether.

I suspsect it has to be dbg - vfio/iommufd will probably trigger these
messages as it probes for domains that are compatible - eg certainly
the first one. Even if it is a "once" it would still emit a confusing
message for a normal occurance.

This is why they were removed in the first place..

Jason

WARNING: multiple messages have this Message-ID (diff)
From: Jason Gunthorpe <jgg@nvidia.com>
To: Will Deacon <will@kernel.org>
Cc: quic_saipraka@quicinc.com, yangyicong@hisilicon.com,
	linux-tegra@vger.kernel.org, thierry.reding@gmail.com,
	jean-philippe@linaro.org, zhang.lyra@gmail.com, joro@8bytes.org,
	jon@solid-run.com, jonathanh@nvidia.com, iommu@lists.linux.dev,
	Nicolin Chen <nicolinc@nvidia.com>,
	linux-arm-kernel@lists.infradead.org, yangyingliang@huawei.com,
	orsonzhai@gmail.com, dwmw2@infradead.org, kevin.tian@intel.com,
	linux-arm-msm@vger.kernel.org, christophe.jaillet@wanadoo.fr,
	baolin.wang@linux.alibaba.com, matthias.bgg@gmail.com,
	tglx@linutronix.de, virtualization@lists.linux-foundation.org,
	yong.wu@mediatek.com, robin.murphy@arm.com,
	linux-kernel@vger.kernel.org,
	shameerali.kolothum.thodi@huawei.com, robdclark@gmail.com,
	suravee.suthikulpanit@amd.com,
	linux-mediatek@lists.infradead.org, quic_jjohnson@quicinc.com,
	baolu.lu@linux.intel.com
Subject: Re: [PATCH v7 4/5] iommu: Use EINVAL for incompatible device/domain in ->attach_dev
Date: Tue, 8 Nov 2022 09:23:10 -0400	[thread overview]
Message-ID: <Y2pYPnjMqrwDDwB/@nvidia.com> (raw)
In-Reply-To: <20221108132041.GB22816@willie-the-truck>

On Tue, Nov 08, 2022 at 01:20:42PM +0000, Will Deacon wrote:
> On Mon, Nov 07, 2022 at 04:14:32PM -0800, Nicolin Chen wrote:
> > On Mon, Nov 07, 2022 at 03:26:45PM +0000, Will Deacon 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 ba47c73f5b8c..01fd7df16cb9 100644
> > > > --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> > > > +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> > > > @@ -2430,23 +2430,14 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
> > > >                       goto out_unlock;
> > > >               }
> > > >       } else if (smmu_domain->smmu != smmu) {
> > > > -             dev_err(dev,
> > > > -                     "cannot attach to SMMU %s (upstream of %s)\n",
> > > > -                     dev_name(smmu_domain->smmu->dev),
> > > > -                     dev_name(smmu->dev));
> > > > -             ret = -ENXIO;
> > > > +             ret = -EINVAL;
> > > >               goto out_unlock;
> > > >       } else if (smmu_domain->stage == ARM_SMMU_DOMAIN_S1 &&
> > > >                  master->ssid_bits != smmu_domain->s1_cfg.s1cdmax) {
> > > > -             dev_err(dev,
> > > > -                     "cannot attach to incompatible domain (%u SSID bits != %u)\n",
> > > > -                     smmu_domain->s1_cfg.s1cdmax, master->ssid_bits);
> > > >               ret = -EINVAL;
> > > >               goto out_unlock;
> > > >       } else if (smmu_domain->stage == ARM_SMMU_DOMAIN_S1 &&
> > > >                  smmu_domain->stall_enabled != master->stall_enabled) {
> > > > -             dev_err(dev, "cannot attach to stall-%s domain\n",
> > > > -                     smmu_domain->stall_enabled ? "enabled" : "disabled");
> > > >               ret = -EINVAL;
> > > >               goto out_unlock;
> > > >       }
> > 
> > > I think it would be helpful to preserve these messages using
> > > dev_err_ratelimited() so that attach failure can be diagnosed without
> > > having to hack the messages back into the driver.
> > 
> > Thank you for the review.
> > 
> > The change is already picked up last week. Yet, I can add prints
> > back with a followup patch, if no one has a problem with that.
> 
> Sorry, I fell behind with upstream so I got to this late. A patch on top
> would be fantastic!
> 
> > Also, I am not quite sure what the use case would be to have an
> > error print. Perhaps dev_dbg() would be more fitting if it is
> > just for diagnosis?
> 
> Sure, that works for me. I think the messages are useful for folks
> triggering this path e.g. via sysfs but if they're limited to debug I think
> that's better than removing them altogether.

I suspsect it has to be dbg - vfio/iommufd will probably trigger these
messages as it probes for domains that are compatible - eg certainly
the first one. Even if it is a "once" it would still emit a confusing
message for a normal occurance.

This is why they were removed in the first place..

Jason

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2022-11-08 13:23 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-17 23:00 [PATCH v7 0/5] Define EINVAL as device/domain incompatibility Nicolin Chen
2022-10-17 23:00 ` Nicolin Chen
2022-10-17 23:00 ` [PATCH v7 1/5] iommu/amd: Drop unnecessary checks in amd_iommu_attach_device() Nicolin Chen
2022-10-17 23:01 ` [PATCH v7 2/5] iommu: Add return value rules to attach_dev op and APIs Nicolin Chen
2022-10-17 23:01   ` Nicolin Chen
2022-10-18  1:20   ` Baolu Lu
2022-10-18  1:20     ` Baolu Lu
2022-10-17 23:02 ` [PATCH v7 3/5] iommu: Regulate EINVAL in ->attach_dev callback functions Nicolin Chen
2022-10-17 23:02   ` Nicolin Chen
2022-10-17 23:02 ` [PATCH v7 4/5] iommu: Use EINVAL for incompatible device/domain in ->attach_dev Nicolin Chen
2022-10-17 23:02   ` Nicolin Chen
2022-11-07 15:26   ` Will Deacon
2022-11-07 15:26     ` Will Deacon
2022-11-07 15:26     ` Will Deacon
2022-11-08  0:14     ` Nicolin Chen
2022-11-08  0:14       ` Nicolin Chen
2022-11-08 13:20       ` Will Deacon
2022-11-08 13:20         ` Will Deacon
2022-11-08 13:20         ` Will Deacon
2022-11-08 13:23         ` Jason Gunthorpe [this message]
2022-11-08 13:23           ` Jason Gunthorpe
2022-10-17 23:02 ` [PATCH v7 5/5] iommu: Propagate return value in ->attach_dev callback functions Nicolin Chen
2022-10-17 23:02   ` Nicolin Chen
2022-10-17 23:54 ` [PATCH v7 0/5] Define EINVAL as device/domain incompatibility Jason Gunthorpe
2022-10-17 23:54   ` 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=Y2pYPnjMqrwDDwB/@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=dwmw2@infradead.org \
    --cc=iommu@lists.linux.dev \
    --cc=jean-philippe@linaro.org \
    --cc=jon@solid-run.com \
    --cc=jonathanh@nvidia.com \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=matthias.bgg@gmail.com \
    --cc=nicolinc@nvidia.com \
    --cc=orsonzhai@gmail.com \
    --cc=quic_jjohnson@quicinc.com \
    --cc=quic_saipraka@quicinc.com \
    --cc=robdclark@gmail.com \
    --cc=robin.murphy@arm.com \
    --cc=shameerali.kolothum.thodi@huawei.com \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=tglx@linutronix.de \
    --cc=thierry.reding@gmail.com \
    --cc=vdumpa@nvidia.com \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=will@kernel.org \
    --cc=yangyicong@hisilicon.com \
    --cc=yangyingliang@huawei.com \
    --cc=yong.wu@mediatek.com \
    --cc=zhang.lyra@gmail.com \
    /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.