RE: [PATCH] scsi: ufs: no sw reset after last linkstartup fail

From: Seunghui Lee
Date: Mon Jul 04 2022 - 07:11:38 EST


As we know, the ufs host controller is disabled and enabled in the ufshcd_hba_enable(). So, host controller registers are clear after sw reset.

Once the host fails to link startup 3 times, all host's controller can be clear due to executing last ufshcd_hba_enable()(s/w reset).
That's why we need to skip last sw reset to get valid host register values.

Before
(ufshcd_dme_link_startup() -> ufshcd_hba_enable() -> retries--) * 3 times.

After
(ufshcd_dme_link_startup() -> if retries is 0, break. -> ufshcd_hba_enable() -> retries--) * 3 times.
In this case, ufshcd_print_host_state(), ufshcd_print_pwr_info(), ufshcd_print_evt_hist() are valid.

> -----Original Message-----
> From: Seunghui Lee <sh043.lee@xxxxxxxxxxx>
> Sent: Thursday, June 30, 2022 1:48 PM
> To: alim.akhtar@xxxxxxxxxxx; avri.altman@xxxxxxx; bvanassche@xxxxxxx;
> jejb@xxxxxxxxxxxxx; martin.petersen@xxxxxxxxxx; linux-scsi@xxxxxxxxxxxxxxx;
> linux-kernel@xxxxxxxxxxxxxxx
> Cc: grant.jung@xxxxxxxxxxx; jt77.jang@xxxxxxxxxxx;
> dh0421.hwang@xxxxxxxxxxx; junwoo80.lee@xxxxxxxxxxx; jangsub.yi@xxxxxxxxxxx;
> cw9316.lee@xxxxxxxxxxx; sh8267.baek@xxxxxxxxxxx; wkon.kim@xxxxxxxxxxx;
> Seunghui Lee <sh043.lee@xxxxxxxxxxx>
> Subject: [PATCH] scsi: ufs: no sw reset after last linkstartup fail
>
> Host driver resets the host(ufshcd_hba_enable) after last linkstartup
> command failed. All of the member or host dump after linkstartup fail are
> reset value because of sw reset.
>
> Signed-off-by: Junwoo Lee <junwoo80.lee@xxxxxxxxxxx>
> Signed-off-by: Seunghui Lee <sh043.lee@xxxxxxxxxxx>
> ---
> drivers/ufs/core/ufshcd.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index
> 7c1d7bb9c579..2cdc14675443 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -4753,7 +4753,7 @@ static int ufshcd_link_startup(struct ufs_hba *hba)
> * but we can't be sure if the link is up until link startup
> * succeeds. So reset the local Uni-Pro and try again.
> */
> - if (ret && ufshcd_hba_enable(hba)) {
> + if (ret && retries && ufshcd_hba_enable(hba)) {
> ufshcd_update_evt_hist(hba,
> UFS_EVT_LINK_STARTUP_FAIL,
> (u32)ret);
> --
> 2.29.0