linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] scsi: ufs: retry link startup if that fails and device state is not active
       [not found] <CGME20210205014904epcas1p1b8cf04408ff6f5ef9ebd5c95b8a99f27@epcas1p1.samsung.com>
@ 2021-02-05  1:36 ` DooHyun Hwang
       [not found]   ` <CGME20210205014906epcas1p4273577a5af2d2a0786ddf794cd32d494@epcas1p4.samsung.com>
       [not found]   ` <CGME20210205014910epcas1p3bcaa909ace0684150973ccc3a35bb0de@epcas1p3.samsung.com>
  0 siblings, 2 replies; 3+ messages in thread
From: DooHyun Hwang @ 2021-02-05  1:36 UTC (permalink / raw)
  To: linux-scsi, linux-kernel, alim.akhtar, avri.altman, jejb,
	martin.petersen, stanley.chu, cang, asutoshd, beanhuo, jaegeuk,
	adrian.hunter, satyat
  Cc: grant.jung, jt77.jang, junwoo80.lee, jangsub.yi, sh043.lee,
	cw9316.lee, sh8267.baek, wkon.kim, DooHyun Hwang

Remove unnecessary link startup command if it was completed.

UniPro stack is reset and enabled when ufshc is enabled.
The link startup command is issued after enabling ufshc,
if link startup is completed, there is no needed to issue again.

Signed-off-by: DooHyun Hwang <dh0421.hwang@samsung.com>
---
 drivers/scsi/ufs/ufshcd.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 721f55db181f..286f7c918f0e 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -4642,13 +4642,13 @@ static int ufshcd_link_startup(struct ufs_hba *hba)
 		ufshcd_update_evt_hist(hba,
 				       UFS_EVT_LINK_STARTUP_FAIL,
 				       (u32)ret);
-		goto out;
-	}
 
-	if (link_startup_again) {
-		link_startup_again = false;
-		retries = DME_LINKSTARTUP_RETRIES;
-		goto link_startup;
+		if (link_startup_again) {
+			link_startup_again = false;
+			retries = DME_LINKSTARTUP_RETRIES;
+			goto link_startup;
+		}
+		goto out;
 	}
 
 	/* Mark that link is up in PWM-G1, 1-lane, SLOW-AUTO mode */
-- 
2.29.0


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

* [PATCH 2/3] scsi: ufs: set device state to power-off before 1st link startup
       [not found]   ` <CGME20210205014906epcas1p4273577a5af2d2a0786ddf794cd32d494@epcas1p4.samsung.com>
@ 2021-02-05  1:36     ` DooHyun Hwang
  0 siblings, 0 replies; 3+ messages in thread
From: DooHyun Hwang @ 2021-02-05  1:36 UTC (permalink / raw)
  To: linux-scsi, linux-kernel, alim.akhtar, avri.altman, jejb,
	martin.petersen, stanley.chu, cang, asutoshd, beanhuo, jaegeuk,
	adrian.hunter, satyat
  Cc: grant.jung, jt77.jang, junwoo80.lee, jangsub.yi, sh043.lee,
	cw9316.lee, sh8267.baek, wkon.kim, DooHyun Hwang

In the ufshcd init sequence, device state should be power-off
bacause the UFS device is not active.

Signed-off-by: DooHyun Hwang <dh0421.hwang@samsung.com>
---
 drivers/scsi/ufs/ufshcd.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 286f7c918f0e..32cb3b0dcbcf 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -9447,13 +9447,12 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
 	/* Hold auto suspend until async scan completes */
 	pm_runtime_get_sync(dev);
 	atomic_set(&hba->scsi_block_reqs_cnt, 0);
+
 	/*
-	 * We are assuming that device wasn't put in sleep/power-down
-	 * state exclusively during the boot stage before kernel.
-	 * This assumption helps avoid doing link startup twice during
-	 * ufshcd_probe_hba().
+	 * The device-initialize-sequence hasn't been invoked yet.
+	 * Set the device to power-off state
 	 */
-	ufshcd_set_ufs_dev_active(hba);
+	ufshcd_set_ufs_dev_poweroff(hba);
 
 	async_schedule(ufshcd_async_scan, hba);
 	ufs_sysfs_add_nodes(hba->dev);
-- 
2.29.0


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

* [PATCH 3/3] scsi: ufs: reset the ufs device before link startup retry
       [not found]   ` <CGME20210205014910epcas1p3bcaa909ace0684150973ccc3a35bb0de@epcas1p3.samsung.com>
@ 2021-02-05  1:36     ` DooHyun Hwang
  0 siblings, 0 replies; 3+ messages in thread
From: DooHyun Hwang @ 2021-02-05  1:36 UTC (permalink / raw)
  To: linux-scsi, linux-kernel, alim.akhtar, avri.altman, jejb,
	martin.petersen, stanley.chu, cang, asutoshd, beanhuo, jaegeuk,
	adrian.hunter, satyat
  Cc: grant.jung, jt77.jang, junwoo80.lee, jangsub.yi, sh043.lee,
	cw9316.lee, sh8267.baek, wkon.kim, DooHyun Hwang

If the link startup command fails, trigger hardware reset to reset
the UFS device before link startup retry.

Signed-off-by: DooHyun Hwang <dh0421.hwang@samsung.com>
---
 drivers/scsi/ufs/ufshcd.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 32cb3b0dcbcf..a87e98631a72 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -4644,7 +4644,15 @@ static int ufshcd_link_startup(struct ufs_hba *hba)
 				       (u32)ret);
 
 		if (link_startup_again) {
+			int err = 0;
+
 			link_startup_again = false;
+
+			/* Reset the attached device before retrying */
+			err = ufshcd_vops_device_reset(hba);
+			if (err && (err != -EOPNOTSUPP))
+				ufshcd_update_evt_hist(hba, UFS_EVT_DEV_RESET, err);
+
 			retries = DME_LINKSTARTUP_RETRIES;
 			goto link_startup;
 		}
-- 
2.29.0


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

end of thread, other threads:[~2021-02-05  1:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20210205014904epcas1p1b8cf04408ff6f5ef9ebd5c95b8a99f27@epcas1p1.samsung.com>
2021-02-05  1:36 ` [PATCH 1/3] scsi: ufs: retry link startup if that fails and device state is not active DooHyun Hwang
     [not found]   ` <CGME20210205014906epcas1p4273577a5af2d2a0786ddf794cd32d494@epcas1p4.samsung.com>
2021-02-05  1:36     ` [PATCH 2/3] scsi: ufs: set device state to power-off before 1st link startup DooHyun Hwang
     [not found]   ` <CGME20210205014910epcas1p3bcaa909ace0684150973ccc3a35bb0de@epcas1p3.samsung.com>
2021-02-05  1:36     ` [PATCH 3/3] scsi: ufs: reset the ufs device before link startup retry DooHyun Hwang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).