Linux IOMMU Development
 help / color / mirror / Atom feed
From: Vasant Hegde <vasant.hegde@amd.com>
To: <iommu@lists.linux.dev>, <joro@8bytes.org>
Cc: <will@kernel.org>, <robin.murphy@arm.com>,
	<suravee.suthikulpanit@amd.com>, <jgg@ziepe.ca>,
	Vasant Hegde <vasant.hegde@amd.com>,
	Joerg Roedel <jroedel@suse.de>, Jason Gunthorpe <jgg@nvidia.com>
Subject: [PATCH v5 06/12] iommu/amd: Do not detach devices in domain free path
Date: Wed, 30 Oct 2024 06:35:50 +0000	[thread overview]
Message-ID: <20241030063556.6104-7-vasant.hegde@amd.com> (raw)
In-Reply-To: <20241030063556.6104-1-vasant.hegde@amd.com>

All devices attached to a protection domain must be freed before
calling domain free. Hence do not try to free devices in domain
free path. Continue to throw warning if pdom->dev_list is not empty
so that any potential issues can be fixed.

Signed-off-by: Vasant Hegde <vasant.hegde@amd.com>
Reviewed-by: Joerg Roedel <jroedel@suse.de>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
---
 drivers/iommu/amd/iommu.c | 26 +-------------------------
 1 file changed, 1 insertion(+), 25 deletions(-)

diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index 0bbe22c3544a..8f0fe2c70adf 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -2279,21 +2279,6 @@ static struct iommu_group *amd_iommu_device_group(struct device *dev)
  *
  *****************************************************************************/
 
-static void cleanup_domain(struct protection_domain *domain)
-{
-	struct iommu_dev_data *entry;
-
-	lockdep_assert_held(&domain->lock);
-
-	while (!list_empty(&domain->dev_list)) {
-		entry = list_first_entry(&domain->dev_list,
-					 struct iommu_dev_data, list);
-		BUG_ON(!entry->domain);
-		do_detach(entry);
-	}
-	WARN_ON(!list_empty(&domain->dev_list));
-}
-
 void protection_domain_free(struct protection_domain *domain)
 {
 	WARN_ON(!list_empty(&domain->dev_list));
@@ -2482,16 +2467,7 @@ amd_iommu_domain_alloc_user(struct device *dev, u32 flags,
 
 void amd_iommu_domain_free(struct iommu_domain *dom)
 {
-	struct protection_domain *domain;
-	unsigned long flags;
-
-	domain = to_pdomain(dom);
-
-	spin_lock_irqsave(&domain->lock, flags);
-
-	cleanup_domain(domain);
-
-	spin_unlock_irqrestore(&domain->lock, flags);
+	struct protection_domain *domain = to_pdomain(dom);
 
 	protection_domain_free(domain);
 }
-- 
2.31.1


  parent reply	other threads:[~2024-10-30  6:46 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-30  6:35 [PATCH v5 00/12] iommu/amd: Improve domain allocator and device attach code path Vasant Hegde
2024-10-30  6:35 ` [PATCH v5 01/12] iommu/amd/pgtbl_v2: Take protection domain lock before invalidating TLB Vasant Hegde
2024-10-30  6:35 ` [PATCH v5 02/12] iommu/amd: Use ida interface to manage protection domain ID Vasant Hegde
2024-10-30  6:35 ` [PATCH v5 03/12] iommu/amd: Remove protection_domain.dev_cnt variable Vasant Hegde
2024-10-30  6:35 ` [PATCH v5 04/12] iommu/amd: xarray to track protection_domain->iommu list Vasant Hegde
2024-10-30  6:35 ` [PATCH v5 05/12] iommu/amd: Remove unused amd_iommus variable Vasant Hegde
2024-10-30  6:35 ` Vasant Hegde [this message]
2024-10-30  6:35 ` [PATCH v5 07/12] iommu/amd: Reduce domain lock scope in attach device path Vasant Hegde
2024-10-30  6:35 ` [PATCH v5 08/12] iommu/amd: Rearrange attach device code Vasant Hegde
2024-10-30  6:35 ` [PATCH v5 09/12] iommu/amd: Convert dev_data lock from spinlock to mutex Vasant Hegde
2024-10-30  6:35 ` [PATCH v5 10/12] iommu/amd: Reorder attach device code Vasant Hegde
2024-10-30  6:35 ` [PATCH v5 11/12] iommu/amd: Add ops->release_domain Vasant Hegde
2024-10-30  6:35 ` [PATCH v5 12/12] iommu/amd: Improve amd_iommu_release_device() Vasant Hegde
2024-10-30 10:24 ` [PATCH v5 00/12] iommu/amd: Improve domain allocator and device attach code path Joerg Roedel

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=20241030063556.6104-7-vasant.hegde@amd.com \
    --to=vasant.hegde@amd.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@nvidia.com \
    --cc=jgg@ziepe.ca \
    --cc=joro@8bytes.org \
    --cc=jroedel@suse.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox