All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Revert "scsi: ufs: core: Remove unnecessary block I/O quiesce for clock scaling"
@ 2026-07-23 12:47 Manivannan Sadhasivam
  2026-07-23 13:03 ` Konrad Dybcio
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Manivannan Sadhasivam @ 2026-07-23 12:47 UTC (permalink / raw)
  To: alim.akhtar, avri.altman, bvanassche, James.Bottomley,
	martin.petersen
  Cc: peter.wang, linux-scsi, linux-kernel, linux-arm-msm,
	Manivannan Sadhasivam, Shawn Guo

This reverts commit 85b2b966285498e1b551ac85f02c79cd06c0cff0.

Qcom UFS Host Controllers do not support scaling clocks when the traffic is
ongoing. But the offending commit removed the block I/O quiesce in the
clock scaling path, which causes below UFS failures during clock scaling:

ufshcd-qcom 1d84000.ufshc: ufshcd_check_errors: saved_err 0x80 saved_uic_err 0x0
ufshcd-qcom 1d84000.ufshc: ufshcd_err_handler started; HBA state eh_fatal; powered 1; shutting down 0; saved_err = 0x80; saved_uic_err = 0x0; force_reset = 0
ufshcd-qcom 1d84000.ufshc: pwr ctrl cmd 0x2 with (MIBattribute 0x1571, mode 0x11) completion timeout
ufshcd-qcom 1d84000.ufshc: UFS Host state=3
ufshcd-qcom 1d84000.ufshc: 7 outstanding reqs, tasks=0x0
ufshcd-qcom 1d84000.ufshc: saved_err=0x80, saved_uic_err=0x0
ufshcd-qcom 1d84000.ufshc: Device power mode=1, UIC link state=1
ufshcd-qcom 1d84000.ufshc: PM in progress=0, sys. suspended=0
ufshcd-qcom 1d84000.ufshc: Auto BKOPS=0, Host self-block=0
ufshcd-qcom 1d84000.ufshc: Clk gate=1
ufshcd-qcom 1d84000.ufshc: last_hibern8_exit_tstamp at 196451913 us, hibern8_exit_cnt=20
ufshcd-qcom 1d84000.ufshc: error handling flags=0x0, req. abort count=0
ufshcd-qcom 1d84000.ufshc: hba->ufs_version=0x300, Host capabilities=0x1587031f, caps=0x124f
ufshcd-qcom 1d84000.ufshc: quirks=0x0, dev. quirks=0x310c4
ufshcd-qcom 1d84000.ufshc: UFS dev info: SAMSUNG  KLUDG4UHDB-B2D1  rev 0400
ufshcd-qcom 1d84000.ufshc: clk: core_clk, rate: 300000000
ufshcd-qcom 1d84000.ufshc: clk: core_clk_unipro, rate: 300000000

Hence, revert the commit to bring back UFS on all Qcom platforms.

Reported-by: Shawn Guo <shengchao.guo@oss.qualcomm.com>
Closes: https://lore.kernel.org/linux-scsi/al8YkXydXJQZrl_Y@QCOM-aGQu4IUr3Y
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
---
 drivers/ufs/core/ufshcd.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 79331c2bd38d..1a5a851d43b2 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -1445,7 +1445,7 @@ static int ufshcd_scale_gear(struct ufs_hba *hba, u32 target_gear, bool scale_up
  *
  * Return: 0 upon success; -EBUSY upon timeout.
  */
-static int ufshcd_clock_scaling_prepare(struct ufs_hba *hba)
+static int ufshcd_clock_scaling_prepare(struct ufs_hba *hba, u64 timeout_us)
 {
 	int ret = 0;
 	/*
@@ -1453,13 +1453,16 @@ static int ufshcd_clock_scaling_prepare(struct ufs_hba *hba)
 	 * clock scaling is in progress
 	 */
 	mutex_lock(&hba->host->scan_mutex);
+	blk_mq_quiesce_tagset(&hba->host->tag_set);
 	mutex_lock(&hba->wb_mutex);
 	down_write(&hba->clk_scaling_lock);
 
-	if (!hba->clk_scaling.is_allowed) {
+	if (!hba->clk_scaling.is_allowed ||
+	    ufshcd_wait_for_pending_cmds(hba, timeout_us)) {
 		ret = -EBUSY;
 		up_write(&hba->clk_scaling_lock);
 		mutex_unlock(&hba->wb_mutex);
+		blk_mq_unquiesce_tagset(&hba->host->tag_set);
 		mutex_unlock(&hba->host->scan_mutex);
 		goto out;
 	}
@@ -1475,6 +1478,7 @@ static void ufshcd_clock_scaling_unprepare(struct ufs_hba *hba, int err)
 {
 	up_write(&hba->clk_scaling_lock);
 	mutex_unlock(&hba->wb_mutex);
+	blk_mq_unquiesce_tagset(&hba->host->tag_set);
 	mutex_unlock(&hba->host->scan_mutex);
 
 	/* Enable Write Booster if current gear requires it else disable it */
@@ -1502,7 +1506,7 @@ static int ufshcd_devfreq_scale(struct ufs_hba *hba, unsigned long freq,
 
 	new_gear = ufshcd_vops_freq_to_gear_speed(hba, freq);
 
-	ret = ufshcd_clock_scaling_prepare(hba);
+	ret = ufshcd_clock_scaling_prepare(hba, 1 * USEC_PER_SEC);
 	if (ret)
 		return ret;
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-07-24  1:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-23 12:47 [PATCH] Revert "scsi: ufs: core: Remove unnecessary block I/O quiesce for clock scaling" Manivannan Sadhasivam
2026-07-23 13:03 ` Konrad Dybcio
2026-07-23 13:06 ` sashiko-bot
2026-07-23 13:23 ` Peter Wang (王信友)
2026-07-23 19:15 ` Bart Van Assche
2026-07-24  1:10 ` Shawn Guo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.