RE: [PATCH 1/3] iommu/vt-d: Use ida to manage domain id
From: Tian, Kevin
Date: Thu Apr 24 2025 - 03:44:44 EST
> From: Lu Baolu <baolu.lu@xxxxxxxxxxxxxxx>
> 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().
> @@ -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.
Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx>