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

Commit d8f9875c authored by Can Guo's avatar Can Guo Committed by Gerrit - the friendly Code Review server
Browse files

scsi: ufs: fix a race condition between clock scaling and UFS card removal



During card removal, if clock scaling is ongoing, the hibern8 enter/exit
in the scaling path may fail, if so, the scaling exits with the write
semaphore held. Then in the card removal path, if it tries to queue any
tasks to the UFS host, such as when remove the scsi devices, it will wait
for the read semaphore, causing a race condition. This change fixes it by
releasing the write semaphore if clock scaling fails.

Change-Id: Id653507bd914188bb4e52366bd99712e186f7af0
Signed-off-by: default avatarCan Guo <cang@codeaurora.org>
parent 485a2d40
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1805,7 +1805,7 @@ static int ufshcd_devfreq_scale(struct ufs_hba *hba, bool scale_up)
		ret = ufshcd_uic_hibern8_enter(hba);
		if (ret)
			/* link will be bad state so no need to scale_up_gear */
			return ret;
			goto clk_scaling_unprepare;
		ufshcd_custom_cmd_log(hba, "Hibern8-entered");
	}

@@ -1818,7 +1818,7 @@ static int ufshcd_devfreq_scale(struct ufs_hba *hba, bool scale_up)
		ret = ufshcd_uic_hibern8_exit(hba);
		if (ret)
			/* link will be bad state so no need to scale_up_gear */
			return ret;
			goto clk_scaling_unprepare;
		ufshcd_custom_cmd_log(hba, "Hibern8-Exited");
	}