]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iommu/amd: Remove protection_domain.dev_cnt variable
authorVasant Hegde <vasant.hegde@amd.com>
Wed, 30 Oct 2024 06:35:47 +0000 (06:35 +0000)
committerJoerg Roedel <jroedel@suse.de>
Wed, 30 Oct 2024 10:06:41 +0000 (11:06 +0100)
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>
drivers/iommu/amd/amd_iommu_types.h
drivers/iommu/amd/iommu.c

index e70f6299f765c3e8bfb1baad94662ab51262ef1b..90a752f574635a914a0b9dee2cf7467576dca9c9 100644 (file)
@@ -578,7 +578,6 @@ struct protection_domain {
        u16 id;                 /* the domain id written to the device table */
        enum protection_domain_mode pd_mode; /* Track page table type */
        bool dirty_tracking;    /* dirty tracking is enabled in the domain */
-       unsigned dev_cnt;       /* devices assigned to this domain */
        unsigned dev_iommu[MAX_IOMMUS]; /* per-IOMMU reference count */
 
        struct mmu_notifier mn; /* mmu notifier for the SVA domain */
index f831526b65f405fd82f9e3c1b14df6c419a3ccac..7f6acbf8e8f435f62b86dfe24cd45982c245b2f6 100644 (file)
@@ -2031,7 +2031,6 @@ static int do_attach(struct iommu_dev_data *dev_data,
 
        /* Do reference counting */
        domain->dev_iommu[iommu->index] += 1;
-       domain->dev_cnt                 += 1;
 
        /* Setup GCR3 table */
        if (pdom_is_sva_capable(domain)) {
@@ -2064,7 +2063,6 @@ static void do_detach(struct iommu_dev_data *dev_data)
 
        /* decrease reference counters - needs to happen after the flushes */
        domain->dev_iommu[iommu->index] -= 1;
-       domain->dev_cnt                 -= 1;
 }
 
 /*
@@ -2237,16 +2235,13 @@ static void cleanup_domain(struct protection_domain *domain)
 
        lockdep_assert_held(&domain->lock);
 
-       if (!domain->dev_cnt)
-               return;
-
        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(domain->dev_cnt != 0);
+       WARN_ON(!list_empty(&domain->dev_list));
 }
 
 void protection_domain_free(struct protection_domain *domain)