[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <617e5bc8-aaef-c6b9-c50b-8fadb8ea8efb@linux.intel.com>
Date: Fri, 1 Jul 2022 09:17:33 +0800
From: Lu Baolu <baolu.lu@...ux.intel.com>
To: "Tian, Kevin" <kevin.tian@...el.com>,
Joerg Roedel <joro@...tes.org>, Steve Wahl <steve.wahl@....com>
Cc: baolu.lu@...ux.intel.com, David Woodhouse <dwmw2@...radead.org>,
Jerry Snitselaar <jsnitsel@...hat.com>,
Mike Travis <mike.travis@....com>,
Dimitri Sivanich <sivanich@....com>,
"Anderson, Russ" <russ.anderson@....com>,
"iommu@...ts.linux.dev" <iommu@...ts.linux.dev>,
"iommu@...ts.linux-foundation.org" <iommu@...ts.linux-foundation.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v1 2/6] iommu/vt-d: Use IDA interface to manage iommu
sequence id
On 6/30/22 4:21 PM, Tian, Kevin wrote:
>> From: Lu Baolu <baolu.lu@...ux.intel.com>
>> Sent: Saturday, June 25, 2022 8:52 PM
>>
>> @@ -1062,11 +1040,14 @@ static int alloc_iommu(struct dmar_drhd_unit
>> *drhd)
>> if (!iommu)
>> return -ENOMEM;
>>
>> - if (dmar_alloc_seq_id(iommu) < 0) {
>> + iommu->seq_id = ida_alloc_range(&dmar_seq_ids, 0,
>> + DMAR_UNITS_SUPPORTED,
>
> should be "DMAR_UNITS_SUPPORTED - 1"
Yes, according to "@max: Highest ID to allocate.". Updated.
>> GFP_KERNEL);
>> + if (iommu->seq_id < 0) {
>> pr_err("Failed to allocate seq_id\n");
>> err = -ENOSPC;
>> goto error;
>> }
>
> ida_alloc_range() returns error code already. No need to change it.
>
Agreed. Updated as below:
diff --git a/drivers/iommu/intel/dmar.c b/drivers/iommu/intel/dmar.c
index bf43889b9d2a..6327b34f5aa7 100644
--- a/drivers/iommu/intel/dmar.c
+++ b/drivers/iommu/intel/dmar.c
@@ -1041,10 +1041,10 @@ static int alloc_iommu(struct dmar_drhd_unit *drhd)
return -ENOMEM;
iommu->seq_id = ida_alloc_range(&dmar_seq_ids, 0,
- DMAR_UNITS_SUPPORTED, GFP_KERNEL);
+ DMAR_UNITS_SUPPORTED - 1,
GFP_KERNEL);
if (iommu->seq_id < 0) {
pr_err("Failed to allocate seq_id\n");
- err = -ENOSPC;
+ err = iommu->seq_id;
goto error;
}
sprintf(iommu->name, "dmar%d", iommu->seq_id);
Best regards,
baolu
Powered by blists - more mailing lists