Skip to content

Commit 1ea1031

Browse files
committed
ide: fix IDE ACPI for slave device-only configurations
ACPI _GTM / _PS0 / _STM were not called if only slave device was present. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
1 parent 0964dbe commit 1ea1031

1 file changed

Lines changed: 10 additions & 11 deletions

File tree

‎drivers/ide/ide.c‎

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -365,15 +365,15 @@ __IDE_DEVSET(pio_mode, 0, NULL, set_pio_mode);
365365

366366
static int generic_ide_suspend(struct device *dev, pm_message_t mesg)
367367
{
368-
ide_drive_t *drive = dev->driver_data;
368+
ide_drive_t *drive = dev->driver_data, *pair = ide_get_pair_dev(drive);
369369
ide_hwif_t *hwif = HWIF(drive);
370370
struct request *rq;
371371
struct request_pm_state rqpm;
372372
ide_task_t args;
373373
int ret;
374374

375-
/* Call ACPI _GTM only once */
376-
if (!(drive->dn % 2))
375+
/* call ACPI _GTM only once */
376+
if ((drive->dn & 1) == 0 || pair == NULL)
377377
ide_acpi_get_timing(hwif);
378378

379379
memset(&rqpm, 0, sizeof(rqpm));
@@ -389,26 +389,25 @@ static int generic_ide_suspend(struct device *dev, pm_message_t mesg)
389389

390390
ret = blk_execute_rq(drive->queue, NULL, rq, 0);
391391
blk_put_request(rq);
392-
/* only call ACPI _PS3 after both drivers are suspended */
393-
if (!ret && (((drive->dn % 2) && hwif->drives[0].present
394-
&& hwif->drives[1].present)
395-
|| !hwif->drives[0].present
396-
|| !hwif->drives[1].present))
392+
393+
/* call ACPI _PS3 only after both devices are suspended */
394+
if (ret == 0 && ((drive->dn & 1) || pair == NULL))
397395
ide_acpi_set_state(hwif, 0);
396+
398397
return ret;
399398
}
400399

401400
static int generic_ide_resume(struct device *dev)
402401
{
403-
ide_drive_t *drive = dev->driver_data;
402+
ide_drive_t *drive = dev->driver_data, *pair = ide_get_pair_dev(drive);
404403
ide_hwif_t *hwif = HWIF(drive);
405404
struct request *rq;
406405
struct request_pm_state rqpm;
407406
ide_task_t args;
408407
int err;
409408

410-
/* Call ACPI _STM only once */
411-
if (!(drive->dn % 2)) {
409+
/* call ACPI _PS0 / _STM only once */
410+
if ((drive->dn & 1) == 0 || pair == NULL) {
412411
ide_acpi_set_state(hwif, 1);
413412
ide_acpi_push_timing(hwif);
414413
}

0 commit comments

Comments
 (0)