Skip to content

Commit 34ed1f9

Browse files
nicolincgregkh
authored andcommitted
iommu/arm-smmu-v3: Fix smmu_domain->nr_ats_masters decrement
commit 685ca57 upstream. 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: 7497f42 ("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 95b6b37 commit 34ed1f9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2997,9 +2997,9 @@ void arm_smmu_attach_commit(struct arm_smmu_attach_state *state)
29972997
/* ATS is being switched off, invalidate the entire ATC */
29982998
arm_smmu_atc_inv_master(master, IOMMU_NO_PASID);
29992999
}
3000-
master->ats_enabled = state->ats_enabled;
30013000

30023001
arm_smmu_remove_master_domain(master, state->old_domain, state->ssid);
3002+
master->ats_enabled = state->ats_enabled;
30033003
}
30043004

30053005
static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)

0 commit comments

Comments
 (0)