All of lore.kernel.org
 help / color / mirror / Atom feed
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>,
	<suravee.suthikulpanit@amd.com>, <iommu@lists.linux.dev>,
	<linux-kernel@vger.kernel.org>
Subject: [PATCH v5 2/6] iommu/amd: Drop unnecessary checks in amd_iommu_attach_device()
Date: Thu, 22 Sep 2022 01:53:52 -0700	[thread overview]
Message-ID: <b7402679fd29226d544ce6e3a31032c0d5656b34.1663836372.git.nicolinc@nvidia.com> (raw)
In-Reply-To: <cover.1663836372.git.nicolinc@nvidia.com>

The same checks are done in amd_iommu_probe_device(). If any of them fails
there, then the device won't get a group, so there's no way for it to even
reach amd_iommu_attach_device anymore.

Suggested-by: Robin Murphy <robin.murphy@arm.com>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Reviewed-by: Vasant Hegde <vasant.hegde@amd.com>
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
---
 drivers/iommu/amd/iommu.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index 828672a46a3d..930d9946b9f7 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -2135,21 +2135,13 @@ static void amd_iommu_detach_device(struct iommu_domain *dom,
 static int amd_iommu_attach_device(struct iommu_domain *dom,
 				   struct device *dev)
 {
+	struct iommu_dev_data *dev_data = dev_iommu_priv_get(dev);
 	struct protection_domain *domain = to_pdomain(dom);
-	struct iommu_dev_data *dev_data;
-	struct amd_iommu *iommu;
+	struct amd_iommu *iommu = rlookup_amd_iommu(dev);
 	int ret;
 
-	if (!check_device(dev))
-		return -EINVAL;
-
-	dev_data = dev_iommu_priv_get(dev);
 	dev_data->defer_attach = false;
 
-	iommu = rlookup_amd_iommu(dev);
-	if (!iommu)
-		return -EINVAL;
-
 	if (dev_data->domain)
 		detach_device(dev);
 
-- 
2.17.1


  parent reply	other threads:[~2022-09-22  8:54 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-22  8:53 [PATCH v5 0/6] Define EINVAL as device/domain incompatibility Nicolin Chen
2022-09-22  8:53 ` Nicolin Chen
2022-09-22  8:53 ` [PATCH v5 1/6] iommu/msm: Fix error-out routine in msm_iommu_attach_dev() Nicolin Chen
2022-09-22 17:23   ` Jason Gunthorpe
2022-09-22 18:26     ` Nicolin Chen
2022-09-22  8:53 ` Nicolin Chen [this message]
2022-09-22 17:23   ` [PATCH v5 2/6] iommu/amd: Drop unnecessary checks in amd_iommu_attach_device() Jason Gunthorpe
2022-09-22  8:54 ` [PATCH v5 3/6] iommu: Add return value rules to attach_dev op and APIs Nicolin Chen
2022-09-22  8:54   ` Nicolin Chen
2022-09-22 17:24   ` Jason Gunthorpe
2022-09-22 17:24     ` Jason Gunthorpe
2022-09-22  8:54 ` [PATCH v5 4/6] iommu: Regulate EINVAL in ->attach_dev callback functions Nicolin Chen
2022-09-22  8:54   ` Nicolin Chen
2022-09-22 17:25   ` Jason Gunthorpe
2022-09-22 17:25     ` Jason Gunthorpe
2022-09-22  8:54 ` [PATCH v5 5/6] iommu: Use EINVAL for incompatible device/domain in ->attach_dev Nicolin Chen
2022-09-22  8:54   ` Nicolin Chen
2022-09-22 17:50   ` Jason Gunthorpe
2022-09-22 17:50     ` Jason Gunthorpe
2022-09-22  8:54 ` [PATCH v5 6/6] iommu: Propagate return value in ->attach_dev callback functions Nicolin Chen
2022-09-22  8:54   ` Nicolin Chen
2022-09-22 17:51   ` Jason Gunthorpe
2022-09-22 17:51     ` Jason Gunthorpe
2022-09-23  1:09   ` Yong Wu
2022-09-23  1:09     ` Yong Wu

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=b7402679fd29226d544ce6e3a31032c0d5656b34.1663836372.git.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=suravee.suthikulpanit@amd.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.