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

Commit 4cb71ce2 authored by Sudarshan Rajagopalan's avatar Sudarshan Rajagopalan
Browse files

iommu/arm-smmu: avoid possible deadlock during map_sg



A possible deadlock could occur with the following flow:

    arm_smmu_map_sg()
    -->arm_smmu_secure_domain_lock()
    -->ops->map_sg() //this returns an error with ret = 0
    -->size_to_unmap = iova + size - __saved_iova_start;
    -->goto out;
    -->arm_smmu_assign_table()
    -->arm_smmu_unmap()
    ---->arm_smmu_secure_domain_lock() //DEADLOCKed!!!!!
    -------->mutex_lock()

The secure domain lock is needed to protect hyp assign and unassign.
Hence, its safe to call arm_smmu_secure_domain_unlock() after the
map and assign is done. Do this to avoid any runtime deadlocks.

Change-Id: I35effc170d8432d32c0cab3081be4897830d9212
Signed-off-by: default avatarSudarshan Rajagopalan <sudaraja@codeaurora.org>
parent ceb47a0e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3285,12 +3285,12 @@ static size_t arm_smmu_map_sg(struct iommu_domain *domain, unsigned long iova,

out:
	arm_smmu_assign_table(smmu_domain);
	arm_smmu_secure_domain_unlock(smmu_domain);

	if (size_to_unmap) {
		arm_smmu_unmap(domain, __saved_iova_start, size_to_unmap);
		iova = __saved_iova_start;
	}
	arm_smmu_secure_domain_unlock(smmu_domain);
	return iova - __saved_iova_start;
}