diff mbox series

[v2,2/3] scsi: ufs: introduce force requeue

Message ID d036f1ee837697809533e8b14c62c4d850645143.1631519695.git.kwmad.kim@samsung.com
State New
Headers show
Series scsi: ufs: introduce vendor isr | expand

Commit Message

Kiwoong Kim Sept. 13, 2021, 7:55 a.m. UTC
When a data command is completed but its data integrity
isn't guaranteed, the driver doesn't return any errors
but user land could face various abnormal symtoms.
All the pending commands should be queued again only if
those events could be detected before the commands are
completed. Because it could be a disaster, especially if
the command is write.

Signed-off-by: Kiwoong Kim <kwmad.kim@samsung.com>
---
 drivers/scsi/ufs/ufshcd.c | 8 ++++++--
 drivers/scsi/ufs/ufshcd.h | 1 +
 2 files changed, 7 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 604c505..6550052 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -5294,8 +5294,11 @@  static void __ufshcd_transfer_req_compl(struct ufs_hba *hba,
 			if (unlikely(ufshcd_should_inform_monitor(hba, lrbp)))
 				ufshcd_update_monitor(hba, lrbp);
 			ufshcd_add_command_trace(hba, index, UFS_CMD_COMP);
-			result = retry_requests ? DID_BUS_BUSY << 16 :
-				ufshcd_transfer_rsp_status(hba, lrbp);
+			if (hba->force_requeue)
+				result = DID_REQUEUE << 16;
+			else
+				result = retry_requests ? DID_BUS_BUSY << 16 :
+					ufshcd_transfer_rsp_status(hba, lrbp);
 			scsi_dma_unmap(cmd);
 			cmd->result = result;
 			/* Mark completed command as NULL in LRB */
@@ -6200,6 +6203,7 @@  static void ufshcd_err_handler(struct Scsi_Host *host)
 	/* Fatal errors need reset */
 	if (needs_reset) {
 		hba->force_reset = false;
+		hba->force_requeue = false;
 		spin_unlock_irqrestore(hba->host->host_lock, flags);
 		err = ufshcd_reset_and_restore(hba);
 		if (err)
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index 7af5d5b..642c547 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -855,6 +855,7 @@  struct ufs_hba {
 	bool force_reset;
 	bool force_pmc;
 	bool silence_err_logs;
+	bool force_requeue;
 
 	/* Device management request data */
 	struct ufs_dev_cmd dev_cmd;