2021-02-05 02:05:20

by DooHyun Hwang

[permalink] [raw]
Subject: [PATCH 1/3] scsi: ufs: retry link startup if that fails and device state is not active

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 <[email protected]>
---
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


2021-02-05 02:05:26

by DooHyun Hwang

[permalink] [raw]
Subject: [PATCH 3/3] scsi: ufs: reset the ufs device before link startup retry

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

Signed-off-by: DooHyun Hwang <[email protected]>
---
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

2021-02-05 02:05:36

by DooHyun Hwang

[permalink] [raw]
Subject: [PATCH 2/3] scsi: ufs: set device state to power-off before 1st link startup

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

Signed-off-by: DooHyun Hwang <[email protected]>
---
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