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>,
Vasant Hegde <vasant.hegde@amd.com>
Subject: [PATCH v2 02/10] iommu/amd: Remove protection_domain.dev_cnt variable
Date: Tue, 10 Sep 2024 06:58:04 +0000 [thread overview]
Message-ID: <20240910065812.6091-3-vasant.hegde@amd.com> (raw)
In-Reply-To: <20240910065812.6091-1-vasant.hegde@amd.com>
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>
---
drivers/iommu/amd/amd_iommu_types.h | 1 -
drivers/iommu/amd/iommu.c | 7 +------
2 files changed, 1 insertion(+), 7 deletions(-)
diff --git a/drivers/iommu/amd/amd_iommu_types.h b/drivers/iommu/amd/amd_iommu_types.h
index d32a86434de3..418c14aa4ec9 100644
--- a/drivers/iommu/amd/amd_iommu_types.h
+++ b/drivers/iommu/amd/amd_iommu_types.h
@@ -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 */
diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index fc1969011ff9..d870aeb654a7 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -2033,7 +2033,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)) {
@@ -2066,7 +2065,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;
}
/*
@@ -2239,16 +2237,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)
--
2.31.1
next prev parent reply other threads:[~2024-09-10 6:59 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-10 6:58 [PATCH v2 00/10] iommu/amd: Improve domain allocator and device attach code path Vasant Hegde
2024-09-10 6:58 ` [PATCH v2 01/10] iommu/amd: Use ida interface to manage protection domain ID Vasant Hegde
2024-10-15 8:38 ` Joerg Roedel
2024-09-10 6:58 ` Vasant Hegde [this message]
2024-10-15 8:39 ` [PATCH v2 02/10] iommu/amd: Remove protection_domain.dev_cnt variable Joerg Roedel
2024-09-10 6:58 ` [PATCH v2 03/10] iommu/amd: xarray to track protection_domain->iommu list Vasant Hegde
2024-10-15 8:39 ` Joerg Roedel
2024-09-10 6:58 ` [PATCH v2 04/10] iommu/amd: Remove unused amd_iommus variable Vasant Hegde
2024-10-15 8:39 ` Joerg Roedel
2024-09-10 6:58 ` [PATCH v2 05/10] iommu/amd: Do not detach devices in domain free path Vasant Hegde
2024-10-15 8:40 ` Joerg Roedel
2024-09-10 6:58 ` [PATCH v2 06/10] iommu/amd: Reduce domain lock scope in attach device path Vasant Hegde
2024-10-15 8:38 ` Joerg Roedel
2024-10-15 12:30 ` Vasant Hegde
2024-10-15 16:12 ` Jason Gunthorpe
2024-10-15 16:45 ` Vasant Hegde
2024-10-15 17:01 ` Jason Gunthorpe
2024-10-16 10:13 ` Vasant Hegde
2024-09-10 6:58 ` [PATCH v2 07/10] iommu/amd: Rearrange attach device code Vasant Hegde
2024-10-15 8:41 ` Joerg Roedel
2024-09-10 6:58 ` [PATCH v2 08/10] iommu/amd: Convert dev_data lock from spinlock to mutex Vasant Hegde
2024-10-15 8:43 ` Joerg Roedel
2024-09-10 6:58 ` [PATCH v2 09/10] iommu/amd: Reorder attach device code Vasant Hegde
2024-10-15 8:44 ` Joerg Roedel
2024-10-15 16:42 ` Vasant Hegde
2024-09-10 6:58 ` [PATCH v2 10/10] iommu/amd: Improve amd_iommu_release_device() Vasant Hegde
2024-10-15 8:45 ` Joerg Roedel
2024-10-04 14:24 ` [PATCH v2 00/10] iommu/amd: Improve domain allocator and device attach code path Vasant Hegde
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=20240910065812.6091-3-vasant.hegde@amd.com \
--to=vasant.hegde@amd.com \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--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