scsi: ufs: core: Fix synchronization between scsi_unjam_host() and ufshcd_queuecommand()
PATCH 1/1 scsi: ufs: core: Fix synchronization between scsi_unjam_host() and ufshcd_queuecommand()
The SCSI error handler calls scsi_unjam_host() which can call the queue function ufshcd_queuecommand() indirectly. The error handler changes the state to UFSHCD_STATE_RESET while running, but error interrupts that happen while the error handler is running could change the state to UFSHCD_STATE_EH_SCHEDULED_NON_FATAL which would allow requests to go through ufshcd_queuecommand() even though the error handler is running. Block that hole by checking whether the error handler is in progress.
--- drivers/scsi/ufs/ufshcd.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/scsi/ufs/ufshcd.c +5 -0
@@ -2688,7 +2688,12 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)switch (hba->ufshcd_state) {case UFSHCD_STATE_OPERATIONAL : +break ;case UFSHCD_STATE_EH_SCHEDULED_NON_FATAL : +if (ufshcd_eh_in_progress (hba)) { + err =SCSI_MLQUEUE_HOST_BUSY ; + goto out; + }break ;case UFSHCD_STATE_EH_SCHEDULED_FATAL :/*
Signature · 1 line
2.25.1
Quoted 19 lines · Adrian Hunter
The SCSI error handler calls
scsi_unjam_host()which can call the queue functionufshcd_queuecommand()indirectly. The error handler changes the state toUFSHCD_STATE_RESETwhile running, but error interrupts that happen while the error handler is running could change the state toUFSHCD_STATE_EH_SCHEDULED_NON_FATALwhich would allow requests to go throughufshcd_queuecommand()even though the error handler is running. Block that hole by checking whether the error handler is in progress.Signed-off-by Adrian Hunter <[email protected]>--- drivers/scsi/ufs/ufshcd.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/scsi/ufs/ufshcd.c +0
-0@@ -2688,7 +2688,12 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
drivers/scsi/ufs/ufshcd.c static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) · line 2698
Quoted 10 lines
drivers/scsi/ufs/ufshcd.c +5
-0switch (hba->ufshcd_state) {case UFSHCD_STATE_OPERATIONAL : +break ;case UFSHCD_STATE_EH_SCHEDULED_NON_FATAL : +if (ufshcd_eh_in_progress (hba)) { + err =SCSI_MLQUEUE_HOST_BUSY ; + goto out; + }break ;case UFSHCD_STATE_EH_SCHEDULED_FATAL :
Please add a comment in ufshcd_queuecommand() that explains why the new code returns SCSI_MLQUEUE_HOST_BUSY.
Thanks,
Bart.