Re: [PATCH v=2] ata: libata-scsi: fix requeue of deferred ATA PASS-THROUGH commands

From: Sergey Shtylyov

Date: Sun Apr 12 2026 - 12:32:46 EST


On 4/12/26 6:36 PM, Igor Pylypiv wrote:

> Commit 0ea84089dbf6 ("ata: libata-scsi: avoid Non-NCQ command starvation")
> introduced ata_scsi_requeue_deferred_qc() to handle commands deferred
> during resets or NCQ failures. This deferral logic completed commands
> with DID_SOFT_ERROR to trigger a retry in the SCSI mid-layer.
>
> However, DID_SOFT_ERROR is subject to scsi_cmd_retry_allowed() checks.
> ATA PASS-THROUGH commands sent via SG_IO ioctl have scmd->allowed set
> to zero. This causes the mid-layer to fail the command immediately
> instead of retrying, even though the command was never actually issued
> to the hardware.
>
> Switch to DID_REQUEUE to ensure these commands are inserted back into
> the request queue regardless of retry limits.
>
> Fixes: 0ea84089dbf6 ("ata: libata-scsi: avoid Non-NCQ command starvation")
> Reviewed-by: Damien Le Moal <dlemoal@xxxxxxxxxx>
> Signed-off-by: Igor Pylypiv <ipylypiv@xxxxxxxxxx>
> ---
>
> Changes from v1:
> - Dropped the usage of set_host_byte() because it is logically a separate
> change from what this commit is fixing. set_host_byte() does not clear
> the status byte and the ML byte.
>
> drivers/ata/libata-scsi.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
> index 3b65df914ebb..cd607911d724 100644
> --- a/drivers/ata/libata-scsi.c
> +++ b/drivers/ata/libata-scsi.c
[...]
> @@ -1701,7 +1701,7 @@ void ata_scsi_requeue_deferred_qc(struct ata_port *ap)
> ap->deferred_qc = NULL;
> cancel_work(&ap->deferred_qc_work);
> ata_qc_free(qc);
> - scmd->result = (DID_SOFT_ERROR << 16);
> + scmd->result = (DID_REQUEUE << 16);

You could drop the useless parens, while at it...

> scsi_done(scmd);
> }
>

MBR, Sergey