* [PATCH v=2] ata: libata-scsi: fix requeue of deferred ATA PASS-THROUGH commands
@ 2026-04-12 15:36 Igor Pylypiv
2026-04-12 16:32 ` Sergey Shtylyov
2026-04-12 18:11 ` Niklas Cassel
0 siblings, 2 replies; 3+ messages in thread
From: Igor Pylypiv @ 2026-04-12 15:36 UTC (permalink / raw)
To: Damien Le Moal, Niklas Cassel
Cc: Martin K. Petersen, John Garry, Xingui Yang, linux-ide,
linux-kernel, Igor Pylypiv
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@kernel.org>
Signed-off-by: Igor Pylypiv <ipylypiv@google.com>
---
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
@@ -1692,7 +1692,7 @@ void ata_scsi_requeue_deferred_qc(struct ata_port *ap)
/*
* If we have a deferred qc when a reset occurs or NCQ commands fail,
* do not try to be smart about what to do with this deferred command
- * and simply retry it by completing it with DID_SOFT_ERROR.
+ * and simply requeue it by completing it with DID_REQUEUE.
*/
if (!qc)
return;
@@ -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);
scsi_done(scmd);
}
--
2.53.0.1213.gd9a14994de-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v=2] ata: libata-scsi: fix requeue of deferred ATA PASS-THROUGH commands
2026-04-12 15:36 [PATCH v=2] ata: libata-scsi: fix requeue of deferred ATA PASS-THROUGH commands Igor Pylypiv
@ 2026-04-12 16:32 ` Sergey Shtylyov
2026-04-12 18:11 ` Niklas Cassel
1 sibling, 0 replies; 3+ messages in thread
From: Sergey Shtylyov @ 2026-04-12 16:32 UTC (permalink / raw)
To: Igor Pylypiv, Damien Le Moal, Niklas Cassel
Cc: Martin K. Petersen, John Garry, Xingui Yang, linux-ide,
linux-kernel
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@kernel.org>
> Signed-off-by: Igor Pylypiv <ipylypiv@google.com>
> ---
>
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v=2] ata: libata-scsi: fix requeue of deferred ATA PASS-THROUGH commands
2026-04-12 15:36 [PATCH v=2] ata: libata-scsi: fix requeue of deferred ATA PASS-THROUGH commands Igor Pylypiv
2026-04-12 16:32 ` Sergey Shtylyov
@ 2026-04-12 18:11 ` Niklas Cassel
1 sibling, 0 replies; 3+ messages in thread
From: Niklas Cassel @ 2026-04-12 18:11 UTC (permalink / raw)
To: Damien Le Moal, Igor Pylypiv, linux-kernel
Cc: Niklas Cassel, Martin K. Petersen, John Garry, Xingui Yang,
linux-ide, Sergey Shtylyov
On Sun, 12 Apr 2026 08:36:37 -0700, 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.
>
> [...]
Hello Igor,
Considering that Linus is expected for release 7.0 any minute now (it is
already Sunday afternoon), it seems too late to send this as a PR for 7.0.
The fix will have to be backported to v7.0 stable instead.
Therefore, I rebased your patch on libata/for-next
(without any parens - the comment from Sergey).
Applied to libata/linux.git (for-7.1), thanks!
[1/1] ata: libata-scsi: fix requeue of deferred ATA PASS-THROUGH commands
https://git.kernel.org/libata/linux/c/8ebf408e
Kind regards,
Niklas
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-04-12 18:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-12 15:36 [PATCH v=2] ata: libata-scsi: fix requeue of deferred ATA PASS-THROUGH commands Igor Pylypiv
2026-04-12 16:32 ` Sergey Shtylyov
2026-04-12 18:11 ` Niklas Cassel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox