From: Nicolin Chen <nicolinc@nvidia.com>
To: <joro@8bytes.org>, <will@kernel.org>, <robin.murphy@arm.com>
Cc: <jgg@nvidia.com>, <kevin.tian@intel.com>, <iommu@lists.linux.dev>,
<linux-kernel@vger.kernel.org>
Subject: [PATCH v2 09/13] iommu/omap: Constrain return value of ->attach_dev()
Date: Tue, 13 Sep 2022 22:15:03 -0700 [thread overview]
Message-ID: <20220914051503.10348-3-nicolinc@nvidia.com> (raw)
In-Reply-To: <20220914051503.10348-1-nicolinc@nvidia.com>
Ensure attach_dev() callback functions only return errno values expected
from the attach_dev() op. In particular, only return -EINVAL when we are
sure that the device is incompatible with the domain.
Also drop any dev_err next to -EINVAL, following the attach_dev op kdocs.
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
---
drivers/iommu/omap-iommu.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c
index d9cf2820c02e..e97ebb2c0133 100644
--- a/drivers/iommu/omap-iommu.c
+++ b/drivers/iommu/omap-iommu.c
@@ -1464,15 +1464,14 @@ omap_iommu_attach_dev(struct iommu_domain *domain, struct device *dev)
if (!arch_data || !arch_data->iommu_dev) {
dev_err(dev, "device doesn't have an associated iommu\n");
- return -EINVAL;
+ return -ENODEV;
}
spin_lock(&omap_domain->lock);
/* only a single client device can be attached to a domain */
if (omap_domain->dev) {
- dev_err(dev, "iommu domain is already attached\n");
- ret = -EBUSY;
+ ret = -EINVAL;
goto out;
}
@@ -1480,6 +1479,7 @@ omap_iommu_attach_dev(struct iommu_domain *domain, struct device *dev)
if (ret) {
dev_err(dev, "failed to allocate required iommu data %d\n",
ret);
+ ret = -ENODEV;
goto init_fail;
}
@@ -1490,6 +1490,7 @@ omap_iommu_attach_dev(struct iommu_domain *domain, struct device *dev)
ret = omap_iommu_attach(oiommu, iommu->pgtable);
if (ret) {
dev_err(dev, "can't get omap iommu: %d\n", ret);
+ ret = -ENODEV;
goto attach_fail;
}
--
2.17.1
prev parent reply other threads:[~2022-09-14 5:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-14 5:15 [PATCH v2 05/13] iommu/fsl: Constrain return value of ->attach_dev() Nicolin Chen
2022-09-14 5:15 ` [PATCH v2 07/13] iommu/ipmmu-vmsa: " Nicolin Chen
2022-09-14 5:15 ` 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=20220914051503.10348-3-nicolinc@nvidia.com \
--to=nicolinc@nvidia.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@nvidia.com \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--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