* [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* Re: [PATCH] Revert "scsi: ufs: core: Remove unnecessary block I/O quiesce for clock scaling"
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
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Konrad Dybcio @ 2026-07-23 13:03 UTC (permalink / raw)
To: Manivannan Sadhasivam, alim.akhtar, avri.altman, bvanassche,
James.Bottomley, martin.petersen
Cc: peter.wang, linux-scsi, linux-kernel, linux-arm-msm, Shawn Guo
On 7/23/26 2:47 PM, Manivannan Sadhasivam wrote:
> 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>
> ---
Tested-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com> # SC8280XP CRD
Konrad
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] Revert "scsi: ufs: core: Remove unnecessary block I/O quiesce for clock scaling"
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 (王信友)
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: sashiko-bot @ 2026-07-23 13:06 UTC (permalink / raw)
To: Manivannan Sadhasivam; +Cc: linux-scsi
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Calling blk_mq_quiesce_tagset() before acquiring the clk_scaling_lock write semaphore introduces an ABBA deadlock with device management commands.
--
--- Patch [1]: [PATCH] Revert "scsi: ufs: core: Remove unnecessary block I/O quiesce for clock scaling" ---
commit d454cd4e623d4ff192ea3b557d6b1e8c27de2a9a
Author: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Revert "scsi: ufs: core: Remove unnecessary block I/O quiesce for clock scaling"
This commit reverts a previous change to restore the block I/O quiesce
during clock scaling preparation. It is intended to fix UFS failures
during clock scaling on Qcom platforms.
Closes: https://lore.kernel.org/linux-scsi/al8YkXydXJQZrl_Y@QCOM-aGQu4IUr3Y
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index 79331c2bd38de..1a5a851d43b28 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);
[Severity: High]
Could this sequencing introduce a deadlock between clock scaling and
device management commands?
If a device management command starts first, it acquires the read lock in
ufshcd_dev_man_lock():
ufshcd_dev_man_lock()
down_read(&hba->clk_scaling_lock);
If the devfreq scaling worker then calls ufshcd_clock_scaling_prepare(),
it will quiesce the block queue and block waiting for the write lock:
ufshcd_clock_scaling_prepare()
blk_mq_quiesce_tagset(&hba->host->tag_set);
down_write(&hba->clk_scaling_lock);
When the device management thread proceeds to execute its request via
ufshcd_issue_dev_cmd() calling blk_execute_rq(), the request gets queued but
will not dispatch because the queue is quiesced.
Since blk_execute_rq() blocks indefinitely and the block layer timeout
doesn't track requests that haven't dispatched yet, won't this result in
both threads hanging permanently?
> - 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;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260723124733.341789-1-manivannan.sadhasivam@oss.qualcomm.com?part=1
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] Revert "scsi: ufs: core: Remove unnecessary block I/O quiesce for clock scaling"
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
4 siblings, 0 replies; 6+ messages in thread
From: Peter Wang (王信友) @ 2026-07-23 13:23 UTC (permalink / raw)
To: manivannan.sadhasivam@oss.qualcomm.com, avri.altman@sandisk.com,
alim.akhtar@samsung.com, bvanassche@acm.org,
martin.petersen@oracle.com, James.Bottomley@HansenPartnership.com
Cc: linux-scsi@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-kernel@vger.kernel.org, shengchao.guo@oss.qualcomm.com
On Thu, 2026-07-23 at 14:47 +0200, Manivannan Sadhasivam wrote:
> 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>
> ---
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Revert "scsi: ufs: core: Remove unnecessary block I/O quiesce for clock scaling"
2026-07-23 12:47 [PATCH] Revert "scsi: ufs: core: Remove unnecessary block I/O quiesce for clock scaling" Manivannan Sadhasivam
` (2 preceding siblings ...)
2026-07-23 13:23 ` Peter Wang (王信友)
@ 2026-07-23 19:15 ` Bart Van Assche
2026-07-24 1:10 ` Shawn Guo
4 siblings, 0 replies; 6+ messages in thread
From: Bart Van Assche @ 2026-07-23 19:15 UTC (permalink / raw)
To: Manivannan Sadhasivam, alim.akhtar, avri.altman, James.Bottomley,
martin.petersen
Cc: peter.wang, linux-scsi, linux-kernel, linux-arm-msm, Shawn Guo
On 7/23/26 5:47 AM, Manivannan Sadhasivam wrote:
> This reverts commit 85b2b966285498e1b551ac85f02c79cd06c0cff0.
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] Revert "scsi: ufs: core: Remove unnecessary block I/O quiesce for clock scaling"
2026-07-23 12:47 [PATCH] Revert "scsi: ufs: core: Remove unnecessary block I/O quiesce for clock scaling" Manivannan Sadhasivam
` (3 preceding siblings ...)
2026-07-23 19:15 ` Bart Van Assche
@ 2026-07-24 1:10 ` Shawn Guo
4 siblings, 0 replies; 6+ messages in thread
From: Shawn Guo @ 2026-07-24 1:10 UTC (permalink / raw)
To: Manivannan Sadhasivam
Cc: alim.akhtar, avri.altman, bvanassche, James.Bottomley,
martin.petersen, peter.wang, linux-scsi, linux-kernel,
linux-arm-msm
On Thu, Jul 23, 2026 at 02:47:33PM +0200, Manivannan Sadhasivam wrote:
> 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>
Tested-by: Shawn Guo <shengchao.guo@oss.qualcomm.com> # Qualcomm Nord SoC
^ permalink raw reply [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.