All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: ufs: Correct the lun used in eh_device_reset_handler() callback
@ 2020-12-28 12:04 Can Guo
  2020-12-30  7:20 ` Avri Altman
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Can Guo @ 2020-12-28 12:04 UTC (permalink / raw)
  To: asutoshd, nguyenb, hongwus, ziqichen, rnayak, linux-scsi,
	kernel-team, saravanak, salyzyn, cang
  Cc: Alim Akhtar, Avri Altman, James E.J. Bottomley,
	Martin K. Petersen, Stanley Chu, Bean Huo, Bart Van Assche,
	open list

Users can initiate resets to specific SCSI device/target/host through
IOCTL. When this happens, the SCSI cmd passed to eh_device/target/host
_reset_handler() callbacks is initialized with a request whose tag is -1.
So, in this case, it is not right for eh_device_reset_handler() callback
to count on the lun get from hba->lrb[-1]. Fix it by getting lun from the
SCSI device associated with the SCSI cmd.

Signed-off-by: Can Guo <cang@codeaurora.org>

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 98093a5..d577cda 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -6604,19 +6604,16 @@ static int ufshcd_eh_device_reset_handler(struct scsi_cmnd *cmd)
 {
 	struct Scsi_Host *host;
 	struct ufs_hba *hba;
-	unsigned int tag;
 	u32 pos;
 	int err;
-	u8 resp = 0xF;
-	struct ufshcd_lrb *lrbp;
+	u8 resp = 0xF, lun;
 	unsigned long flags;
 
 	host = cmd->device->host;
 	hba = shost_priv(host);
-	tag = cmd->request->tag;
 
-	lrbp = &hba->lrb[tag];
-	err = ufshcd_issue_tm_cmd(hba, lrbp->lun, 0, UFS_LOGICAL_RESET, &resp);
+	lun = ufshcd_scsi_to_upiu_lun(cmd->device->lun);
+	err = ufshcd_issue_tm_cmd(hba, lun, 0, UFS_LOGICAL_RESET, &resp);
 	if (err || resp != UPIU_TASK_MANAGEMENT_FUNC_COMPL) {
 		if (!err)
 			err = resp;
@@ -6625,7 +6622,7 @@ static int ufshcd_eh_device_reset_handler(struct scsi_cmnd *cmd)
 
 	/* clear the commands that were pending for corresponding LUN */
 	for_each_set_bit(pos, &hba->outstanding_reqs, hba->nutrs) {
-		if (hba->lrb[pos].lun == lrbp->lun) {
+		if (hba->lrb[pos].lun == lun) {
 			err = ufshcd_clear_cmd(hba, pos);
 			if (err)
 				break;
-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.


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

* RE: [PATCH] scsi: ufs: Correct the lun used in eh_device_reset_handler() callback
  2020-12-28 12:04 [PATCH] scsi: ufs: Correct the lun used in eh_device_reset_handler() callback Can Guo
@ 2020-12-30  7:20 ` Avri Altman
  2020-12-30  7:49   ` Can Guo
  2020-12-30  8:33 ` Stanley Chu
  2021-01-08  4:19 ` Martin K. Petersen
  2 siblings, 1 reply; 5+ messages in thread
From: Avri Altman @ 2020-12-30  7:20 UTC (permalink / raw)
  To: Can Guo, asutoshd, nguyenb, hongwus, ziqichen, rnayak,
	linux-scsi, kernel-team, saravanak, salyzyn
  Cc: Alim Akhtar, James E.J. Bottomley, Martin K. Petersen,
	Stanley Chu, Bean Huo, Bart Van Assche, open list

 
> Users can initiate resets to specific SCSI device/target/host through
> IOCTL. When this happens, the SCSI cmd passed to eh_device/target/host
> _reset_handler() callbacks is initialized with a request whose tag is -1.
> So, in this case, it is not right for eh_device_reset_handler() callback
> to count on the lun get from hba->lrb[-1]. Fix it by getting lun from the
> SCSI device associated with the SCSI cmd.
> 
> Signed-off-by: Can Guo <cang@codeaurora.org>
Reviewed-by: Avri Altman <avri.altman@wdc.com>

Btw, am surprised to see that you guys are still using sg_reset instead of ufs-utils?

Thanks,
Avri

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

* Re: [PATCH] scsi: ufs: Correct the lun used in eh_device_reset_handler() callback
  2020-12-30  7:20 ` Avri Altman
