linux/drivers/iommu/arm
Nicolin Chen 685ca577b4 iommu/arm-smmu-v3: Fix smmu_domain->nr_ats_masters decrement
The arm_smmu_attach_commit() updates master->ats_enabled before calling
arm_smmu_remove_master_domain() that is supposed to clean up everything
in the old domain, including the old domain's nr_ats_masters. So, it is
supposed to use the old ats_enabled state of the device, not an updated
state.

This isn't a problem if switching between two domains where:
 - old ats_enabled = false; new ats_enabled = false
 - old ats_enabled = true;  new ats_enabled = true
but can fail cases where:
 - old ats_enabled = false; new ats_enabled = true
   (old domain should keep the counter but incorrectly decreased it)
 - old ats_enabled = true;  new ats_enabled = false
   (old domain needed to decrease the counter but incorrectly missed it)

Update master->ats_enabled after arm_smmu_remove_master_domain() to fix
this.

Fixes: 7497f4211f ("iommu/arm-smmu-v3: Make changing domains be hitless for ATS")
Cc: stable@vger.kernel.org
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
Acked-by: Will Deacon <will@kernel.org>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Pranjal Shrivastava <praan@google.com>
Link: https://lore.kernel.org/r/20250801030127.2006979-1-nicolinc@nvidia.com
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2025-08-22 08:41:20 +02:00
..
arm-smmu Merge branch 'arm/smmu/updates' into next 2025-07-24 11:18:28 +01:00
arm-smmu-v3 iommu/arm-smmu-v3: Fix smmu_domain->nr_ats_masters decrement 2025-08-22 08:41:20 +02:00
Kconfig iommu: Split out and tidy up Arm Kconfig 2025-04-17 16:34:00 +02:00
Makefile Revert "iommu: make inclusion of arm/arm-smmu-v3 directory conditional" 2025-05-31 07:43:16 -07:00