Skip to content

Commit 14c801d

Browse files
quic-ziqichensmb49
authored andcommitted
scsi: ufs: core: Don't perform UFS clkscaling during host async scan
BugLink: https://bugs.launchpad.net/bugs/2121266 [ Upstream commit e97633492f5a3eca7b3ff03b4ef6f993017f7955 ] 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 in ufshcd_clock_scaling_unprepare(). 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 I/O 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 <[email protected]> Signed-off-by: Can Guo <[email protected]> Signed-off-by: Ziqi Chen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Suggested-by: Bart Van Assche <[email protected]> Reviewed-by: Bart Van Assche <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Noah Wager <[email protected]> Signed-off-by: Stefan Bader <[email protected]>
1 parent e1a2030 commit 14c801d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/ufs/core/ufshcd.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,6 +1368,7 @@ static int ufshcd_clock_scaling_prepare(struct ufs_hba *hba, u64 timeout_us)
13681368
* make sure that there are no outstanding requests when
13691369
* clock scaling is in progress
13701370
*/
1371+
mutex_lock(&hba->host->scan_mutex);
13711372
blk_mq_quiesce_tagset(&hba->host->tag_set);
13721373
mutex_lock(&hba->wb_mutex);
13731374
down_write(&hba->clk_scaling_lock);
@@ -1378,6 +1379,7 @@ static int ufshcd_clock_scaling_prepare(struct ufs_hba *hba, u64 timeout_us)
13781379
up_write(&hba->clk_scaling_lock);
13791380
mutex_unlock(&hba->wb_mutex);
13801381
blk_mq_unquiesce_tagset(&hba->host->tag_set);
1382+
mutex_unlock(&hba->host->scan_mutex);
13811383
goto out;
13821384
}
13831385

@@ -1399,6 +1401,7 @@ static void ufshcd_clock_scaling_unprepare(struct ufs_hba *hba, int err, bool sc
13991401
mutex_unlock(&hba->wb_mutex);
14001402

14011403
blk_mq_unquiesce_tagset(&hba->host->tag_set);
1404+
mutex_unlock(&hba->host->scan_mutex);
14021405
ufshcd_release(hba);
14031406
}
14041407

0 commit comments

Comments
 (0)