Re: [PATCH] scsi: ufs: core: Skip completion of SCSI commands owned by the SCSI EH

From: Bart Van Assche

Date: Thu Oct 29 2026 - 11:38:06 EST


On 10/29/26 12:09 AM, Stanley Jhu wrote:
+static inline bool ufshcd_cmd_owned_by_scsi_eh(struct scsi_cmnd *cmd)
+{
+ return cmd->submitter == SUBMITTED_BY_BLOCK_LAYER &&
+ test_bit(SCMD_STATE_COMPLETE, &cmd->state);
+}

This is a layering violation. The UFS driver has no business checking
these fields. cmd->submitter checks and cmd->state checks should happen
by the SCSI core and not by any SCSI LLD.

@@ -6009,6 +6025,10 @@ void ufshcd_compl_one_cqe(struct ufs_hba *hba, int task_tag,
lrbp->compl_time_stamp_local_clock = local_clock();
}
if (ufshcd_is_scsi_cmd(cmd)) {
+ if (unlikely(ufshcd_cmd_owned_by_scsi_eh(cmd))) {
+ ufshcd_release_scsi_cmd(hba, cmd);
+ return;
+ }
if (unlikely(ufshcd_should_inform_monitor(hba, cmd)))
ufshcd_update_monitor(hba, cmd);
ufshcd_add_command_trace(hba, cmd, UFS_CMD_COMP);

The problem described in the patch description applies to all SCSI LLDs
and hence should be solved in a generic way instead of in the UFS driver
only.

Bart.