Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: ufs: core: Don't perform UFS clkscaling during host async scan

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 <quic_cang@quicinc.com>
Signed-off-by: Can Guo <quic_cang@quicinc.com>
Signed-off-by: Ziqi Chen <quic_ziqichen@quicinc.com>
Link: https://lore.kernel.org/r/20250522081233.2358565-1-quic_ziqichen@quicinc.com
Suggested-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Ziqi Chen and committed by
Martin K. Petersen
e9763349 fd2963e7

+3
+3
drivers/ufs/core/ufshcd.c
··· 1397 1397 * make sure that there are no outstanding requests when 1398 1398 * clock scaling is in progress 1399 1399 */ 1400 + mutex_lock(&hba->host->scan_mutex); 1400 1401 blk_mq_quiesce_tagset(&hba->host->tag_set); 1401 1402 mutex_lock(&hba->wb_mutex); 1402 1403 down_write(&hba->clk_scaling_lock); ··· 1408 1407 up_write(&hba->clk_scaling_lock); 1409 1408 mutex_unlock(&hba->wb_mutex); 1410 1409 blk_mq_unquiesce_tagset(&hba->host->tag_set); 1410 + mutex_unlock(&hba->host->scan_mutex); 1411 1411 goto out; 1412 1412 } 1413 1413 ··· 1430 1428 mutex_unlock(&hba->wb_mutex); 1431 1429 1432 1430 blk_mq_unquiesce_tagset(&hba->host->tag_set); 1431 + mutex_unlock(&hba->host->scan_mutex); 1433 1432 ufshcd_release(hba); 1434 1433 } 1435 1434