Skip to content

Commit 743a4ba

Browse files
hegdevasantjoergroedel
authored andcommitted
iommu/amd: Remove protection_domain.dev_cnt variable
protection_domain->dev_list tracks list of attached devices to domain. We can use list_* functions on dev_list to get device count. Hence remove 'dev_cnt' variable. No functional change intended. Signed-off-by: Vasant Hegde <vasant.hegde@amd.com> Reviewed-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Reviewed-by: Joerg Roedel <jroedel@suse.de> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Link: https://lore.kernel.org/r/20241030063556.6104-4-vasant.hegde@amd.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent 2fcab2d commit 743a4ba

File tree

2 files changed

+1
-7
lines changed

2 files changed

+1
-7
lines changed

drivers/iommu/amd/amd_iommu_types.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,6 @@ struct protection_domain {
578578
u16 id; /* the domain id written to the device table */
579579
enum protection_domain_mode pd_mode; /* Track page table type */
580580
bool dirty_tracking; /* dirty tracking is enabled in the domain */
581-
unsigned dev_cnt; /* devices assigned to this domain */
582581
unsigned dev_iommu[MAX_IOMMUS]; /* per-IOMMU reference count */
583582

584583
struct mmu_notifier mn; /* mmu notifier for the SVA domain */

drivers/iommu/amd/iommu.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2031,7 +2031,6 @@ static int do_attach(struct iommu_dev_data *dev_data,
20312031

20322032
/* Do reference counting */
20332033
domain->dev_iommu[iommu->index] += 1;
2034-
domain->dev_cnt += 1;
20352034

20362035
/* Setup GCR3 table */
20372036
if (pdom_is_sva_capable(domain)) {
@@ -2064,7 +2063,6 @@ static void do_detach(struct iommu_dev_data *dev_data)
20642063

20652064
/* decrease reference counters - needs to happen after the flushes */
20662065
domain->dev_iommu[iommu->index] -= 1;
2067-
domain->dev_cnt -= 1;
20682066
}
20692067

20702068
/*
@@ -2237,16 +2235,13 @@ static void cleanup_domain(struct protection_domain *domain)
22372235

22382236
lockdep_assert_held(&domain->lock);
22392237

2240-
if (!domain->dev_cnt)
2241-
return;
2242-
22432238
while (!list_empty(&domain->dev_list)) {
22442239
entry = list_first_entry(&domain->dev_list,
22452240
struct iommu_dev_data, list);
22462241
BUG_ON(!entry->domain);
22472242
do_detach(entry);
22482243
}
2249-
WARN_ON(domain->dev_cnt != 0);
2244+
WARN_ON(!list_empty(&domain->dev_list));
22502245
}
22512246

22522247
void protection_domain_free(struct protection_domain *domain)

0 commit comments

Comments
 (0)