Linux SCSI subsystem development
 help / color / mirror / Atom feed
* [PATCH] scsi: ufs: core: call hibern8 notify when hibern8 cmd failed
@ 2026-04-22  7:21 Hongjie Fang
  2026-04-24 23:00 ` Bart Van Assche
  0 siblings, 1 reply; 3+ messages in thread
From: Hongjie Fang @ 2026-04-22  7:21 UTC (permalink / raw)
  To: alim.akhtar, avri.altman, bvanassche, martin.petersen,
	James.Bottomley
  Cc: linux-scsi, linux-kernel

The vendor hibern8 notify callback always can be executed in the
PRE_CHANGE phase of hibern8 enter/exit. But it cannot be executed
in the POST_CHANGE phase if the hibern8 cmd fails.

When the hibern8 cmd fails, the vendor hibern8 notify callback
should still have the opportunity to execute.

Signed-off-by: Hongjie Fang <hongjiefang@asrmicro.com>
---
 drivers/ufs/core/ufshcd.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 9ceb6d6d479d..02091e72f8db 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -4500,9 +4500,8 @@ int ufshcd_uic_hibern8_enter(struct ufs_hba *hba)
 	if (ret)
 		dev_err(hba->dev, "%s: hibern8 enter failed. ret = %d\n",
 			__func__, ret);
-	else
-		ufshcd_vops_hibern8_notify(hba, UIC_CMD_DME_HIBER_ENTER,
-								POST_CHANGE);
+
+	ufshcd_vops_hibern8_notify(hba, UIC_CMD_DME_HIBER_ENTER, POST_CHANGE);
 
 	return ret;
 }
@@ -4526,12 +4525,12 @@ int ufshcd_uic_hibern8_exit(struct ufs_hba *hba)
 		dev_err(hba->dev, "%s: hibern8 exit failed. ret = %d\n",
 			__func__, ret);
 	} else {
-		ufshcd_vops_hibern8_notify(hba, UIC_CMD_DME_HIBER_EXIT,
-								POST_CHANGE);
 		hba->ufs_stats.last_hibern8_exit_tstamp = local_clock();
 		hba->ufs_stats.hibern8_exit_cnt++;
 	}
 
+	ufshcd_vops_hibern8_notify(hba, UIC_CMD_DME_HIBER_EXIT, POST_CHANGE);
+
 	return ret;
 }
 EXPORT_SYMBOL_GPL(ufshcd_uic_hibern8_exit);
-- 
2.25.1


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

* Re: [PATCH] scsi: ufs: core: call hibern8 notify when hibern8 cmd failed
  2026-04-22  7:21 [PATCH] scsi: ufs: core: call hibern8 notify when hibern8 cmd failed Hongjie Fang
@ 2026-04-24 23:00 ` Bart Van Assche
  2026-04-28  5:34   ` Fang Hongjie(方洪杰)
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Van Assche @ 2026-04-24 23:00 UTC (permalink / raw)
  To: Hongjie Fang, alim.akhtar, avri.altman, martin.petersen,
	James.Bottomley
  Cc: linux-scsi, linux-kernel

On 4/22/26 12:21 AM, Hongjie Fang wrote:
> The vendor hibern8 notify callback always can be executed in the
> PRE_CHANGE phase of hibern8 enter/exit. But it cannot be executed
> in the POST_CHANGE phase if the hibern8 cmd fails.
> 
> When the hibern8 cmd fails, the vendor hibern8 notify callback
> should still have the opportunity to execute.
> 
> Signed-off-by: Hongjie Fang <hongjiefang@asrmicro.com>
> ---
>   drivers/ufs/core/ufshcd.c | 9 ++++-----
>   1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index 9ceb6d6d479d..02091e72f8db 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -4500,9 +4500,8 @@ int ufshcd_uic_hibern8_enter(struct ufs_hba *hba)
>   	if (ret)
>   		dev_err(hba->dev, "%s: hibern8 enter failed. ret = %d\n",
>   			__func__, ret);
> -	else
> -		ufshcd_vops_hibern8_notify(hba, UIC_CMD_DME_HIBER_ENTER,
> -								POST_CHANGE);
> +
> +	ufshcd_vops_hibern8_notify(hba, UIC_CMD_DME_HIBER_ENTER, POST_CHANGE);
>   
>   	return ret;
>   }
> @@ -4526,12 +4525,12 @@ int ufshcd_uic_hibern8_exit(struct ufs_hba *hba)
>   		dev_err(hba->dev, "%s: hibern8 exit failed. ret = %d\n",
>   			__func__, ret);
>   	} else {
> -		ufshcd_vops_hibern8_notify(hba, UIC_CMD_DME_HIBER_EXIT,
> -								POST_CHANGE);
>   		hba->ufs_stats.last_hibern8_exit_tstamp = local_clock();
>   		hba->ufs_stats.hibern8_exit_cnt++;
>   	}
>   
> +	ufshcd_vops_hibern8_notify(hba, UIC_CMD_DME_HIBER_EXIT, POST_CHANGE);
> +
>   	return ret;
>   }
>   EXPORT_SYMBOL_GPL(ufshcd_uic_hibern8_exit);

This change may break existing hibern8_notify() implementations. Please 
add a new argument to ufshcd_vops_hibern8_notify() that represents 
whether or not the operation succeeded for POST_CHANGE callbacks.

Thanks,

Bart.

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

* RE: [PATCH] scsi: ufs: core: call hibern8 notify when hibern8 cmd failed
  2026-04-24 23:00 ` Bart Van Assche
