Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f0e6f673 authored by Sudarshan Rajagopalan's avatar Sudarshan Rajagopalan Committed by Gerrit - the friendly Code Review server
Browse files

iommu: arm-smmu: Avoid register writes on multiple detach calls



Two or more racing detach calls are possible, where the attach_count
gets decremented multiple times and becomes negative, due to which
the necessary check would fail and register writes would occur followed
by TLB flush all. Check if attach_count was zero, and return if so.

Change-Id: I0f33585c57f4d96e475c672604bb9163edc332fb
Signed-off-by: default avatarSudarshan Rajagopalan <sudaraja@codeaurora.org>
parent 314af848
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -2423,7 +2423,10 @@ static void arm_smmu_domain_remove_master(struct arm_smmu_domain *smmu_domain,

	mutex_lock(&smmu->stream_map_mutex);
	for_each_cfg_sme(fwspec, i, idx) {
		WARN_ON(s2cr[idx].attach_count == 0);
		if (WARN_ON(s2cr[idx].attach_count == 0)) {
			mutex_unlock(&smmu->stream_map_mutex);
			return;
		}
		s2cr[idx].attach_count -= 1;

		if (s2cr[idx].attach_count > 0)