Skip to content

Commit 07bbd66

Browse files
hegdevasantjoergroedel
authored andcommitted
iommu/amd: Do not detach devices in domain free path
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> Link: https://lore.kernel.org/r/20241030063556.6104-7-vasant.hegde@amd.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent b73c698 commit 07bbd66

File tree

1 file changed

+1
-25
lines changed

1 file changed

+1
-25
lines changed

drivers/iommu/amd/iommu.c

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2279,21 +2279,6 @@ static struct iommu_group *amd_iommu_device_group(struct device *dev)
22792279
*
22802280
*****************************************************************************/
22812281

2282-
static void cleanup_domain(struct protection_domain *domain)
2283-
{
2284-
struct iommu_dev_data *entry;
2285-
2286-
lockdep_assert_held(&domain->lock);
2287-
2288-
while (!list_empty(&domain->dev_list)) {
2289-
entry = list_first_entry(&domain->dev_list,
2290-
struct iommu_dev_data, list);
2291-
BUG_ON(!entry->domain);
2292-
do_detach(entry);
2293-
}
2294-
WARN_ON(!list_empty(&domain->dev_list));
2295-
}
2296-
22972282
void protection_domain_free(struct protection_domain *domain)
22982283
{
22992284
WARN_ON(!list_empty(&domain->dev_list));
@@ -2482,16 +2467,7 @@ amd_iommu_domain_alloc_user(struct device *dev, u32 flags,
24822467

24832468
void amd_iommu_domain_free(struct iommu_domain *dom)
24842469
{
2485-
struct protection_domain *domain;
2486-
unsigned long flags;
2487-
2488-
domain = to_pdomain(dom);
2489-
2490-
spin_lock_irqsave(&domain->lock, flags);
2491-
2492-
cleanup_domain(domain);
2493-
2494-
spin_unlock_irqrestore(&domain->lock, flags);
2470+
struct protection_domain *domain = to_pdomain(dom);
24952471

24962472
protection_domain_free(domain);
24972473
}

0 commit comments

Comments
 (0)