From b632dc2e1d79086320858da0408fcf9b4c03fbb5 Mon Sep 17 00:00:00 2001 From: Manish Pandey Date: Fri, 1 Aug 2025 18:49:54 +0530 Subject: [PATCH] FROMGIT: scsi: ufs: core: Use link recovery when h8 exit fails during runtime resume If the h8 exit fails during runtime resume process, the runtime thread enters runtime suspend immediately and the error handler operates at the same time. It becomes stuck and cannot be recovered through the error handler. To fix this, use link recovery instead of the error handler. Fixes: 4db7a2360597 ("scsi: ufs: Fix concurrency of error handler and other error recovery paths") Signed-off-by: Seunghui Lee Link: https://lore.kernel.org/r/20250717081213.6811-1-sh043.lee@samsung.com Reviewed-by: Bean Huo Acked-by: Bart Van Assche Signed-off-by: Martin K. Petersen BUG: 434106145 Link: https://lore.kernel.org/r/20250717081213.6811-1-sh043.lee@samsung.com (cherry picked from commit 35dabf4503b94a697bababe94678a8bc989c3223 http://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git 6.17/scsi-staging) Change-Id: Ife911f7a9d34d5860d480222eb8f393b4614afaf Signed-off-by: Manish Pandey --- drivers/ufs/core/ufshcd.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 241ab29acaf2..cd14a3873fc4 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -4436,7 +4436,7 @@ out: hba->uic_async_done = NULL; if (reenable_intr) ufshcd_enable_intr(hba, UIC_COMMAND_COMPL); - if (ret) { + if (ret && !hba->pm_op_in_progress) { ufshcd_set_link_broken(hba); ufshcd_schedule_eh_work(hba); } @@ -4444,6 +4444,14 @@ out_unlock: spin_unlock_irqrestore(hba->host->host_lock, flags); mutex_unlock(&hba->uic_cmd_mutex); + /* + * If the h8 exit fails during the runtime resume process, + * it becomes stuck and cannot be recovered through the error handler. + * To fix this, use link recovery instead of the error handler. + */ + if (ret && hba->pm_op_in_progress) + ret = ufshcd_link_recovery(hba); + return ret; }