]> git.ipfire.org Git - thirdparty/linux.git/commit
iommu/vt-d: Replace spin_lock with mutex to protect domain ida
authorLu Baolu <baolu.lu@linux.intel.com>
Tue, 13 May 2025 03:07:37 +0000 (11:07 +0800)
committerJoerg Roedel <jroedel@suse.de>
Fri, 16 May 2025 06:49:28 +0000 (08:49 +0200)
commit868720fe15d1a6a1bddc28ad7b7e4b62448ee36b
tree9018dc0134a68ff60b67e43c7e75aa8fed08e9cf
parentf93b4ac5929a5754fc4edba26b43d0c9fa57d576
iommu/vt-d: Replace spin_lock with mutex to protect domain ida

The domain ID allocator is currently protected by a spin_lock. However,
ida_alloc_range can potentially block if it needs to allocate memory to
grow its internal structures.

Replace the spin_lock with a mutex which allows sleep on block. Thus,
the memory allocation flags can be updated from GFP_ATOMIC to GFP_KERNEL
to allow blocking memory allocations if necessary.

Introduce a new mutex, did_lock, specifically for protecting the domain
ida. The existing spinlock will remain for protecting other intel_iommu
fields.

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-3-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