Skip to content

Commit 596bb22

Browse files
hegdevasantgregkh
authored andcommitted
iommu/amd: Do not detach devices in domain free path
[ Upstream commit 07bbd66 ] 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> Stable-dep-of: faad224 ("iommu/amd: Fix clone_alias() to use the original device's devid") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent b9065e7 commit 596bb22

1 file changed

Lines changed: 1 addition & 25 deletions

File tree

drivers/iommu/amd/iommu.c

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2316,21 +2316,6 @@ static struct iommu_group *amd_iommu_device_group(struct device *dev)
23162316
*
23172317
*****************************************************************************/
23182318

2319-
static void cleanup_domain(struct protection_domain *domain)
2320-
{
2321-
struct iommu_dev_data *entry;
2322-
2323-
lockdep_assert_held(&domain->lock);
2324-
2325-
while (!list_empty(&domain->dev_list)) {
2326-
entry = list_first_entry(&domain->dev_list,
2327-
struct iommu_dev_data, list);
2328-
BUG_ON(!entry->domain);
2329-
do_detach(entry);
2330-
}
2331-
WARN_ON(!list_empty(&domain->dev_list));
2332-
}
2333-
23342319
void protection_domain_free(struct protection_domain *domain)
23352320
{
23362321
WARN_ON(!list_empty(&domain->dev_list));
@@ -2498,16 +2483,7 @@ amd_iommu_domain_alloc_user(struct device *dev, u32 flags,
24982483

24992484
void amd_iommu_domain_free(struct iommu_domain *dom)
25002485
{
2501-
struct protection_domain *domain;
2502-
unsigned long flags;
2503-
2504-
domain = to_pdomain(dom);
2505-
2506-
spin_lock_irqsave(&domain->lock, flags);
2507-
2508-
cleanup_domain(domain);
2509-
2510-
spin_unlock_irqrestore(&domain->lock, flags);
2486+
struct protection_domain *domain = to_pdomain(dom);
25112487

25122488
protection_domain_free(domain);
25132489
}

0 commit comments

Comments
 (0)