Linux-mediatek Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v2 0/2] scsi: ufs: add error recovery for suspend and resume in ufs-mediatek
@ 2020-03-26 15:07 Stanley Chu
  2020-03-26 15:07 ` [PATCH v2 1/2] scsi: ufs: export ufshcd_link_recovery for vendor's error recovery Stanley Chu
  2020-03-26 15:07 ` [PATCH v2 2/2] scsi: ufs-mediatek: add error recovery for suspend and resume Stanley Chu
  0 siblings, 2 replies; 6+ messages in thread
From: Stanley Chu @ 2020-03-26 15:07 UTC (permalink / raw)
  To: linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb
  Cc: Stanley Chu, bvanassche, andy.teng, chun-hung.wu, kuohong.wang,
	linux-kernel, cang, linux-mediatek, peter.wang, matthias.bgg,
	beanhuo, linux-arm-kernel, asutoshd

Hi,

This patchset adds error recovery flow for suspend and resume in ufs-mediatek driver.

v1 -> v2:
  - Fix format of comments

Stanley Chu (2):
  scsi: ufs: export ufshcd_link_recovery for vendor's error recovery
  scsi: ufs-mediatek: add error recovery for suspend and resume

 drivers/scsi/ufs/ufs-mediatek.c | 13 +++++++++++--
 drivers/scsi/ufs/ufshcd.c       |  3 ++-
 drivers/scsi/ufs/ufshcd.h       |  1 +
 3 files changed, 14 insertions(+), 3 deletions(-)

-- 
2.18.0
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH v2 1/2] scsi: ufs: export ufshcd_link_recovery for vendor's error recovery
  2020-03-26 15:07 [PATCH v2 0/2] scsi: ufs: add error recovery for suspend and resume in ufs-mediatek Stanley Chu
@ 2020-03-26 15:07 ` Stanley Chu
  2020-03-27  9:24   ` Avri Altman
  2020-03-26 15:07 ` [PATCH v2 2/2] scsi: ufs-mediatek: add error recovery for suspend and resume Stanley Chu
  1 sibling, 1 reply; 6+ messages in thread
From: Stanley Chu @ 2020-03-26 15:07 UTC (permalink / raw)
  To: linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb
  Cc: Stanley Chu, bvanassche, andy.teng, chun-hung.wu, kuohong.wang,
	linux-kernel, cang, linux-mediatek, peter.wang, matthias.bgg,
	beanhuo, linux-arm-kernel, asutoshd

export ufshcd_link_recovery to allow vendors to recover failed link
in vendor's callbacks.

Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
---
 drivers/scsi/ufs/ufshcd.c | 3 ++-
 drivers/scsi/ufs/ufshcd.h | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 4b30fb2f7da7..92967df2c877 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -3744,7 +3744,7 @@ static int ufshcd_uic_change_pwr_mode(struct ufs_hba *hba, u8 mode)
 	return ret;
 }
 
-static int ufshcd_link_recovery(struct ufs_hba *hba)
+int ufshcd_link_recovery(struct ufs_hba *hba)
 {
 	int ret;
 	unsigned long flags;
@@ -3771,6 +3771,7 @@ static int ufshcd_link_recovery(struct ufs_hba *hba)
 
 	return ret;
 }
+EXPORT_SYMBOL_GPL(ufshcd_link_recovery);
 
 static int __ufshcd_uic_hibern8_enter(struct ufs_hba *hba)
 {
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index d45a04444191..836d90a5c0e6 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -785,6 +785,7 @@ int ufshcd_alloc_host(struct device *, struct ufs_hba **);
 void ufshcd_dealloc_host(struct ufs_hba *);
 int ufshcd_hba_enable(struct ufs_hba *hba);
 int ufshcd_init(struct ufs_hba * , void __iomem * , unsigned int);
+int ufshcd_link_recovery(struct ufs_hba *hba);
 int ufshcd_make_hba_operational(struct ufs_hba *hba);
 void ufshcd_remove(struct ufs_hba *);
 int ufshcd_uic_hibern8_exit(struct ufs_hba *hba);
-- 
2.18.0
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH v2 2/2] scsi: ufs-mediatek: add error recovery for suspend and resume
  2020-03-26 15:07 [PATCH v2 0/2] scsi: ufs: add error recovery for suspend and resume in ufs-mediatek Stanley Chu
  2020-03-26 15:07 ` [PATCH v2 1/2] scsi: ufs: export ufshcd_link_recovery for vendor's error recovery Stanley Chu
