diff mbox series

scsi: ufs: clear uac for RPMB after ufshcd resets

Message ID 20201201041402.3860525-1-jaegeuk@kernel.org
State New
Headers show
Series scsi: ufs: clear uac for RPMB after ufshcd resets | expand

Commit Message

Jaegeuk Kim Dec. 1, 2020, 4:14 a.m. UTC
From: Randall Huang <huangrandall@google.com>

If RPMB is not provisioned, we may see RPMB failure after UFS suspend/resume.
Inject request_sense to clear uac in ufshcd reset flow.

Signed-off-by: Randall Huang <huangrandall@google.com>
Signed-off-by: Leo Liou <leoliou@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
---
 drivers/scsi/ufs/ufshcd.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

Comments

Jaegeuk Kim Dec. 8, 2020, 9:51 p.m. UTC | #1
From 902e313f0d7ccf5e24491c2badc6dc173ce35fb1 Mon Sep 17 00:00:00 2001
From: Randall Huang <huangrandall@google.com>

Date: Tue, 24 Nov 2020 15:29:58 +0800
Subject: [PATCH] scsi: ufs: clear uac for RPMB after ufshcd resets

If RPMB is not provisioned, we may see RPMB failure after UFS suspend/resume.
Inject request_sense to clear uac in ufshcd reset flow.

Signed-off-by: Randall Huang <huangrandall@google.com>

Signed-off-by: Leo Liou <leoliou@google.com>

Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>

---

 v2:
  - fix build warning

 drivers/scsi/ufs/ufshcd.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index dba3ee307307..d6a3a0ba6960 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -220,6 +220,7 @@ static int ufshcd_reset_and_restore(struct ufs_hba *hba);
 static int ufshcd_eh_host_reset_handler(struct scsi_cmnd *cmd);
 static int ufshcd_clear_tm_cmd(struct ufs_hba *hba, int tag);
 static void ufshcd_hba_exit(struct ufs_hba *hba);
+static int ufshcd_clear_ua_wluns(struct ufs_hba *hba);
 static int ufshcd_probe_hba(struct ufs_hba *hba, bool async);
 static int __ufshcd_setup_clocks(struct ufs_hba *hba, bool on,
 				 bool skip_ref_clk);
@@ -6814,7 +6815,8 @@ static int ufshcd_host_reset_and_restore(struct ufs_hba *hba)
 
 	/* Establish the link again and restore the device */
 	err = ufshcd_probe_hba(hba, false);
-
+	if (!err)
+		ufshcd_clear_ua_wluns(hba);
 out:
 	if (err)
 		dev_err(hba->dev, "%s: Host init failed %d\n", __func__, err);
@@ -8304,13 +8306,7 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba,
 	 * handling context.
 	 */
 	hba->host->eh_noresume = 1;
-	if (hba->wlun_dev_clr_ua) {
-		ret = ufshcd_send_request_sense(hba, sdp);
-		if (ret)
-			goto out;
-		/* Unit attention condition is cleared now */
-		hba->wlun_dev_clr_ua = false;
-	}
+	ufshcd_clear_ua_wluns(hba);
 
 	cmd[4] = pwr_mode << 4;
 
@@ -8331,7 +8327,7 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba,
 
 	if (!ret)
 		hba->curr_dev_pwr_mode = pwr_mode;
-out:
+
 	scsi_device_put(sdp);
 	hba->host->eh_noresume = 0;
 	return ret;
-- 
2.29.2.576.ga3fc446d84-goog
Stanley Chu Dec. 9, 2020, 1:06 a.m. UTC | #2
On Tue, 2020-12-08 at 13:51 -0800, Jaegeuk Kim wrote:
> From 902e313f0d7ccf5e24491c2badc6dc173ce35fb1 Mon Sep 17 00:00:00 2001

> From: Randall Huang <huangrandall@google.com>

> Date: Tue, 24 Nov 2020 15:29:58 +0800

> Subject: [PATCH] scsi: ufs: clear uac for RPMB after ufshcd resets

> 

> If RPMB is not provisioned, we may see RPMB failure after UFS suspend/resume.

> Inject request_sense to clear uac in ufshcd reset flow.

> 

> Signed-off-by: Randall Huang <huangrandall@google.com>

> Signed-off-by: Leo Liou <leoliou@google.com>

> Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>


Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Martin K. Petersen Dec. 9, 2020, 2:36 a.m. UTC | #3
Jaegeuk,

> If RPMB is not provisioned, we may see RPMB failure after UFS suspend/resume.

> Inject request_sense to clear uac in ufshcd reset flow.


Applied to 5.11/scsi-staging, thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering
diff mbox series

Patch

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index dba3ee307307..c728c00b58db 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -220,6 +220,7 @@  static int ufshcd_reset_and_restore(struct ufs_hba *hba);
 static int ufshcd_eh_host_reset_handler(struct scsi_cmnd *cmd);
 static int ufshcd_clear_tm_cmd(struct ufs_hba *hba, int tag);
 static void ufshcd_hba_exit(struct ufs_hba *hba);
+static int ufshcd_clear_ua_wluns(struct ufs_hba *hba);
 static int ufshcd_probe_hba(struct ufs_hba *hba, bool async);
 static int __ufshcd_setup_clocks(struct ufs_hba *hba, bool on,
 				 bool skip_ref_clk);
@@ -6814,7 +6815,8 @@  static int ufshcd_host_reset_and_restore(struct ufs_hba *hba)
 
 	/* Establish the link again and restore the device */
 	err = ufshcd_probe_hba(hba, false);
-
+	if (!err)
+		ufshcd_clear_ua_wluns(hba);
 out:
 	if (err)
 		dev_err(hba->dev, "%s: Host init failed %d\n", __func__, err);
@@ -8304,13 +8306,7 @@  static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba,
 	 * handling context.
 	 */
 	hba->host->eh_noresume = 1;
-	if (hba->wlun_dev_clr_ua) {
-		ret = ufshcd_send_request_sense(hba, sdp);
-		if (ret)
-			goto out;
-		/* Unit attention condition is cleared now */
-		hba->wlun_dev_clr_ua = false;
-	}
+	ufshcd_clear_ua_wluns(hba);
 
 	cmd[4] = pwr_mode << 4;