ata: libata-core: Check device support before querying power state
PATCH 1/1 ata: libata-core: Check device support before querying power state
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.
---
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(-)
drivers/ata/libata-core.c +4 -4
@@ -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
Signature · 1 line
2.54.0
Quoted 10 lines · Giuseppe Piscitelli
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 <[email protected]>---
Quoted 8 lines · Giuseppe Piscitelli
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.
[...]
Applied to libata/linux.git (for-7.4-fixes), thanks!
[1/1] ata: libata-core: Check device support before querying power state
https://git.kernel.org/libata/linux/c/ec585ac7
Kind regards,
Niklas