@ 2020-03-26 15:07 ` Stanley Chu
  2020-03-27  9:23   ` Avri Altman
  1 sibling, 1 reply; 6+ messages in thread
From: Stanley Chu @ 2020-03-26 15:07 UTC (permalink / raw)
  To: linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb
  Cc: Stanley Chu, bvanassche, andy.teng, chun-hung.wu, kuohong.wang,
	linux-kernel, cang, linux-mediatek, peter.wang, matthias.bgg,
	beanhuo, linux-arm-kernel, asutoshd

Once fail happens during suspend and resume flow if the desired low
power link state is H8, link recovery is required for MediaTek UFS
controller.

For resume flow, since power and clocks are already enabled before
invoking vendor's resume callback, simply using ufshcd_link_recovery()
inside callback is fine.

For suspend flow, the device power enters low power mode or is disabled
before suspend callback, thus ufshcd_link_recovery() can not be directly
used in callback. To leverage host reset flow during ufshcd_suspend(),
set link as off state enforcedly to let ufshcd_host_reset_and_restore()
be executed by ufshcd_suspend().

Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
---
 drivers/scsi/ufs/ufs-mediatek.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
index 3b0e575d7460..2384e35ac85f 100644
--- a/drivers/scsi/ufs/ufs-mediatek.c
+++ b/drivers/scsi/ufs/ufs-mediatek.c
@@ -486,8 +486,15 @@ static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
 
 	if (ufshcd_is_link_hibern8(hba)) {
 		err = ufs_mtk_link_set_lpm(hba);
-		if (err)
+		if (err) {
+			/*
+			 * Set link as off state enforcedly to trigger
+			 * ufshcd_host_reset_and_restore() in ufshcd_suspend()
+			 * for completed host reset.
+			 */
+			ufshcd_set_link_off(hba);
 			return -EAGAIN;
+		}
 	}
 
 	if (!ufshcd_is_link_active(hba))
@@ -506,8 +513,10 @@ static int ufs_mtk_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
 
 	if (ufshcd_is_link_hibern8(hba)) {
 		err = ufs_mtk_link_set_hpm(hba);
-		if (err)
+		if (err) {
+			err = ufshcd_link_recovery(hba);
 			return err;
+		}
 	}
 
 	return 0;
-- 
2.18.0
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* RE: [PATCH v2 2/2] scsi: ufs-mediatek: add error recovery for suspend and resume
  2020-03-26 15:07 ` [PATCH v2 2/2] scsi: ufs-mediatek: add error recovery for suspend and resume Stanley Chu
@ 2020-03-27  9:23   ` Avri Altman
  2020-03-27  9:54     ` Stanley Chu
  0 siblings, 1 reply; 6+ messages in thread
From: Avri Altman @ 2020-03-27  9:23 UTC (permalink / raw)
  To: Stanley Chu, linux-scsi, martin.petersen, alim.akhtar, jejb
  Cc: bvanassche, andy.teng, chun-hung.wu, kuohong.wang, linux-kernel,
	cang, linux-mediatek, peter.wang, matthias.bgg, beanhuo,
	linux-arm-kernel, asutoshd

 
> 
> Once fail happens during suspend and resume flow if the desired low
> power link state is H8, link recovery is required for MediaTek UFS
> controller.
> 
> For resume flow, since power and clocks are already enabled before
> invoking vendor's resume callback, simply using ufshcd_link_recovery()
> inside callback is fine.
> 
> For suspend flow, the device power enters low power mode or is disabled
> before suspend callback, thus ufshcd_link_recovery() can not be directly
> used in callback. To leverage host reset flow during ufshcd_suspend(),
> set link as off state enforcedly 
Not sure this is a proper English, but I'm not sure.

to let ufshcd_host_reset_and_restore()
> be executed by ufshcd_suspend().
> 
> Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* RE: [PATCH v2 1/2] scsi: ufs: export ufshcd_link_recovery for vendor's error recovery
  2020-03-26 15:07 ` [PATCH v2 1/2] scsi: ufs: export ufshcd_link_recovery for vendor's error recovery Stanley Chu
