iommu/vt-d: Use ida to manage domain id
authorLu Baolu <baolu.lu@linux.intel.com>
Tue, 13 May 2025 03:07:36 +0000 (11:07 +0800)
committerJoerg Roedel <jroedel@suse.de>
Fri, 16 May 2025 06:49:27 +0000 (08:49 +0200)
commitf93b4ac5929a5754fc4edba26b43d0c9fa57d576
treec800a3f4daeed3af7e5fdb8329019616eac9da0a
parent6f5dc7658094610debe2fad1b09a2034e14857b1
iommu/vt-d: Use ida to manage domain id

Switch the intel iommu driver to use the ida mechanism for managing domain
IDs, replacing the previous fixed-size bitmap.

The previous approach allocated a bitmap large enough to cover the maximum
number of domain IDs supported by the hardware, regardless of the actual
number of domains in use. This led to unnecessary memory consumption,
especially on systems supporting a large number of iommu units but only
utilizing a small number of domain IDs.

The ida allocator dynamically manages the allocation and freeing of integer
IDs, only consuming memory for the IDs that are currently in use. This
significantly optimizes memory usage compared to the fixed-size bitmap.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/20250430021135.2370244-2-baolu.lu@linux.intel.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/intel/dmar.c
drivers/iommu/intel/iommu.c
drivers/iommu/intel/iommu.h