[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4541dba3-1a4b-45f6-a607-fe2fe9a9f014@linux.intel.com>
Date: Thu, 24 Apr 2025 17:01:35 +0800
From: Baolu Lu <baolu.lu@...ux.intel.com>
To: "Tian, Kevin" <kevin.tian@...el.com>, Joerg Roedel <joro@...tes.org>,
Will Deacon <will@...nel.org>, Robin Murphy <robin.murphy@....com>,
Jason Gunthorpe <jgg@...pe.ca>
Cc: baolu.lu@...ux.intel.com, "iommu@...ts.linux.dev"
<iommu@...ts.linux.dev>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/3] iommu/vt-d: Use ida to manage domain id
On 4/24/2025 3:37 PM, Tian, Kevin wrote:
>> From: Lu Baolu <baolu.lu@...ux.intel.com>
>> Sent: Wednesday, April 23, 2025 11:10 AM
>>
>> static void free_dmar_iommu(struct intel_iommu *iommu)
>> {
>> - if (iommu->domain_ids) {
>> - bitmap_free(iommu->domain_ids);
>> - iommu->domain_ids = NULL;
>> - }
>> + ida_destroy(&iommu->domain_ida);
>
> since ida_init() is in alloc_iommu() now, the destroy can be
> moved to free_iommu().
Sure.
diff --git a/drivers/iommu/intel/dmar.c b/drivers/iommu/intel/dmar.c
index e25e8d3dedcb..9e17e8e56308 100644
--- a/drivers/iommu/intel/dmar.c
+++ b/drivers/iommu/intel/dmar.c
@@ -1198,6 +1198,7 @@ static void free_iommu(struct intel_iommu *iommu)
if (iommu->reg)
unmap_iommu(iommu);
+ ida_destroy(&iommu->domain_ida);
ida_free(&dmar_seq_ids, iommu->seq_id);
kfree(iommu);
}
diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index f784df122d7a..0002511c561f 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -1304,8 +1304,6 @@ static void disable_dmar_iommu(struct intel_iommu
*iommu)
static void free_dmar_iommu(struct intel_iommu *iommu)
{
- ida_destroy(&iommu->domain_ida);
-
if (iommu->copied_tables) {
bitmap_free(iommu->copied_tables);
iommu->copied_tables = NULL;
>
>> @@ -1399,14 +1356,13 @@ int domain_attach_iommu(struct dmar_domain
>> *domain, struct intel_iommu *iommu)
>> return 0;
>> }
>>
>> - ndomains = cap_ndoms(iommu->cap);
>> - num = find_first_zero_bit(iommu->domain_ids, ndomains);
>> - if (num >= ndomains) {
>> + num = ida_alloc_range(&iommu->domain_ida, FLPT_DEFAULT_DID +
>> 1,
>> + cap_ndoms(iommu->cap) - 1, GFP_ATOMIC);
>
> let's define a macro e.g. FIRST_DID for min.
Okay, how about IDA_START_DID?
Thanks,
baolu
>
> Reviewed-by: Kevin Tian <kevin.tian@...el.com>
Powered by blists - more mailing lists