@ 2020-03-27  9:24   ` Avri Altman
  0 siblings, 0 replies; 6+ messages in thread
From: Avri Altman @ 2020-03-27  9:24 UTC (permalink / raw)
  To: Stanley Chu, linux-scsi, martin.petersen, alim.akhtar, jejb
  Cc: bvanassche, andy.teng, chun-hung.wu, kuohong.wang, linux-kernel,
	cang, linux-mediatek, peter.wang, matthias.bgg, beanhuo,
	linux-arm-kernel, asutoshd


> export ufshcd_link_recovery to allow vendors to recover failed link
> in vendor's callbacks.
> 
> Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* RE: [PATCH v2 2/2] scsi: ufs-mediatek: add error recovery for suspend and resume
  2020-03-27  9:23   ` Avri Altman
@ 2020-03-27  9:54     ` Stanley Chu
  0 siblings, 0 replies; 6+ messages in thread
From: Stanley Chu @ 2020-03-27  9:54 UTC (permalink / raw)
  To: Avri Altman
  Cc: linux-scsi, martin.petersen, andy.teng, jejb, chun-hung.wu,
	kuohong.wang, linux-kernel, cang, linux-mediatek, peter.wang,
	alim.akhtar, matthias.bgg, beanhuo, bvanassche, linux-arm-kernel,
	asutoshd

Hi Avri,

On Fri, 2020-03-27 at 09:23 +0000, Avri Altman wrote:
> > 
> > Once fail happens during suspend and resume flow if the desired low
> > power link state is H8, link recovery is required for MediaTek UFS
> > controller.
> > 
> > For resume flow, since power and clocks are already enabled before
> > invoking vendor's resume callback, simply using ufshcd_link_recovery()
> > inside callback is fine.
> > 
> > For suspend flow, the device power enters low power mode or is disabled
> > before suspend callback, thus ufshcd_link_recovery() can not be directly
> > used in callback. To leverage host reset flow during ufshcd_suspend(),
> > set link as off state enforcedly 
> Not sure this is a proper English, but I'm not sure.
> 
> to let ufshcd_host_reset_and_restore()
> > be executed by ufshcd_suspend().

Thanks for your review! I will fix this sentence in next version.

Stanley Chu
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

end of thread, back to index

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-26 15:07 [PATCH v2 0/2] scsi: ufs: add error recovery for suspend and resume in ufs-mediatek Stanley Chu
2020-03-26 15:07 ` [PATCH v2 1/2] scsi: ufs: export ufshcd_link_recovery for vendor's error recovery Stanley Chu
2020-03-27  9:24   ` Avri Altman
2020-03-26 15:07 ` [PATCH v2 2/2] scsi: ufs-mediatek: add error recovery for suspend and resume Stanley Chu
2020-03-27  9:23   ` Avri Altman
2020-03-27  9:54     ` Stanley Chu

Linux-mediatek Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mediatek/0 linux-mediatek/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mediatek linux-mediatek/ https://lore.kernel.org/linux-mediatek \
		linux-mediatek@lists.infradead.org
	public-inbox-index linux-mediatek

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-mediatek


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git