@ 2020-12-30  7:49   ` Can Guo
  0 siblings, 0 replies; 5+ messages in thread
From: Can Guo @ 2020-12-30  7:49 UTC (permalink / raw)
  To: Avri Altman
  Cc: asutoshd, nguyenb, hongwus, ziqichen, rnayak, linux-scsi,
	kernel-team, saravanak, salyzyn, Alim Akhtar,
	James E.J. Bottomley, Martin K. Petersen, Stanley Chu, Bean Huo,
	Bart Van Assche, open list

On 2020-12-30 15:20, Avri Altman wrote:
>> Users can initiate resets to specific SCSI device/target/host through
>> IOCTL. When this happens, the SCSI cmd passed to eh_device/target/host
>> _reset_handler() callbacks is initialized with a request whose tag is 
>> -1.
>> So, in this case, it is not right for eh_device_reset_handler() 
>> callback
>> to count on the lun get from hba->lrb[-1]. Fix it by getting lun from 
>> the
>> SCSI device associated with the SCSI cmd.
>> 
>> Signed-off-by: Can Guo <cang@codeaurora.org>
> Reviewed-by: Avri Altman <avri.altman@wdc.com>
> 
> Btw, am surprised to see that you guys are still using sg_reset
> instead of ufs-utils?

Hi Avri,

We are not using any user layer tools at all. But I am confronted
with many customers and tons of test teams inside and outside.
I see all kinds of corner cases everyday, so not surprised at all.

Thanks,
Can Guo

> 
> Thanks,
> Avri

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

* Re: [PATCH] scsi: ufs: Correct the lun used in eh_device_reset_handler() callback
  2020-12-28 12:04 [PATCH] scsi: ufs: Correct the lun used in eh_device_reset_handler() callback Can Guo
  2020-12-30  7:20 ` Avri Altman
@ 2020-12-30  8:33 ` Stanley Chu
  2021-01-08  4:19 ` Martin K. Petersen
  2 siblings, 0 replies; 5+ messages in thread
From: Stanley Chu @ 2020-12-30  8:33 UTC (permalink / raw)
  To: Can Guo
  Cc: asutoshd, nguyenb, hongwus, ziqichen, rnayak, linux-scsi,
	kernel-team, saravanak, salyzyn, Alim Akhtar, Avri Altman,
	James E.J. Bottomley, Martin K. Petersen, Bean Huo,
	Bart Van Assche, open list

On Mon, 2020-12-28 at 04:04 -0800, Can Guo wrote:
> Users can initiate resets to specific SCSI device/target/host through
> IOCTL. When this happens, the SCSI cmd passed to eh_device/target/host
> _reset_handler() callbacks is initialized with a request whose tag is -1.
> So, in this case, it is not right for eh_device_reset_handler() callback
> to count on the lun get from hba->lrb[-1]. Fix it by getting lun from the
> SCSI device associated with the SCSI cmd.
> 
> Signed-off-by: Can Guo <cang@codeaurora.org>

Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>

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

* Re: [PATCH] scsi: ufs: Correct the lun used in eh_device_reset_handler() callback
  2020-12-28 12:04 [PATCH] scsi: ufs: Correct the lun used in eh_device_reset_handler() callback Can Guo
  2020-12-30  7:20 ` Avri Altman
  2020-12-30  8:33 ` Stanley Chu
@ 2021-01-08  4:19 ` Martin K. Petersen
  2 siblings, 0 replies; 5+ messages in thread
From: Martin K. Petersen @ 2021-01-08  4:19 UTC (permalink / raw)
  To: kernel-team, linux-scsi, ziqichen, saravanak, rnayak, Can Guo,
	hongwus, nguyenb, asutoshd, salyzyn
  Cc: Martin K . Petersen, Bean Huo, James E.J. Bottomley, Stanley Chu,
	Bart Van Assche, Avri Altman, open list, Alim Akhtar

On Mon, 28 Dec 2020 04:04:36 -0800, Can Guo wrote:

> Users can initiate resets to specific SCSI device/target/host through
> IOCTL. When this happens, the SCSI cmd passed to eh_device/target/host
> _reset_handler() callbacks is initialized with a request whose tag is -1.
> So, in this case, it is not right for eh_device_reset_handler() callback
> to count on the lun get from hba->lrb[-1]. Fix it by getting lun from the
> SCSI device associated with the SCSI cmd.

Applied to 5.11/scsi-fixes, thanks!

[1/1] scsi: ufs: Correct the lun used in eh_device_reset_handler() callback
      https://git.kernel.org/mkp/scsi/c/35fc4cd34426

-- 
Martin K. Petersen	Oracle Linux Engineering

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

end of thread, other threads:[~2021-01-08  4:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-28 12:04 [PATCH] scsi: ufs: Correct the lun used in eh_device_reset_handler() callback Can Guo
2020-12-30  7:20 ` Avri Altman
2020-12-30  7:49   ` Can Guo
2020-12-30  8:33 ` Stanley Chu
2021-01-08  4:19 ` Martin K. Petersen

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.