mirror-linux/drivers/ufs/core
Wang Shuaiwei b0bd84c392 scsi: ufs: core: Fix SError in ufshcd_rtc_work() during UFS suspend
In __ufshcd_wl_suspend(), cancel_delayed_work_sync() is called to cancel
the UFS RTC work, but it is placed after ufshcd_vops_suspend(hba, pm_op,
POST_CHANGE). This creates a race condition where ufshcd_rtc_work() can
still be running while ufshcd_vops_suspend() is executing. When
UFSHCD_CAP_CLK_GATING is not supported, the condition
!hba->clk_gating.active_reqs is always true, causing ufshcd_update_rtc()
to be executed. Since ufshcd_vops_suspend() typically performs clock
gating operations, executing ufshcd_update_rtc() at that moment triggers
an SError. The kernel panic trace is as follows:

Kernel panic - not syncing: Asynchronous SError Interrupt
Call trace:
 dump_backtrace+0xec/0x128
 show_stack+0x18/0x28
 dump_stack_lvl+0x40/0xa0
 dump_stack+0x18/0x24
 panic+0x148/0x374
 nmi_panic+0x3c/0x8c
 arm64_serror_panic+0x64/0x8c
 do_serror+0xc4/0xc8
 el1h_64_error_handler+0x34/0x4c
 el1h_64_error+0x68/0x6c
 el1_interrupt+0x20/0x58
 el1h_64_irq_handler+0x18/0x24
 el1h_64_irq+0x68/0x6c
 ktime_get+0xc4/0x12c
 ufshcd_mcq_sq_stop+0x4c/0xec
 ufshcd_mcq_sq_cleanup+0x64/0x1dc
 ufshcd_clear_cmd+0x38/0x134
 ufshcd_issue_dev_cmd+0x298/0x4d0
 ufshcd_exec_dev_cmd+0x1a4/0x1c4
 ufshcd_query_attr+0xbc/0x19c
 ufshcd_rtc_work+0x10c/0x1c8
 process_scheduled_works+0x1c4/0x45c
 worker_thread+0x32c/0x3e8
 kthread+0x120/0x1d8
 ret_from_fork+0x10/0x20

Fix this by moving cancel_delayed_work_sync() before the call to
ufshcd_vops_suspend(hba, pm_op, PRE_CHANGE), ensuring the UFS RTC work is
fully completed or cancelled at that point.

Cc: Bean Huo <beanhuo@iokpp.de>
Fixes: 6bf999e0eb ("scsi: ufs: core: Add UFS RTC support")
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Wang Shuaiwei <wangshuaiwei1@xiaomi.com>
Link: https://patch.msgid.link/20260307035128.3419687-1-wangshuaiwei1@xiaomi.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2026-03-07 11:08:39 -05:00
..
Kconfig scsi: ufs: core: Remove HPB support 2023-07-23 16:40:39 -04:00
Makefile scsi: ufs: core: Add OP-TEE based RPMB driver for UFS devices 2025-11-10 12:49:43 -05:00
ufs-debugfs.c
ufs-debugfs.h
ufs-fault-injection.c fault-inject: improve build for CONFIG_FAULT_INJECTION=n 2024-09-01 20:43:33 -07:00
ufs-fault-injection.h scsi: ufs: core: Make fault injection dynamically configurable per HBA 2023-11-24 19:23:35 -05:00
ufs-hwmon.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
ufs-mcq.c scsi: ufs: core: Use a host-wide tagset in SDB mode 2026-02-03 21:56:27 -05:00
ufs-rpmb.c scsi: ufs: core: Add OP-TEE based RPMB driver for UFS devices 2025-11-10 12:49:43 -05:00
ufs-sysfs.c Merge patch series "ufs: ufs-qcom: Add support firmware managed platforms" 2026-01-23 22:07:51 -05:00
ufs-sysfs.h scsi: ufs: core: Revert "Make HID attributes visible" 2025-10-29 23:12:33 -04:00
ufs_bsg.c scsi: ufs: core: Remove an unnecessary NULL pointer check 2025-11-12 20:58:28 -05:00
ufs_bsg.h
ufs_trace.h scsi: ufs: core: Remove UFS_DEV_COMP 2025-10-23 22:18:12 -04:00
ufs_trace_types.h scsi: ufs: core: Remove UFS_DEV_COMP 2025-10-23 22:18:12 -04:00
ufshcd-crypto.c blk-crypto: add basic hardware-wrapped key support 2025-02-10 09:54:19 -07:00
ufshcd-crypto.h scsi: ufs: core: Optimize the hot path 2025-11-12 17:02:34 -05:00
ufshcd-priv.h SCSI misc on 20260212 2026-02-12 15:43:02 -08:00
ufshcd.c scsi: ufs: core: Fix SError in ufshcd_rtc_work() during UFS suspend 2026-03-07 11:08:39 -05:00