All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: ufs: clear uac for RPMB after ufshcd resets
@ 2020-12-01  4:14 Jaegeuk Kim
  2020-12-01  7:39   ` kernel test robot
  2020-12-08 21:51 ` [PATCH v2] " Jaegeuk Kim
  0 siblings, 2 replies; 7+ messages in thread
From: Jaegeuk Kim @ 2020-12-01  4:14 UTC (permalink / raw)
  To: linux-kernel, linux-scsi, kernel-team
  Cc: cang, alim.akhtar, avri.altman, bvanassche, martin.petersen,
	stanley.chu, Randall Huang, Leo Liou, Jaegeuk Kim

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(-)

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;
 
-- 
2.29.2.454.gaff20da3a2-goog


^ permalink raw reply related	[flat|nested] 7+ messages in thread
* Re: [PATCH] scsi: ufs: clear uac for RPMB after ufshcd resets
@ 2020-12-01  6:31 kernel test robot
  0 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2020-12-01  6:31 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 7786 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20201201041402.3860525-1-jaegeuk@kernel.org>
References: <20201201041402.3860525-1-jaegeuk@kernel.org>
TO: Jaegeuk Kim <jaegeuk@kernel.org>
TO: linux-kernel(a)vger.kernel.org
TO: linux-scsi(a)vger.kernel.org
TO: kernel-team(a)android.com
CC: cang(a)codeaurora.org
CC: alim.akhtar(a)samsung.com
CC: avri.altman(a)wdc.com
CC: bvanassche(a)acm.org
CC: martin.petersen(a)oracle.com
CC: stanley.chu(a)mediatek.com
CC: Randall Huang <huangrandall@google.com>

Hi Jaegeuk,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on scsi/for-next]
[also build test WARNING on mkp-scsi/for-next linux/master linus/master v5.10-rc6 next-20201130]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Jaegeuk-Kim/scsi-ufs-clear-uac-for-RPMB-after-ufshcd-resets/20201201-121956
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
:::::: branch date: 2 hours ago
:::::: commit date: 2 hours ago
config: i386-randconfig-s002-20201201 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.3-170-g3bc348f6-dirty
        # https://github.com/0day-ci/linux/commit/0636adf2e8880085b18818ce6e7ee878189b52ca
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Jaegeuk-Kim/scsi-ufs-clear-uac-for-RPMB-after-ufshcd-resets/20201201-121956
        git checkout 0636adf2e8880085b18818ce6e7ee878189b52ca
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


"sparse warnings: (new ones prefixed by >>)"
>> drivers/scsi/ufs/ufshcd.c:8398:1: sparse: sparse: unused label 'out'

vim +/out +8398 drivers/scsi/ufs/ufshcd.c

