Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Manivannan Sadhasivam" <manivannan.sadhasivam@oss.qualcomm.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH] Revert "scsi: ufs: core: Remove unnecessary block I/O quiesce for clock scaling"
Date: Thu, 23 Jul 2026 13:06:41 +0000	[thread overview]
Message-ID: <20260723130641.92FD31F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260723124733.341789-1-manivannan.sadhasivam@oss.qualcomm.com>

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

  parent reply	other threads:[~2026-07-23 13:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2026-07-23 13:23 ` Peter Wang (王信友)
2026-07-23 19:15 ` Bart Van Assche
2026-07-24  1:10 ` Shawn Guo
2026-07-24 14:19 ` Bart Van Assche
2026-07-26  2:40   ` Shawn Guo
2026-07-26 13:44 ` David Heidelberg
2026-07-26 19:29 ` Martin K. Petersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260723130641.92FD31F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=manivannan.sadhasivam@oss.qualcomm.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox