mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/1] scsi: ufs: core: Schedule EH on WLUN resume failure
@ 2026-01-23  4:54 Po-Wen Kao
  2026-01-26  3:42 ` Peter Wang (王信友)
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Po-Wen Kao @ 2026-01-23  4:54 UTC (permalink / raw)
  Cc: Brian Kao, Alim Akhtar, Avri Altman, Bart Van Assche,
	James E.J. Bottomley, Martin K. Petersen, Peter Wang, Bean Huo,
	Adrian Hunter, Bao D. Nguyen,
	open list:UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER,
	open list

From: Brian Kao <powenkao@google.com>

On WLUN resume failed, core driver leaves wlun dev in error runtime
PM state without taking further action. To ensure the driver can recover
from such errors, this patch schedules the error handler to perform
a full reset when error occurs during WLUN resume.

Signed-off-by: Brian Kao <powenkao@google.com>
---
 drivers/ufs/core/ufshcd.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 057678f4c50a..ac4db8484ee5 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -10236,6 +10236,15 @@ static int __ufshcd_wl_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
 	hba->clk_gating.is_suspended = false;
 	ufshcd_release(hba);
 	hba->pm_op_in_progress = false;
+
+	if (ret) {
+		/* ufshcd_reset_and_restore() might set host to UFSHCD_STATE_ERROR */
+		scoped_guard(spinlock_irqsave, hba->host->host_lock)
+			hba->ufshcd_state = UFSHCD_STATE_RESET;
+
+		ufshcd_force_error_recovery(hba);
+	}
+
 	return ret;
 }
 

base-commit: a9e03ec01ef2633288fd1b506980f54ae41c5a85
-- 
2.52.0.457.g6b5491de43-goog


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] scsi: ufs: core: Schedule EH on WLUN resume failure
  2026-01-23  4:54 [PATCH 1/1] scsi: ufs: core: Schedule EH on WLUN resume failure Po-Wen Kao
@ 2026-01-26  3:42 ` Peter Wang (王信友)
       [not found]   ` <CA+=0d2ZKT7ynBLvBcqM3YqLk7tX3knhpNwyL9LKxjB3=KvpVMg@mail.gmail.com>
  2026-01-30  9:04 ` Peter Wang (王信友)
  2026-01-30 22:55 ` Bart Van Assche
  2 siblings, 1 reply; 5+ messages in thread
From: Peter Wang (王信友) @ 2026-01-26  3:42 UTC (permalink / raw)
  To: powenkao
  Cc: beanhuo, avri.altman, quic_nguyenb, linux-scsi, bvanassche,
	linux-kernel, alim.akhtar, adrian.hunter, James.Bottomley,
	martin.petersen

On Fri, 2026-01-23 at 04:54 +0000, Po-Wen Kao wrote:
> From: Brian Kao <powenkao@google.com>
> 
> On WLUN resume failed, core driver leaves wlun dev in error runtime
> PM state without taking further action. To ensure the driver can
> recover
> from such errors, this patch schedules the error handler to perform
> a full reset when error occurs during WLUN resume.
> 

Hi Powen,

May I know at which step in __ufshcd_wl_resume the error occurred?


> Signed-off-by: Brian Kao <powenkao@google.com>
> ---
>  drivers/ufs/core/ufshcd.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index 057678f4c50a..ac4db8484ee5 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -10236,6 +10236,15 @@ static int __ufshcd_wl_resume(struct ufs_hba
> *hba, enum ufs_pm_op pm_op)
>  	hba->clk_gating.is_suspended = false;
>  	ufshcd_release(hba);
>  	hba->pm_op_in_progress = false;
> +
> +	if (ret) {
> +		/* ufshcd_reset_and_restore() might set host to
> UFSHCD_STATE_ERROR */
> +		scoped_guard(spinlock_irqsave, hba->host->host_lock)
> +			hba->ufshcd_state = UFSHCD_STATE_RESET;
> +
> +		ufshcd_force_error_recovery(hba);
> +	}
> +
>  	return ret;
> 

After recovery, is the return value still an error?

Thanks.
Peter


>  }
>  
> 
> base-commit: a9e03ec01ef2633288fd1b506980f54ae41c5a85


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] scsi: ufs: core: Schedule EH on WLUN resume failure
       [not found]   ` <CA+=0d2ZKT7ynBLvBcqM3YqLk7tX3knhpNwyL9LKxjB3=KvpVMg@mail.gmail.com>
@ 2026-01-27  6:59     ` Brian Kao
  0 siblings, 0 replies; 5+ messages in thread
From: Brian Kao @ 2026-01-27  6:59 UTC (permalink / raw)
  To: Peter Wang (王信友)
  Cc: beanhuo, avri.altman, quic_nguyenb, linux-scsi, bvanassche,
	linux-kernel, alim.akhtar, adrian.hunter,
	James.Bottomley@HansenPartnership.com, martin.petersen

[RESEND in plaintext]
Hi Peter,

> May I know at which step in __ufshcd_wl_resume the error occurred?
In our case, ufshcd_reset_and_restore() may return errors due to Link
Startup (LSS) failure.

> After recovery, is the return value still an error?
Since the error handler is scheduled to run asynchronously, the error
still propagates to the runtime PM framework when __ufshcd_wl_resume()
returns. If LSS succeeds during the error handler's execution, the
runtime PM error should be cleared in ufshcd_recover_pm_error(),
returning the host to an operational state.

Best regards,
Brian Kao


On Tue, Jan 27, 2026 at 2:41 PM Brian Kao <powenkao@google.com> wrote:
>
> Hi Peter,
>
> > May I know at which step in __ufshcd_wl_resume the error occurred?
> In our case, ufshcd_reset_and_restore() may return errors due to Link Startup (LSS) failure.
>
> > After recovery, is the return value still an error?
> Since the error handler is scheduled to run asynchronously, the error still propagates to the runtime PM framework when __ufshcd_wl_resume() returns. If LSS succeeds during the error handler's execution, the runtime PM error should be cleared in ufshcd_recover_pm_error(), returning the host to an operational state.
>
> Best regards,
> Brian Kao

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] scsi: ufs: core: Schedule EH on WLUN resume failure
  2026-01-23  4:54 [PATCH 1/1] scsi: ufs: core: Schedule EH on WLUN resume failure Po-Wen Kao
  2026-01-26  3:42 ` Peter Wang (王信友)
@ 2026-01-30  9:04 ` Peter Wang (王信友)
  2026-01-30 22:55 ` Bart Van Assche
  2 siblings, 0 replies; 5+ messages in thread
From: Peter Wang (王信友) @ 2026-01-30  9:04 UTC (permalink / raw)
  To: powenkao
  Cc: beanhuo, avri.altman, quic_nguyenb, linux-scsi, bvanassche,
	linux-kernel, alim.akhtar, adrian.hunter, James.Bottomley,
	martin.petersen

On Fri, 2026-01-23 at 04:54 +0000, Po-Wen Kao wrote:
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index 057678f4c50a..ac4db8484ee5 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -10236,6 +10236,15 @@ static int __ufshcd_wl_resume(struct ufs_hba
> *hba, enum ufs_pm_op pm_op)
>  	hba->clk_gating.is_suspended = false;
>  	ufshcd_release(hba);
>  	hba->pm_op_in_progress = false;
> +
> +	if (ret) {
> +		/* ufshcd_reset_and_restore() might set host to
> UFSHCD_STATE_ERROR */
> +		scoped_guard(spinlock_irqsave, hba->host->host_lock)
> +			hba->ufshcd_state = UFSHCD_STATE_RESET;
> +
> +		ufshcd_force_error_recovery(hba);
> +	}
> +
>  	return ret;
>  }
>  

Reviewed-by: Peter Wang <peter.wang@mediatek.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] scsi: ufs: core: Schedule EH on WLUN resume failure
  2026-01-23  4:54 [PATCH 1/1] scsi: ufs: core: Schedule EH on WLUN resume failure Po-Wen Kao
  2026-01-26  3:42 ` Peter Wang (王信友)
  2026-01-30  9:04 ` Peter Wang (王信友)
@ 2026-01-30 22:55 ` Bart Van Assche
  2 siblings, 0 replies; 5+ messages in thread
From: Bart Van Assche @ 2026-01-30 22:55 UTC (permalink / raw)
  To: Po-Wen Kao
  Cc: Alim Akhtar, Avri Altman, James E.J. Bottomley,
	Martin K. Petersen, Peter Wang, Bean Huo, Adrian Hunter,
	Bao D. Nguyen,
	open list:UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER,
	open list

On 1/22/26 8:54 PM, Po-Wen Kao wrote:
> From: Brian Kao <powenkao@google.com>
> 
> On WLUN resume failed, core driver leaves wlun dev in error runtime
> PM state without taking further action. To ensure the driver can recover
> from such errors, this patch schedules the error handler to perform
> a full reset when error occurs during WLUN resume.
> 
> Signed-off-by: Brian Kao <powenkao@google.com>
> ---
>   drivers/ufs/core/ufshcd.c | 9 +++++++++
>   1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index 057678f4c50a..ac4db8484ee5 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -10236,6 +10236,15 @@ static int __ufshcd_wl_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
>   	hba->clk_gating.is_suspended = false;
>   	ufshcd_release(hba);
>   	hba->pm_op_in_progress = false;
> +
> +	if (ret) {
> +		/* ufshcd_reset_and_restore() might set host to UFSHCD_STATE_ERROR */
> +		scoped_guard(spinlock_irqsave, hba->host->host_lock)
> +			hba->ufshcd_state = UFSHCD_STATE_RESET;
> +
> +		ufshcd_force_error_recovery(hba);
> +	}
> +
>   	return ret;
>   }
Isn't the hba->ufshcd_state assignment needed for all
ufshcd_force_error_recovery() callers? I'm wondering whether that
assignment should be moved into ufshcd_force_error_recovery().

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-01-30 22:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-23  4:54 [PATCH 1/1] scsi: ufs: core: Schedule EH on WLUN resume failure Po-Wen Kao
2026-01-26  3:42 ` Peter Wang (王信友)
     [not found]   ` <CA+=0d2ZKT7ynBLvBcqM3YqLk7tX3knhpNwyL9LKxjB3=KvpVMg@mail.gmail.com>
2026-01-27  6:59     ` Brian Kao
2026-01-30  9:04 ` Peter Wang (王信友)
2026-01-30 22:55 ` Bart Van Assche

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®