From: Lu Baolu <baolu.lu@linux.intel.com>
To: Joerg Roedel <joro@8bytes.org>, Kevin Tian <kevin.tian@intel.com>,
Ashok Raj <ashok.raj@intel.com>, Liu Yi L <yi.l.liu@intel.com>,
Jacob Pan <jacob.jun.pan@linux.intel.com>
Cc: linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org,
Jason Gunthorpe <jgg@nvidia.com>,
Robin Murphy <robin.murphy@arm.com>,
Christoph Hellwig <hch@lst.de>
Subject: [PATCH v2 01/11] iommu/vt-d: Remove intel_iommu::domains
Date: Mon, 14 Feb 2022 10:56:54 +0800 [thread overview]
Message-ID: <20220214025704.3184654-2-baolu.lu@linux.intel.com> (raw)
In-Reply-To: <20220214025704.3184654-1-baolu.lu@linux.intel.com>
The "domains" field of the intel_iommu structure keeps the mapping of
domain_id to dmar_domain. This information is not used anywhere. Remove
and cleanup it to avoid unnecessary memory consumption.
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
include/linux/intel-iommu.h | 1 -
drivers/iommu/intel/iommu.c | 68 ++-----------------------------------
2 files changed, 3 insertions(+), 66 deletions(-)
diff --git a/include/linux/intel-iommu.h b/include/linux/intel-iommu.h
index 5cfda90b2cca..8c7591b5f3e2 100644
--- a/include/linux/intel-iommu.h
+++ b/include/linux/intel-iommu.h
@@ -578,7 +578,6 @@ struct intel_iommu {
#ifdef CONFIG_INTEL_IOMMU
unsigned long *domain_ids; /* bitmap of domains */
- struct dmar_domain ***domains; /* ptr to domains */
spinlock_t lock; /* protect context, domain ids */
struct root_entry *root_entry; /* virtual address */
diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index b549172e88ef..e3b04d5d87b0 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -455,36 +455,6 @@ __setup("intel_iommu=", intel_iommu_setup);
static struct kmem_cache *iommu_domain_cache;
static struct kmem_cache *iommu_devinfo_cache;
-static struct dmar_domain* get_iommu_domain(struct intel_iommu *iommu, u16 did)
-{
- struct dmar_domain **domains;
- int idx = did >> 8;
-
- domains = iommu->domains[idx];
- if (!domains)
- return NULL;
-
- return domains[did & 0xff];
-}
-
-static void set_iommu_domain(struct intel_iommu *iommu, u16 did,
- struct dmar_domain *domain)
-{
- struct dmar_domain **domains;
- int idx = did >> 8;
-
- if (!iommu->domains[idx]) {
- size_t size = 256 * sizeof(struct dmar_domain *);
- iommu->domains[idx] = kzalloc(size, GFP_ATOMIC);
- }
-
- domains = iommu->domains[idx];
- if (WARN_ON(!domains))
- return;
- else
- domains[did & 0xff] = domain;
-}
-
void *alloc_pgtable_page(int node)
{
struct page *page;
@@ -1751,8 +1721,7 @@ static void intel_flush_iotlb_all(struct iommu_domain *domain)
DMA_TLB_DSI_FLUSH);
if (!cap_caching_mode(iommu->cap))
- iommu_flush_dev_iotlb(get_iommu_domain(iommu, did),
- 0, MAX_AGAW_PFN_WIDTH);
+ iommu_flush_dev_iotlb(dmar_domain, 0, MAX_AGAW_PFN_WIDTH);
}
}
@@ -1815,7 +1784,6 @@ static void iommu_disable_translation(struct intel_iommu *iommu)
static int iommu_init_domains(struct intel_iommu *iommu)
{
u32 ndomains;
- size_t size;
ndomains = cap_ndoms(iommu->cap);
pr_debug("%s: Number of Domains supported <%d>\n",
@@ -1827,24 +1795,6 @@ static int iommu_init_domains(struct intel_iommu *iommu)
if (!iommu->domain_ids)
return -ENOMEM;
- size = (ALIGN(ndomains, 256) >> 8) * sizeof(struct dmar_domain **);
- iommu->domains = kzalloc(size, GFP_KERNEL);
-
- if (iommu->domains) {
- size = 256 * sizeof(struct dmar_domain *);
- iommu->domains[0] = kzalloc(size, GFP_KERNEL);
- }
-
- if (!iommu->domains || !iommu->domains[0]) {
- pr_err("%s: Allocating domain array failed\n",
- iommu->name);
- bitmap_free(iommu->domain_ids);
- kfree(iommu->domains);
- iommu->domain_ids = NULL;
- iommu->domains = NULL;
- return -ENOMEM;
- }
-
/*
* If Caching mode is set, then invalid translations are tagged
* with domain-id 0, hence we need to pre-allocate it. We also
@@ -1871,7 +1821,7 @@ static void disable_dmar_iommu(struct intel_iommu *iommu)
struct device_domain_info *info, *tmp;
unsigned long flags;
- if (!iommu->domains || !iommu->domain_ids)
+ if (!iommu->domain_ids)
return;
spin_lock_irqsave(&device_domain_lock, flags);
@@ -1892,15 +1842,8 @@ static void disable_dmar_iommu(struct intel_iommu *iommu)
static void free_dmar_iommu(struct intel_iommu *iommu)
{
- if ((iommu->domains) && (iommu->domain_ids)) {
- int elems = ALIGN(cap_ndoms(iommu->cap), 256) >> 8;
- int i;
-
- for (i = 0; i < elems; i++)
- kfree(iommu->domains[i]);
- kfree(iommu->domains);
+ if (iommu->domain_ids) {
bitmap_free(iommu->domain_ids);
- iommu->domains = NULL;
iommu->domain_ids = NULL;
}
@@ -1978,11 +1921,8 @@ static int domain_attach_iommu(struct dmar_domain *domain,
}
set_bit(num, iommu->domain_ids);
- set_iommu_domain(iommu, num, domain);
-
domain->iommu_did[iommu->seq_id] = num;
domain->nid = iommu->node;
-
domain_update_iommu_cap(domain);
}
@@ -2001,8 +1941,6 @@ static void domain_detach_iommu(struct dmar_domain *domain,
if (domain->iommu_refcnt[iommu->seq_id] == 0) {
num = domain->iommu_did[iommu->seq_id];
clear_bit(num, iommu->domain_ids);
- set_iommu_domain(iommu, num, NULL);
-
domain_update_iommu_cap(domain);
domain->iommu_did[iommu->seq_id] = 0;
}
--
2.25.1
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2022-02-14 2:58 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-14 2:56 [PATCH v2 00/11] iommu/vt-d: Some Intel IOMMU cleanups Lu Baolu
2022-02-14 2:56 ` Lu Baolu [this message]
2022-02-24 12:58 ` [PATCH v2 01/11] iommu/vt-d: Remove intel_iommu::domains Jason Gunthorpe via iommu
2022-02-14 2:56 ` [PATCH v2 02/11] iommu/vt-d: Remove finding domain in dmar_insert_one_dev_info() Lu Baolu
2022-02-24 12:59 ` Jason Gunthorpe via iommu
2022-02-14 2:56 ` [PATCH v2 03/11] iommu/vt-d: Remove iova_cache_get/put() Lu Baolu
2022-02-24 13:00 ` Jason Gunthorpe via iommu
2022-02-14 2:56 ` [PATCH v2 04/11] iommu/vt-d: Remove domain and devinfo mempool Lu Baolu
2022-02-24 13:01 ` Jason Gunthorpe via iommu
2022-02-14 2:56 ` [PATCH v2 05/11] iommu/vt-d: Remove DEFER_DEVICE_DOMAIN_INFO Lu Baolu
2022-02-14 7:31 ` Christoph Hellwig
2022-02-24 13:04 ` Jason Gunthorpe via iommu
2022-02-25 1:55 ` Lu Baolu
2022-02-14 2:56 ` [PATCH v2 06/11] iommu/vt-d: Remove unnecessary includes Lu Baolu
2022-02-14 7:32 ` Christoph Hellwig
2022-02-24 13:05 ` Jason Gunthorpe via iommu
2022-02-25 1:56 ` Lu Baolu
2022-02-14 2:57 ` [PATCH v2 07/11] iommu/vt-d: Remove unnecessary prototypes Lu Baolu
2022-02-14 7:32 ` Christoph Hellwig
2022-02-24 13:05 ` Jason Gunthorpe via iommu
2022-02-14 2:57 ` [PATCH v2 08/11] iommu/vt-d: Fix indentation of goto labels Lu Baolu
2022-02-14 7:33 ` Christoph Hellwig
2022-02-24 13:08 ` Jason Gunthorpe via iommu
2022-02-25 1:57 ` Lu Baolu
2022-02-14 2:57 ` [PATCH v2 09/11] iommu/vt-d: Remove commented code Lu Baolu
2022-02-14 7:34 ` Christoph Hellwig
2022-02-16 3:45 ` Tian, Kevin
2022-02-16 7:11 ` Lu Baolu
2022-02-24 13:09 ` Jason Gunthorpe via iommu
2022-02-25 1:53 ` Lu Baolu
2022-02-14 2:57 ` [PATCH v2 10/11] iommu/vt-d: Use xarray for global device_domain_info Lu Baolu
2022-02-14 7:38 ` Christoph Hellwig
2022-02-15 5:54 ` Lu Baolu
2022-02-14 14:00 ` Jason Gunthorpe via iommu
2022-02-15 5:46 ` Lu Baolu
2022-02-14 2:57 ` [PATCH v2 11/11] iommu/vt-d: Use rculist for per-domain device list Lu Baolu
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=20220214025704.3184654-2-baolu.lu@linux.intel.com \
--to=baolu.lu@linux.intel.com \
--cc=ashok.raj@intel.com \
--cc=hch@lst.de \
--cc=iommu@lists.linux-foundation.org \
--cc=jacob.jun.pan@linux.intel.com \
--cc=jgg@nvidia.com \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=robin.murphy@arm.com \
--cc=yi.l.liu@intel.com \
/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