Linux ATA/IDE development
 help / color / mirror / Atom feed
* [PATCH] ata: libata-core: Check device support before querying power state
@ 2026-10-26 20:25 Giuseppe Piscitelli
  2026-10-27 20:29 ` Niklas Cassel
  0 siblings, 1 reply; 2+ messages in thread
From: Giuseppe Piscitelli @ 2026-10-26 20:25 UTC (permalink / raw)
  To: Damien Le Moal, Niklas Cassel; +Cc: linux-ide, linux-kernel

The standby path queries the power state before checking whether the
device accepts ATA power-management commands. This sends CHECK POWER MODE
to ATAPI devices, including the QEMU DVD-ROM, which rejects it.

Run the existing taskfile initialization and device-class check first,
as the active-power path already does.

Fixes: 9cec467d0502 ("ata: libata-core: Do not call ata_dev_power_set_standby() twice")
Signed-off-by: Giuseppe Piscitelli <ooonea@gmail.com>
---
OpenAI Codex investigated the QEMU DVD power-command failures and wrote
this fix and its local validation.

Earlier validation covered 1,536 source-body dispatch cases, a Linux 7.3
build and two ordinary corrected QEMU DVD cycles. No exhaustive ATA/ATAPI
hardware matrix was run. This base was checked for applicability; no new
build or runtime test was run.

 drivers/ata/libata-core.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 92233fb..c644e2c 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -2047,6 +2047,10 @@ void ata_dev_power_set_standby(struct ata_device *dev)
 	struct ata_taskfile tf;
 	unsigned int err_mask;
 
+	/* Issue STANDBY IMMEDIATE command only if supported by the device */
+	if (!ata_dev_power_init_tf(dev, &tf, false))
+		return;
+
 	/* If the device is already sleeping or in standby, do nothing. */
 	if ((dev->flags & ATA_DFLAG_SLEEPING) ||
 	    !ata_dev_power_is_active(dev))
@@ -2065,10 +2069,6 @@ void ata_dev_power_set_standby(struct ata_device *dev)
 	    system_entering_hibernation())
 		return;
 
-	/* Issue STANDBY IMMEDIATE command only if supported by the device */
-	if (!ata_dev_power_init_tf(dev, &tf, false))
-		return;
-
 	ata_dev_notice(dev, "Entering standby power mode\n");
 
 	err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0);
base-commit: 69be770908ae57354a41d7e1cc99ab46278d2e86
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ata: libata-core: Check device support before querying power state
  2026-10-26 20:25 [PATCH] ata: libata-core: Check device support before querying power state Giuseppe Piscitelli
@ 2026-10-27 20:29 ` Niklas Cassel
  0 siblings, 0 replies; 2+ messages in thread
From: Niklas Cassel @ 2026-10-27 20:29 UTC (permalink / raw)
  To: Giuseppe Piscitelli; +Cc: Damien Le Moal, linux-ide, linux-kernel

On Mon, Oct 26, 2026 at 09:25:11PM +0100, Giuseppe Piscitelli wrote:
> The standby path queries the power state before checking whether the
> device accepts ATA power-management commands. This sends CHECK POWER MODE
> to ATAPI devices, including the QEMU DVD-ROM, which rejects it.
> 
> Run the existing taskfile initialization and device-class check first,
> as the active-power path already does.
> 
> Fixes: 9cec467d0502 ("ata: libata-core: Do not call ata_dev_power_set_standby() twice")
> Signed-off-by: Giuseppe Piscitelli <ooonea@gmail.com>
> ---

Reviewed-by: Niklas Cassel <cassel@kernel.org>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-27 20:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-26 20:25 [PATCH] ata: libata-core: Check device support before querying power state Giuseppe Piscitelli
2026-10-27 20:29 ` Niklas Cassel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox