Linux IOMMU Development
 help / color / mirror / Atom feed
From: Yi Liu <yi.l.liu@intel.com>
To: joro@8bytes.org, jgg@nvidia.com, kevin.tian@intel.com
Cc: nicolinc@nvidia.com, kvm@vger.kernel.org, yi.l.liu@intel.com,
	iommu@lists.linux.dev, baolu.lu@linux.intel.com
Subject: [PATCH 1/2] iommufd: Avoid duplicated __iommu_group_set_core_domain() call
Date: Sun,  8 Sep 2024 04:42:55 -0700	[thread overview]
Message-ID: <20240908114256.979518-2-yi.l.liu@intel.com> (raw)
In-Reply-To: <20240908114256.979518-1-yi.l.liu@intel.com>

For the fault-capable hwpts, the iommufd_hwpt_detach_device() calls both
iommufd_fault_domain_detach_dev() and iommu_detach_group(). This would have
duplicated __iommu_group_set_core_domain() call since both functions call
it in the end. This looks no harm as the __iommu_group_set_core_domain()
returns if the new domain equals to the existing one. But it makes sense to
avoid such duplicated calls in caller side.

Signed-off-by: Yi Liu <yi.l.liu@intel.com>
---
 drivers/iommu/iommufd/iommufd_private.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/iommufd/iommufd_private.h b/drivers/iommu/iommufd/iommufd_private.h
index 92efe30a8f0d..1141c0633dc9 100644
--- a/drivers/iommu/iommufd/iommufd_private.h
+++ b/drivers/iommu/iommufd/iommufd_private.h
@@ -490,8 +490,10 @@ static inline int iommufd_hwpt_attach_device(struct iommufd_hw_pagetable *hwpt,
 static inline void iommufd_hwpt_detach_device(struct iommufd_hw_pagetable *hwpt,
 					      struct iommufd_device *idev)
 {
-	if (hwpt->fault)
+	if (hwpt->fault) {
 		iommufd_fault_domain_detach_dev(hwpt, idev);
+		return;
+	}
 
 	iommu_detach_group(hwpt->domain, idev->igroup->group);
 }
-- 
2.34.1


  reply	other threads:[~2024-09-08 11:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-08 11:42 [PATCH 0/2] iommufd: Misc cleanups per iommufd iopf merging Yi Liu
2024-09-08 11:42 ` Yi Liu [this message]
2024-09-09  7:29   ` [PATCH 1/2] iommufd: Avoid duplicated __iommu_group_set_core_domain() call Baolu Lu
2024-09-11  6:33   ` Tian, Kevin
2024-09-08 11:42 ` [PATCH 2/2] iommu: Set iommu_attach_handle->domain in core Yi Liu
2024-09-09  7:31   ` Baolu Lu
2024-09-11  6:33   ` Tian, Kevin
2024-09-14 14:13 ` [PATCH 0/2] iommufd: Misc cleanups per iommufd iopf merging 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=20240908114256.979518-2-yi.l.liu@intel.com \
    --to=yi.l.liu@intel.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@nvidia.com \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=nicolinc@nvidia.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox