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

Configure Feed

Select the types of activity you want to include in your feed.

scsi: ufs: core: Fix a deadlock in the frequency scaling code

Commit 08b12cda6c44 ("scsi: ufs: core: Switch to scsi_get_internal_cmd()")
accidentally introduced a deadlock in the frequency scaling code.
ufshcd_clock_scaling_unprepare() may submit a device management command
while SCSI command processing is blocked. The deadlock was introduced by
using the SCSI core for submitting device management commands
(scsi_get_internal_cmd() + blk_execute_rq()). Fix this deadlock by calling
blk_mq_unquiesce_tagset() before any device management commands are
submitted by ufshcd_clock_scaling_unprepare().

Fixes: 08b12cda6c44 ("scsi: ufs: core: Switch to scsi_get_internal_cmd()")
Reported-by: Manivannan Sadhasivam <mani@kernel.org>
Reported-by: Roger Shimizu <rosh@debian.org>
Closes: https://lore.kernel.org/linux-scsi/ehorjaflathzab5oekx2nae2zss5vi2r36yqkqsfjb2fgsifz2@yk3us5g3igow/
Tested-by: Roger Shimizu <rosh@debian.org>
Cc: Nitin Rawat <nitin.rawat@oss.qualcomm.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Reviewed-by: Nitin Rawat <nitin.rawat@oss.qualcomm.com>
Tested-by: Alexey Klimov <alexey.klimov@linaro.org> # RB5 board
Link: https://patch.msgid.link/20251204181548.1006696-1-bvanassche@acm.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Bart Van Assche and committed by
Martin K. Petersen
d2875b81 14be351e

+3 -4
+3 -4
drivers/ufs/core/ufshcd.c
··· 1455 1455 static void ufshcd_clock_scaling_unprepare(struct ufs_hba *hba, int err) 1456 1456 { 1457 1457 up_write(&hba->clk_scaling_lock); 1458 + mutex_unlock(&hba->wb_mutex); 1459 + blk_mq_unquiesce_tagset(&hba->host->tag_set); 1460 + mutex_unlock(&hba->host->scan_mutex); 1458 1461 1459 1462 /* Enable Write Booster if current gear requires it else disable it */ 1460 1463 if (ufshcd_enable_wb_if_scaling_up(hba) && !err) 1461 1464 ufshcd_wb_toggle(hba, hba->pwr_info.gear_rx >= hba->clk_scaling.wb_gear); 1462 1465 1463 - mutex_unlock(&hba->wb_mutex); 1464 - 1465 - blk_mq_unquiesce_tagset(&hba->host->tag_set); 1466 - mutex_unlock(&hba->host->scan_mutex); 1467 1466 ufshcd_release(hba); 1468 1467 } 1469 1468