linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4] scsi: ufs: core: Don't perform UFS clkscale if host asyn scan in progress
@ 2025-05-22  8:12 Ziqi Chen
  2025-05-27 21:24 ` Bart Van Assche
                   ` (3 more replies)
  0 siblings, 4 replies; 17+ messages in thread
From: Ziqi Chen @ 2025-05-22  8:12 UTC (permalink / raw)
  To: quic_cang, bvanassche, mani, beanhuo, avri.altman, junwoo80.lee,
	martin.petersen, quic_ziqichen, quic_nguyenb, quic_nitirawa,
	quic_rampraka, neil.armstrong, luca.weiss, konrad.dybcio,
	peter.wang
  Cc: linux-arm-msm, linux-scsi, Alim Akhtar, James E.J. Bottomley,
	Manivannan Sadhasivam, open list

When preparing for UFS clock scaling, the UFS driver will quiesce all sdevs
queues in the UFS SCSI host tagset list and then unquiesce them when UFS
clock scaling unpreparing. If the UFS SCSI host async scan is in progress
at this time, some LUs may be added to the tagset list between UFS clkscale
prepare and unprepare. This can cause two issues:

1. During clock scaling, there may be IO requests issued through new added
queues that have not been quiesced, leading to task abort issue.

2. These new added queues that have not been quiesced will be unquiesced as
well when UFS clkscale is unprepared, resulting in warning prints.

Therefore, use the mutex lock scan_mutex in ufshcd_clock_scaling_prepare()
and ufshcd_clock_scaling_unprepare() to protect it.

Co-developed-by: Can Guo <quic_cang@quicinc.com>
Signed-off-by: Can Guo <quic_cang@quicinc.com>
Signed-off-by: Ziqi Chen <quic_ziqichen@quicinc.com>
Suggested-by: Bart Van Assche <bvanassche@acm.org>

---
v1 -> v2:
Move whole clkscale Initialize process out of ufshcd_add_lus().

v2 -> v3:
Add check for the return value of ufshcd_add_lus().

v3 -> v4:
1. Using lock 'scan_mutex' instead of checking flag 'scan_mutex'.
2. Update patch name and commit message.
---
 drivers/ufs/core/ufshcd.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index d7ff24b48de3..a7513f256057 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -1397,6 +1397,7 @@ static int ufshcd_clock_scaling_prepare(struct ufs_hba *hba, u64 timeout_us)
 	 * make sure that there are no outstanding requests when
 	 * 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);
@@ -1407,6 +1408,7 @@ static int ufshcd_clock_scaling_prepare(struct ufs_hba *hba, u64 timeout_us)
 		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;
 	}
 
@@ -1428,6 +1430,7 @@ static void ufshcd_clock_scaling_unprepare(struct ufs_hba *hba, int err)
 	mutex_unlock(&hba->wb_mutex);
 
 	blk_mq_unquiesce_tagset(&hba->host->tag_set);
+	mutex_unlock(&hba->host->scan_mutex);
 	ufshcd_release(hba);
 }
 
-- 
2.34.1


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

end of thread, other threads:[~2025-08-05  7:39 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-22  8:12 [PATCH v4] scsi: ufs: core: Don't perform UFS clkscale if host asyn scan in progress Ziqi Chen
2025-05-27 21:24 ` Bart Van Assche
2025-05-28  1:58 ` Martin K. Petersen
2025-06-03  2:35 ` Martin K. Petersen
2025-07-25  9:13 ` Peter Wang (王信友)
2025-07-25 14:54   ` Bart Van Assche
2025-07-28  6:34     ` Peter Wang (王信友)
2025-07-29  3:02       ` Ziqi Chen
2025-07-30 12:55         ` Peter Wang (王信友)
2025-07-30 15:37           ` Bart Van Assche
2025-07-30 15:42             ` Bart Van Assche
2025-07-30 15:50           ` Bart Van Assche
2025-08-04  7:54             ` Ziqi Chen
2025-08-04  9:41               ` Peter Wang (王信友)
2025-08-04 12:43               ` Peter Wang (王信友)
2025-08-05  6:03                 ` Ziqi Chen
2025-08-05  7:39                   ` Peter Wang (王信友)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).