linux/drivers/scsi/ufs
Bart Van Assche 493c9e8506 scsi: ufs: Fix a deadlock in the error handler
commit 945c3cca05 upstream.

The following deadlock has been observed on a test setup:

 - All tags allocated

 - The SCSI error handler calls ufshcd_eh_host_reset_handler()

 - ufshcd_eh_host_reset_handler() queues work that calls
   ufshcd_err_handler()

 - ufshcd_err_handler() locks up as follows:

Workqueue: ufs_eh_wq_0 ufshcd_err_handler.cfi_jt
Call trace:
 __switch_to+0x298/0x5d8
 __schedule+0x6cc/0xa94
 schedule+0x12c/0x298
 blk_mq_get_tag+0x210/0x480
 __blk_mq_alloc_request+0x1c8/0x284
 blk_get_request+0x74/0x134
 ufshcd_exec_dev_cmd+0x68/0x640
 ufshcd_verify_dev_init+0x68/0x35c
 ufshcd_probe_hba+0x12c/0x1cb8
 ufshcd_host_reset_and_restore+0x88/0x254
 ufshcd_reset_and_restore+0xd0/0x354
 ufshcd_err_handler+0x408/0xc58
 process_one_work+0x24c/0x66c
 worker_thread+0x3e8/0xa4c
 kthread+0x150/0x1b4
 ret_from_fork+0x10/0x30

Fix this lockup by making ufshcd_exec_dev_cmd() allocate a reserved
request.

Link: https://lore.kernel.org/r/20211203231950.193369-10-bvanassche@acm.org
Tested-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-02-23 12:03:15 +01:00
..
cdns-pltfrm.c scsi: ufs: Reduce power management code duplication 2021-08-02 21:43:57 -04:00
Kconfig scsi: ufs: Add fault injection support 2021-08-03 07:27:42 -04:00
Makefile scsi: ufs: Add fault injection support 2021-08-03 07:27:42 -04:00
tc-dwc-g210-pci.c scsi: ufs: Fix race conditions related to driver data 2022-01-27 11:04:10 +01:00
tc-dwc-g210-pltfrm.c scsi: ufs: Reduce power management code duplication 2021-08-02 21:43:57 -04:00
tc-dwc-g210.c
tc-dwc-g210.h
ti-j721e-ufs.c
ufs_bsg.c scsi: ufs: core: Enable power management for wlun 2021-05-10 22:28:20 -04:00
ufs_bsg.h
ufs_quirks.h scsi: ufs: core: Add L2P entry swap quirk for Micron UFS 2021-08-05 23:21:08 -04:00
ufs-debugfs.c scsi: ufs: core: Enable power management for wlun 2021-05-10 22:28:20 -04:00
ufs-debugfs.h scsi: ufs: core: Enable power management for wlun 2021-05-10 22:28:20 -04:00
ufs-exynos.c scsi: ufs: ufs-exynos: Correct timeout value setting registers 2021-10-20 23:25:51 -04:00
ufs-exynos.h scsi: ufs: ufs-exynos: Fix static checker warning 2021-08-24 23:10:14 -04:00
ufs-fault-injection.c scsi: ufs: Add fault injection support 2021-08-03 07:27:42 -04:00
ufs-fault-injection.h scsi: ufs: Add fault injection support 2021-08-03 07:27:42 -04:00
ufs-hisi.c scsi: ufs: Reduce power management code duplication 2021-08-02 21:43:57 -04:00
ufs-hisi.h
ufs-mediatek-trace.h
ufs-mediatek.c scsi: ufs: ufs-mediatek: Fix error checking in ufs_mtk_init_va09_pwr_ctrl() 2022-01-27 11:05:22 +01:00
ufs-mediatek.h
ufs-qcom-ice.c
ufs-qcom.c scsi: ufs: Reduce power management code duplication 2021-08-02 21:43:57 -04:00
ufs-qcom.h
ufs-sysfs.c scsi: ufs: core: Add lu_enable sysfs node 2021-08-05 23:21:13 -04:00
ufs-sysfs.h
ufs.h scsi: ufs: ufshpb: Add HPB 2.0 support 2021-08-01 16:05:07 -04:00
ufshcd-crypto.c SCSI misc on 20210219 2021-02-22 10:24:58 -08:00
ufshcd-crypto.h
ufshcd-dwc.c
ufshcd-dwc.h
ufshcd-pci.c scsi: ufs: Fix race conditions related to driver data 2022-01-27 11:04:10 +01:00
ufshcd-pltfrm.c scsi: ufs: ufshcd-pltfrm: Check the return value of devm_kstrdup() 2022-02-16 12:56:13 +01:00
ufshcd-pltfrm.h scsi: ufs: Reduce power management code duplication 2021-08-02 21:43:57 -04:00
ufshcd.c scsi: ufs: Fix a deadlock in the error handler 2022-02-23 12:03:15 +01:00
ufshcd.h scsi: ufs: Fix a deadlock in the error handler 2022-02-23 12:03:15 +01:00
ufshci-dwc.h
ufshci.h scsi: ufs: Treat link loss as fatal error 2022-02-16 12:56:14 +01:00
ufshpb.c scsi: ufs: ufshpb: Properly handle max-single-cmd 2021-11-18 19:17:07 +01:00
ufshpb.h scsi: ufs: ufshpb: Properly handle max-single-cmd 2021-11-18 19:17:07 +01:00
unipro.h