@ 2026-04-28  5:34   ` Fang Hongjie(方洪杰)
  0 siblings, 0 replies; 3+ messages in thread
From: Fang Hongjie(方洪杰) @ 2026-04-28  5:34 UTC (permalink / raw)
  To: Bart Van Assche, alim.akhtar@samsung.com, avri.altman@wdc.com,
	martin.petersen@oracle.com, James.Bottomley@HansenPartnership.com
  Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org


> From: Bart Van Assche [mailto:bvanassche@acm.org]
> Sent: Saturday, April 25, 2026 7:01 AM
> To: Fang Hongjie <hongjiefang@asrmicro.com>;
> alim.akhtar@samsung.com; avri.altman@wdc.com;
> martin.petersen@oracle.com; James.Bottomley@HansenPartnership.com
> Cc: linux-scsi@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH] scsi: ufs: core: call hibern8 notify when hibern8 cmd
> failed
> 
> On 4/22/26 12:21 AM, Hongjie Fang wrote:
> > The vendor hibern8 notify callback always can be executed in the
> > PRE_CHANGE phase of hibern8 enter/exit. But it cannot be executed
> > in the POST_CHANGE phase if the hibern8 cmd fails.
> >
> > When the hibern8 cmd fails, the vendor hibern8 notify callback
> > should still have the opportunity to execute.
> >
> > Signed-off-by: Hongjie Fang <hongjiefang@asrmicro.com>
> > ---
> >   drivers/ufs/core/ufshcd.c | 9 ++++-----
> >   1 file changed, 4 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> > index 9ceb6d6d479d..02091e72f8db 100644
> > --- a/drivers/ufs/core/ufshcd.c
> > +++ b/drivers/ufs/core/ufshcd.c
> > @@ -4500,9 +4500,8 @@ int ufshcd_uic_hibern8_enter(struct ufs_hba
> *hba)
> >   	if (ret)
> >   		dev_err(hba->dev, "%s: hibern8 enter failed. ret = %d\n",
> >   			__func__, ret);
> > -	else
> > -		ufshcd_vops_hibern8_notify(hba,
> UIC_CMD_DME_HIBER_ENTER,
> > -
> 	POST_CHANGE);
> > +
> > +	ufshcd_vops_hibern8_notify(hba, UIC_CMD_DME_HIBER_ENTER,
> POST_CHANGE);
> >
> >   	return ret;
> >   }
> > @@ -4526,12 +4525,12 @@ int ufshcd_uic_hibern8_exit(struct ufs_hba
> *hba)
> >   		dev_err(hba->dev, "%s: hibern8 exit failed. ret = %d\n",
> >   			__func__, ret);
> >   	} else {
> > -		ufshcd_vops_hibern8_notify(hba,
> UIC_CMD_DME_HIBER_EXIT,
> > -
> 	POST_CHANGE);
> >   		hba->ufs_stats.last_hibern8_exit_tstamp = local_clock();
> >   		hba->ufs_stats.hibern8_exit_cnt++;
> >   	}
> >
> > +	ufshcd_vops_hibern8_notify(hba, UIC_CMD_DME_HIBER_EXIT,
> POST_CHANGE);
> > +
> >   	return ret;
> >   }
> >   EXPORT_SYMBOL_GPL(ufshcd_uic_hibern8_exit);
> 
> This change may break existing hibern8_notify() implementations. Please
> add a new argument to ufshcd_vops_hibern8_notify() that represents
> whether or not the operation succeeded for POST_CHANGE callbacks.
> 

Okay, I’ll modify the patch accordingly.

> Thanks,
> 
> Bart.

Best.

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

end of thread, other threads:[~2026-04-28  5:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-22  7:21 [PATCH] scsi: ufs: core: call hibern8 notify when hibern8 cmd failed Hongjie Fang
2026-04-24 23:00 ` Bart Van Assche
2026-04-28  5:34   ` Fang Hongjie(方洪杰)

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