Skip to content

Commit b6d76d6

Browse files
bvanasschegregkh
authored andcommitted
scsi: ufs: core: Fix handling of lrbp->cmd
[ Upstream commit 549e91a ] ufshcd_queuecommand() may be called two times in a row for a SCSI command before it is completed. Hence make the following changes: - In the functions that submit a command, do not check the old value of lrbp->cmd nor clear lrbp->cmd in error paths. - In ufshcd_release_scsi_cmd(), do not clear lrbp->cmd. See also scsi_send_eh_cmnd(). This commit prevents that the following appears if a command times out: WARNING: at drivers/ufs/core/ufshcd.c:2965 ufshcd_queuecommand+0x6f8/0x9a8 Call trace: ufshcd_queuecommand+0x6f8/0x9a8 scsi_send_eh_cmnd+0x2c0/0x960 scsi_eh_test_devices+0x100/0x314 scsi_eh_ready_devs+0xd90/0x114c scsi_error_handler+0x2b4/0xb70 kthread+0x16c/0x1e0 Fixes: 5a0b0cb ("[SCSI] ufs: Add support for sending NOP OUT UPIU") Signed-off-by: Bart Van Assche <bvanassche@acm.org> Link: https://lore.kernel.org/r/20230524203659.1394307-3-bvanassche@acm.org Acked-by: Adrian Hunter <adrian.hunter@intel.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> [ Removed the change in ufshcd_advanced_rpmb_req_handler() due to missing commit:6ff265fc5ef6("scsi: ufs: core: bsg: Add advanced RPMB support in ufs_bsg") ] Signed-off-by: Rajani Kantha <681739313@139.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent cfa7458 commit b6d76d6

1 file changed

Lines changed: 1 addition & 5 deletions

File tree

drivers/ufs/core/ufshcd.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2821,7 +2821,6 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
28212821
(hba->clk_gating.state != CLKS_ON));
28222822

28232823
lrbp = &hba->lrb[tag];
2824-
WARN_ON(lrbp->cmd);
28252824
lrbp->cmd = cmd;
28262825
lrbp->task_tag = tag;
28272826
lrbp->lun = ufshcd_scsi_to_upiu_lun(cmd->device->lun);
@@ -2837,7 +2836,6 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
28372836

28382837
err = ufshcd_map_sg(hba, lrbp);
28392838
if (err) {
2840-
lrbp->cmd = NULL;
28412839
ufshcd_release(hba);
28422840
goto out;
28432841
}
@@ -3047,7 +3045,7 @@ static int ufshcd_exec_dev_cmd(struct ufs_hba *hba,
30473045
down_read(&hba->clk_scaling_lock);
30483046

30493047
lrbp = &hba->lrb[tag];
3050-
WARN_ON(lrbp->cmd);
3048+
lrbp->cmd = NULL;
30513049
err = ufshcd_compose_dev_cmd(hba, lrbp, cmd_type, tag);
30523050
if (unlikely(err))
30533051
goto out;
@@ -5357,7 +5355,6 @@ static void ufshcd_release_scsi_cmd(struct ufs_hba *hba,
53575355
struct scsi_cmnd *cmd = lrbp->cmd;
53585356

53595357
scsi_dma_unmap(cmd);
5360-
lrbp->cmd = NULL; /* Mark the command as completed. */
53615358
ufshcd_release(hba);
53625359
ufshcd_clk_scaling_update_busy(hba);
53635360
}
@@ -6936,7 +6933,6 @@ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba,
69366933
down_read(&hba->clk_scaling_lock);
69376934

69386935
lrbp = &hba->lrb[tag];
6939-
WARN_ON(lrbp->cmd);
69406936
lrbp->cmd = NULL;
69416937
lrbp->task_tag = tag;
69426938
lrbp->lun = 0;

0 commit comments

Comments
 (0)