57d104c153d3d6d Subhash Jadavani   2014-09-25  8335  
57d104c153d3d6d Subhash Jadavani   2014-09-25  8336  /**
57d104c153d3d6d Subhash Jadavani   2014-09-25  8337   * ufshcd_set_dev_pwr_mode - sends START STOP UNIT command to set device
57d104c153d3d6d Subhash Jadavani   2014-09-25  8338   *			     power mode
57d104c153d3d6d Subhash Jadavani   2014-09-25  8339   * @hba: per adapter instance
57d104c153d3d6d Subhash Jadavani   2014-09-25  8340   * @pwr_mode: device power mode to set
57d104c153d3d6d Subhash Jadavani   2014-09-25  8341   *
57d104c153d3d6d Subhash Jadavani   2014-09-25  8342   * Returns 0 if requested power mode is set successfully
57d104c153d3d6d Subhash Jadavani   2014-09-25  8343   * Returns non-zero if failed to set the requested power mode
57d104c153d3d6d Subhash Jadavani   2014-09-25  8344   */
57d104c153d3d6d Subhash Jadavani   2014-09-25  8345  static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba,
57d104c153d3d6d Subhash Jadavani   2014-09-25  8346  				     enum ufs_dev_pwr_mode pwr_mode)
57d104c153d3d6d Subhash Jadavani   2014-09-25  8347  {
57d104c153d3d6d Subhash Jadavani   2014-09-25  8348  	unsigned char cmd[6] = { START_STOP };
57d104c153d3d6d Subhash Jadavani   2014-09-25  8349  	struct scsi_sense_hdr sshdr;
7c48bfd038e570c Akinobu Mita       2014-10-23  8350  	struct scsi_device *sdp;
7c48bfd038e570c Akinobu Mita       2014-10-23  8351  	unsigned long flags;
57d104c153d3d6d Subhash Jadavani   2014-09-25  8352  	int ret;
57d104c153d3d6d Subhash Jadavani   2014-09-25  8353  
7c48bfd038e570c Akinobu Mita       2014-10-23  8354  	spin_lock_irqsave(hba->host->host_lock, flags);
7c48bfd038e570c Akinobu Mita       2014-10-23  8355  	sdp = hba->sdev_ufs_device;
7c48bfd038e570c Akinobu Mita       2014-10-23  8356  	if (sdp) {
7c48bfd038e570c Akinobu Mita       2014-10-23  8357  		ret = scsi_device_get(sdp);
7c48bfd038e570c Akinobu Mita       2014-10-23  8358  		if (!ret && !scsi_device_online(sdp)) {
7c48bfd038e570c Akinobu Mita       2014-10-23  8359  			ret = -ENODEV;
7c48bfd038e570c Akinobu Mita       2014-10-23  8360  			scsi_device_put(sdp);
7c48bfd038e570c Akinobu Mita       2014-10-23  8361  		}
7c48bfd038e570c Akinobu Mita       2014-10-23  8362  	} else {
7c48bfd038e570c Akinobu Mita       2014-10-23  8363  		ret = -ENODEV;
7c48bfd038e570c Akinobu Mita       2014-10-23  8364  	}
7c48bfd038e570c Akinobu Mita       2014-10-23  8365  	spin_unlock_irqrestore(hba->host->host_lock, flags);
7c48bfd038e570c Akinobu Mita       2014-10-23  8366  
7c48bfd038e570c Akinobu Mita       2014-10-23  8367  	if (ret)
7c48bfd038e570c Akinobu Mita       2014-10-23  8368  		return ret;
57d104c153d3d6d Subhash Jadavani   2014-09-25  8369  
57d104c153d3d6d Subhash Jadavani   2014-09-25  8370  	/*
57d104c153d3d6d Subhash Jadavani   2014-09-25  8371  	 * If scsi commands fail, the scsi mid-layer schedules scsi error-
57d104c153d3d6d Subhash Jadavani   2014-09-25  8372  	 * handling, which would wait for host to be resumed. Since we know
57d104c153d3d6d Subhash Jadavani   2014-09-25  8373  	 * we are functional while we are here, skip host resume in error
57d104c153d3d6d Subhash Jadavani   2014-09-25  8374  	 * handling context.
57d104c153d3d6d Subhash Jadavani   2014-09-25  8375  	 */
57d104c153d3d6d Subhash Jadavani   2014-09-25  8376  	hba->host->eh_noresume = 1;
0636adf2e888008 Randall Huang      2020-11-30  8377  	ufshcd_clear_ua_wluns(hba);
57d104c153d3d6d Subhash Jadavani   2014-09-25  8378  
57d104c153d3d6d Subhash Jadavani   2014-09-25  8379  	cmd[4] = pwr_mode << 4;
57d104c153d3d6d Subhash Jadavani   2014-09-25  8380  
57d104c153d3d6d Subhash Jadavani   2014-09-25  8381  	/*
57d104c153d3d6d Subhash Jadavani   2014-09-25  8382  	 * Current function would be generally called from the power management
e806402130c9c49 Christoph Hellwig  2016-10-20  8383  	 * callbacks hence set the RQF_PM flag so that it doesn't resume the
57d104c153d3d6d Subhash Jadavani   2014-09-25  8384  	 * already suspended childs.
57d104c153d3d6d Subhash Jadavani   2014-09-25  8385  	 */
fcbfffe2c5cbec0 Christoph Hellwig  2017-02-23  8386  	ret = scsi_execute(sdp, cmd, DMA_NONE, NULL, 0, NULL, &sshdr,
fcbfffe2c5cbec0 Christoph Hellwig  2017-02-23  8387  			START_STOP_TIMEOUT, 0, 0, RQF_PM, NULL);
57d104c153d3d6d Subhash Jadavani   2014-09-25  8388  	if (ret) {
57d104c153d3d6d Subhash Jadavani   2014-09-25  8389  		sdev_printk(KERN_WARNING, sdp,
ef61329db7b8b43 Hannes Reinecke    2014-10-24  8390  			    "START_STOP failed for power mode: %d, result %x\n",
ef61329db7b8b43 Hannes Reinecke    2014-10-24  8391  			    pwr_mode, ret);
c65be1a63f1df22 Johannes Thumshirn 2018-06-25  8392  		if (driver_byte(ret) == DRIVER_SENSE)
2104551969e8011 Hannes Reinecke    2015-01-08  8393  			scsi_print_sense_hdr(sdp, NULL, &sshdr);
57d104c153d3d6d Subhash Jadavani   2014-09-25  8394  	}
57d104c153d3d6d Subhash Jadavani   2014-09-25  8395  
57d104c153d3d6d Subhash Jadavani   2014-09-25  8396  	if (!ret)
57d104c153d3d6d Subhash Jadavani   2014-09-25  8397  		hba->curr_dev_pwr_mode = pwr_mode;
57d104c153d3d6d Subhash Jadavani   2014-09-25 @8398  out:
7c48bfd038e570c Akinobu Mita       2014-10-23  8399  	scsi_device_put(sdp);
57d104c153d3d6d Subhash Jadavani   2014-09-25  8400  	hba->host->eh_noresume = 0;
57d104c153d3d6d Subhash Jadavani   2014-09-25  8401  	return ret;
57d104c153d3d6d Subhash Jadavani   2014-09-25  8402  }
57d104c153d3d6d Subhash Jadavani   2014-09-25  8403  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 32498 bytes --]

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

end of thread, other threads:[~2020-12-09  2:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-01  4:14 [PATCH] scsi: ufs: clear uac for RPMB after ufshcd resets Jaegeuk Kim
2020-12-01  7:39 ` kernel test robot
2020-12-01  7:39   ` kernel test robot
2020-12-08 21:51 ` [PATCH v2] " Jaegeuk Kim
2020-12-09  1:06   ` Stanley Chu
2020-12-09  2:36   ` Martin K. Petersen
2020-12-01  6:31 [PATCH] " kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.