Commit e9763349 authored by Ziqi Chen's avatar Ziqi Chen Committed by Martin K. Petersen
Browse files

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: default avatarCan Guo <quic_cang@quicinc.com>
Signed-off-by: default avatarCan Guo <quic_cang@quicinc.com>
Signed-off-by: default avatarZiqi Chen <quic_ziqichen@quicinc.com>
Link: https://lore.kernel.org/r/20250522081233.2358565-1-quic_ziqichen@quicinc.com


Suggested-by: default avatarBart Van Assche <bvanassche@acm.org>
Reviewed-by: default avatarBart Van Assche <bvanassche@acm.org>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent fd2963e7
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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);
}