From 8ff877aa637efdfd6e8bfca1f0e5565e3103a628 Mon Sep 17 00:00:00 2001 From: Peter Wang Date: Fri, 8 Aug 2025 13:50:27 +0800 Subject: [PATCH] ANDROID: fix android-specific bug in ufshcd.c There is a circular locking dependency bug detected that only occurs in ACK and not in upstream. According to the discussed solution, use mutex_trylock instead of mutex_lock. Fixes: e97633492f5a ("scsi: ufs: core: Don't perform UFS clkscaling during host async scan") Link: https://lore.kernel.org/all/20250522081233.2358565-1-quic_ziqichen@quicinc.com/ Bug: 436163342 Change-Id: Ibc231d385b0695e0d2863d8606eb0ab8a15550c1 Signed-off-by: Peter Wang --- drivers/ufs/core/ufshcd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 0e6a198e19e9..241ab29acaf2 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -1436,7 +1436,9 @@ 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); + if (!mutex_trylock(&hba->host->scan_mutex)) + return -EAGAIN; + blk_mq_quiesce_tagset(&hba->host->tag_set); mutex_lock(&hba->wb_mutex); down_write(&hba->clk_scaling_lock);