ide-pm.c revision 22aa4b32a19b1f231d4ce7e9af6354b577a22a35
1e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz#include <linux/kernel.h> 2e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz#include <linux/ide.h> 3e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz#include <linux/hdreg.h> 4e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz 5e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewiczint generic_ide_suspend(struct device *dev, pm_message_t mesg) 6e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz{ 7e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz ide_drive_t *drive = dev->driver_data, *pair = ide_get_pair_dev(drive); 8898ec223fea2a2df88035e58dbf50f493577e225Bartlomiej Zolnierkiewicz ide_hwif_t *hwif = drive->hwif; 9e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz struct request *rq; 10e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz struct request_pm_state rqpm; 1122aa4b32a19b1f231d4ce7e9af6354b577a22a35Bartlomiej Zolnierkiewicz struct ide_cmd cmd; 12e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz int ret; 13e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz 14e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz /* call ACPI _GTM only once */ 15e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz if ((drive->dn & 1) == 0 || pair == NULL) 16e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz ide_acpi_get_timing(hwif); 17e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz 18e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz memset(&rqpm, 0, sizeof(rqpm)); 1922aa4b32a19b1f231d4ce7e9af6354b577a22a35Bartlomiej Zolnierkiewicz memset(&cmd, 0, sizeof(cmd)); 20e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz rq = blk_get_request(drive->queue, READ, __GFP_WAIT); 21e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz rq->cmd_type = REQ_TYPE_PM_SUSPEND; 2222aa4b32a19b1f231d4ce7e9af6354b577a22a35Bartlomiej Zolnierkiewicz rq->special = &cmd; 23e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz rq->data = &rqpm; 24e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz rqpm.pm_step = IDE_PM_START_SUSPEND; 25e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz if (mesg.event == PM_EVENT_PRETHAW) 26e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz mesg.event = PM_EVENT_FREEZE; 27e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz rqpm.pm_state = mesg.event; 28e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz 29e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz ret = blk_execute_rq(drive->queue, NULL, rq, 0); 30e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz blk_put_request(rq); 31e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz 32e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz /* call ACPI _PS3 only after both devices are suspended */ 33e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz if (ret == 0 && ((drive->dn & 1) || pair == NULL)) 34e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz ide_acpi_set_state(hwif, 0); 35e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz 36e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz return ret; 37e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz} 38e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz 39e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewiczint generic_ide_resume(struct device *dev) 40e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz{ 41e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz ide_drive_t *drive = dev->driver_data, *pair = ide_get_pair_dev(drive); 42898ec223fea2a2df88035e58dbf50f493577e225Bartlomiej Zolnierkiewicz ide_hwif_t *hwif = drive->hwif; 43e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz struct request *rq; 44e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz struct request_pm_state rqpm; 4522aa4b32a19b1f231d4ce7e9af6354b577a22a35Bartlomiej Zolnierkiewicz struct ide_cmd cmd; 46e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz int err; 47e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz 48e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz /* call ACPI _PS0 / _STM only once */ 49e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz if ((drive->dn & 1) == 0 || pair == NULL) { 50e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz ide_acpi_set_state(hwif, 1); 51e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz ide_acpi_push_timing(hwif); 52e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz } 53e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz 54e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz ide_acpi_exec_tfs(drive); 55e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz 56e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz memset(&rqpm, 0, sizeof(rqpm)); 5722aa4b32a19b1f231d4ce7e9af6354b577a22a35Bartlomiej Zolnierkiewicz memset(&cmd, 0, sizeof(cmd)); 58e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz rq = blk_get_request(drive->queue, READ, __GFP_WAIT); 59e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz rq->cmd_type = REQ_TYPE_PM_RESUME; 60e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz rq->cmd_flags |= REQ_PREEMPT; 6122aa4b32a19b1f231d4ce7e9af6354b577a22a35Bartlomiej Zolnierkiewicz rq->special = &cmd; 62e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz rq->data = &rqpm; 63e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz rqpm.pm_step = IDE_PM_START_RESUME; 64e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz rqpm.pm_state = PM_EVENT_ON; 65e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz 66e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz err = blk_execute_rq(drive->queue, NULL, rq, 1); 67e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz blk_put_request(rq); 68e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz 69e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz if (err == 0 && dev->driver) { 707f3c868ba78e486bd9d7569f884dd46d8f59bb18Bartlomiej Zolnierkiewicz struct ide_driver *drv = to_ide_driver(dev->driver); 71e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz 72e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz if (drv->resume) 73e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz drv->resume(drive); 74e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz } 75e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz 76e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz return err; 77e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz} 78e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz 79e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewiczvoid ide_complete_power_step(ide_drive_t *drive, struct request *rq) 80e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz{ 81e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz struct request_pm_state *pm = rq->data; 82e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz 83e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz#ifdef DEBUG_PM 84e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz printk(KERN_INFO "%s: complete_power_step(step: %d)\n", 85e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz drive->name, pm->pm_step); 86e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz#endif 87e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz if (drive->media != ide_disk) 88e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz return; 89e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz 90e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz switch (pm->pm_step) { 91e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz case IDE_PM_FLUSH_CACHE: /* Suspend step 1 (flush cache) */ 92e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz if (pm->pm_state == PM_EVENT_FREEZE) 93e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz pm->pm_step = IDE_PM_COMPLETED; 94e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz else 95e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz pm->pm_step = IDE_PM_STANDBY; 96e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz break; 97e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz case IDE_PM_STANDBY: /* Suspend step 2 (standby) */ 98e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz pm->pm_step = IDE_PM_COMPLETED; 99e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz break; 100e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz case IDE_PM_RESTORE_PIO: /* Resume step 1 (restore PIO) */ 101e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz pm->pm_step = IDE_PM_IDLE; 102e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz break; 103e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz case IDE_PM_IDLE: /* Resume step 2 (idle)*/ 104e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz pm->pm_step = IDE_PM_RESTORE_DMA; 105e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz break; 106e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz } 107e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz} 108e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz 109e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewiczide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *rq) 110e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz{ 111e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz struct request_pm_state *pm = rq->data; 11222aa4b32a19b1f231d4ce7e9af6354b577a22a35Bartlomiej Zolnierkiewicz struct ide_cmd *cmd = rq->special; 113e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz 11422aa4b32a19b1f231d4ce7e9af6354b577a22a35Bartlomiej Zolnierkiewicz memset(cmd, 0, sizeof(*cmd)); 115e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz 116e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz switch (pm->pm_step) { 117e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz case IDE_PM_FLUSH_CACHE: /* Suspend step 1 (flush cache) */ 118e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz if (drive->media != ide_disk) 119e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz break; 120e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz /* Not supported? Switch to next step now. */ 121e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz if (ata_id_flush_enabled(drive->id) == 0 || 122e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz (drive->dev_flags & IDE_DFLAG_WCACHE) == 0) { 123e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz ide_complete_power_step(drive, rq); 124e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz return ide_stopped; 125e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz } 126e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz if (ata_id_flush_ext_enabled(drive->id)) 12722aa4b32a19b1f231d4ce7e9af6354b577a22a35Bartlomiej Zolnierkiewicz cmd->tf.command = ATA_CMD_FLUSH_EXT; 128e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz else 12922aa4b32a19b1f231d4ce7e9af6354b577a22a35Bartlomiej Zolnierkiewicz cmd->tf.command = ATA_CMD_FLUSH; 130e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz goto out_do_tf; 131e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz case IDE_PM_STANDBY: /* Suspend step 2 (standby) */ 13222aa4b32a19b1f231d4ce7e9af6354b577a22a35Bartlomiej Zolnierkiewicz cmd->tf.command = ATA_CMD_STANDBYNOW1; 133e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz goto out_do_tf; 134e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz case IDE_PM_RESTORE_PIO: /* Resume step 1 (restore PIO) */ 135e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz ide_set_max_pio(drive); 136e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz /* 137e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz * skip IDE_PM_IDLE for ATAPI devices 138e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz */ 139e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz if (drive->media != ide_disk) 140e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz pm->pm_step = IDE_PM_RESTORE_DMA; 141e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz else 142e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz ide_complete_power_step(drive, rq); 143e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz return ide_stopped; 144e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz case IDE_PM_IDLE: /* Resume step 2 (idle) */ 14522aa4b32a19b1f231d4ce7e9af6354b577a22a35Bartlomiej Zolnierkiewicz cmd->tf.command = ATA_CMD_IDLEIMMEDIATE; 146e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz goto out_do_tf; 147e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz case IDE_PM_RESTORE_DMA: /* Resume step 3 (restore DMA) */ 148e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz /* 149e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz * Right now, all we do is call ide_set_dma(drive), 150e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz * we could be smarter and check for current xfer_speed 151e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz * in struct drive etc... 152e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz */ 153e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz if (drive->hwif->dma_ops == NULL) 154e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz break; 155e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz /* 156e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz * TODO: respect IDE_DFLAG_USING_DMA 157e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz */ 158e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz ide_set_dma(drive); 159e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz break; 160e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz } 161e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz 162e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz pm->pm_step = IDE_PM_COMPLETED; 16322aa4b32a19b1f231d4ce7e9af6354b577a22a35Bartlomiej Zolnierkiewicz 164e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz return ide_stopped; 165e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz 166e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewiczout_do_tf: 16722aa4b32a19b1f231d4ce7e9af6354b577a22a35Bartlomiej Zolnierkiewicz cmd->tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; 16822aa4b32a19b1f231d4ce7e9af6354b577a22a35Bartlomiej Zolnierkiewicz cmd->data_phase = TASKFILE_NO_DATA; 16922aa4b32a19b1f231d4ce7e9af6354b577a22a35Bartlomiej Zolnierkiewicz 17022aa4b32a19b1f231d4ce7e9af6354b577a22a35Bartlomiej Zolnierkiewicz return do_rw_taskfile(drive, cmd); 171e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz} 172e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz 173e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz/** 1743616b6536a74ff1c56029c17cbb3575c69c0a574Bartlomiej Zolnierkiewicz * ide_complete_pm_rq - end the current Power Management request 175e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz * @drive: target drive 176e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz * @rq: request 177e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz * 178e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz * This function cleans up the current PM request and stops the queue 179e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz * if necessary. 180e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz */ 1813616b6536a74ff1c56029c17cbb3575c69c0a574Bartlomiej Zolnierkiewiczvoid ide_complete_pm_rq(ide_drive_t *drive, struct request *rq) 182e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz{ 183e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz struct request_queue *q = drive->queue; 1843616b6536a74ff1c56029c17cbb3575c69c0a574Bartlomiej Zolnierkiewicz struct request_pm_state *pm = rq->data; 185e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz unsigned long flags; 186e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz 1873616b6536a74ff1c56029c17cbb3575c69c0a574Bartlomiej Zolnierkiewicz ide_complete_power_step(drive, rq); 1883616b6536a74ff1c56029c17cbb3575c69c0a574Bartlomiej Zolnierkiewicz if (pm->pm_step != IDE_PM_COMPLETED) 1893616b6536a74ff1c56029c17cbb3575c69c0a574Bartlomiej Zolnierkiewicz return; 1903616b6536a74ff1c56029c17cbb3575c69c0a574Bartlomiej Zolnierkiewicz 191e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz#ifdef DEBUG_PM 192e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz printk("%s: completing PM request, %s\n", drive->name, 193e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz blk_pm_suspend_request(rq) ? "suspend" : "resume"); 194e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz#endif 195e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz spin_lock_irqsave(q->queue_lock, flags); 1962ea5521022ac8f4f528dcbae02668e02a3501a5aBartlomiej Zolnierkiewicz if (blk_pm_suspend_request(rq)) 197e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz blk_stop_queue(q); 1982ea5521022ac8f4f528dcbae02668e02a3501a5aBartlomiej Zolnierkiewicz else 199e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz drive->dev_flags &= ~IDE_DFLAG_BLOCKED; 200e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz spin_unlock_irqrestore(q->queue_lock, flags); 201e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz 202b65fac32cfe3b2f98cd472fef400bd1c1340de23Bartlomiej Zolnierkiewicz drive->hwif->rq = NULL; 203e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz 204e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz if (blk_end_request(rq, 0, 0)) 205e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz BUG(); 206e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz} 207e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz 208e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewiczvoid ide_check_pm_state(ide_drive_t *drive, struct request *rq) 209e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz{ 210e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz struct request_pm_state *pm = rq->data; 211e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz 212e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz if (blk_pm_suspend_request(rq) && 213e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz pm->pm_step == IDE_PM_START_SUSPEND) 214e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz /* Mark drive blocked when starting the suspend sequence. */ 215e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz drive->dev_flags |= IDE_DFLAG_BLOCKED; 216e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz else if (blk_pm_resume_request(rq) && 217e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz pm->pm_step == IDE_PM_START_RESUME) { 218e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz /* 219e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz * The first thing we do on wakeup is to wait for BSY bit to 220e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz * go away (with a looong timeout) as a drive on this hwif may 221e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz * just be POSTing itself. 222e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz * We do that before even selecting as the "other" device on 223e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz * the bus may be broken enough to walk on our toes at this 224e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz * point. 225e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz */ 226e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz ide_hwif_t *hwif = drive->hwif; 2272ea5521022ac8f4f528dcbae02668e02a3501a5aBartlomiej Zolnierkiewicz struct request_queue *q = drive->queue; 2282ea5521022ac8f4f528dcbae02668e02a3501a5aBartlomiej Zolnierkiewicz unsigned long flags; 229e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz int rc; 230e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz#ifdef DEBUG_PM 231e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz printk("%s: Wakeup request inited, waiting for !BSY...\n", drive->name); 232e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz#endif 233e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz rc = ide_wait_not_busy(hwif, 35000); 234e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz if (rc) 235e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz printk(KERN_WARNING "%s: bus not ready on wakeup\n", drive->name); 236e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz SELECT_DRIVE(drive); 237e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz hwif->tp_ops->set_irq(hwif, 1); 238e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz rc = ide_wait_not_busy(hwif, 100000); 239e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz if (rc) 240e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz printk(KERN_WARNING "%s: drive not ready on wakeup\n", drive->name); 2412ea5521022ac8f4f528dcbae02668e02a3501a5aBartlomiej Zolnierkiewicz 2422ea5521022ac8f4f528dcbae02668e02a3501a5aBartlomiej Zolnierkiewicz spin_lock_irqsave(q->queue_lock, flags); 2432ea5521022ac8f4f528dcbae02668e02a3501a5aBartlomiej Zolnierkiewicz blk_start_queue(q); 2442ea5521022ac8f4f528dcbae02668e02a3501a5aBartlomiej Zolnierkiewicz spin_unlock_irqrestore(q->queue_lock, flags); 245e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz } 246e2984c628c924442132304ae662da433f41c05c9Bartlomiej Zolnierkiewicz} 247