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 07/13] iommu/ipmmu-vmsa: Constrain return value of ->attach_dev()
Date: Tue, 13 Sep 2022 22:15:02 -0700 [thread overview]
Message-ID: <20220914051503.10348-2-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/ipmmu-vmsa.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
index 1d42084d0276..73e7d0c261c4 100644
--- a/drivers/iommu/ipmmu-vmsa.c
+++ b/drivers/iommu/ipmmu-vmsa.c
@@ -452,8 +452,10 @@ static int ipmmu_domain_init_context(struct ipmmu_vmsa_domain *domain)
* Find an unused context.
*/
ret = ipmmu_domain_allocate_context(domain->mmu->root, domain);
- if (ret < 0)
+ if (ret < 0) {
+ ret = -ENOMEM;
return ret;
+ }
domain->context_id = ret;
@@ -462,7 +464,7 @@ static int ipmmu_domain_init_context(struct ipmmu_vmsa_domain *domain)
if (!domain->iop) {
ipmmu_domain_free_context(domain->mmu->root,
domain->context_id);
- return -EINVAL;
+ return -ENOMEM;
}
ipmmu_domain_setup_context(domain);
@@ -607,7 +609,7 @@ static int ipmmu_attach_device(struct iommu_domain *io_domain,
if (!mmu) {
dev_err(dev, "Cannot attach to IPMMU\n");
- return -ENXIO;
+ return -ENODEV;
}
mutex_lock(&domain->mutex);
@@ -628,8 +630,6 @@ static int ipmmu_attach_device(struct iommu_domain *io_domain,
* Something is wrong, we can't attach two devices using
* different IOMMUs to the same domain.
*/
- dev_err(dev, "Can't attach IPMMU %s to domain on IPMMU %s\n",
- dev_name(mmu->dev), dev_name(domain->mmu->dev));
ret = -EINVAL;
} else
dev_info(dev, "Reusing IPMMU context %u\n", domain->context_id);
--
2.17.1
next 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 ` Nicolin Chen [this message]
2022-09-14 5:15 ` [PATCH v2 09/13] iommu/omap: " Nicolin Chen
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-2-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