Skip to content

Commit 35fc4cd

Browse files
Can Guomartinkpetersen
authored andcommitted
scsi: ufs: Correct the LUN used in eh_device_reset_handler() callback
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. 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. Link: https://lore.kernel.org/r/1609157080-26283-1-git-send-email-cang@codeaurora.org Reviewed-by: Avri Altman <avri.altman@wdc.com> Reviewed-by: Stanley Chu <stanley.chu@mediatek.com> Signed-off-by: Can Guo <cang@codeaurora.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 6948a96 commit 35fc4cd

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

drivers/scsi/ufs/ufshcd.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6659,19 +6659,16 @@ static int ufshcd_eh_device_reset_handler(struct scsi_cmnd *cmd)
66596659
{
66606660
struct Scsi_Host *host;
66616661
struct ufs_hba *hba;
6662-
unsigned int tag;
66636662
u32 pos;
66646663
int err;
6665-
u8 resp = 0xF;
6666-
struct ufshcd_lrb *lrbp;
6664+
u8 resp = 0xF, lun;
66676665
unsigned long flags;
66686666

66696667
host = cmd->device->host;
66706668
hba = shost_priv(host);
6671-
tag = cmd->request->tag;
66726669

6673-
lrbp = &hba->lrb[tag];
6674-
err = ufshcd_issue_tm_cmd(hba, lrbp->lun, 0, UFS_LOGICAL_RESET, &resp);
6670+
lun = ufshcd_scsi_to_upiu_lun(cmd->device->lun);
6671+
err = ufshcd_issue_tm_cmd(hba, lun, 0, UFS_LOGICAL_RESET, &resp);
66756672
if (err || resp != UPIU_TASK_MANAGEMENT_FUNC_COMPL) {
66766673
if (!err)
66776674
err = resp;
@@ -6680,7 +6677,7 @@ static int ufshcd_eh_device_reset_handler(struct scsi_cmnd *cmd)
66806677

66816678
/* clear the commands that were pending for corresponding LUN */
66826679
for_each_set_bit(pos, &hba->outstanding_reqs, hba->nutrs) {
6683-
if (hba->lrb[pos].lun == lrbp->lun) {
6680+
if (hba->lrb[pos].lun == lun) {
66846681
err = ufshcd_clear_cmd(hba, pos);
66856682
if (err)
66866683
break;

0 commit comments

Comments
 (0)