Skip to content

Commit

Permalink
libata: reimplement suspend/resume support using sdev->manage_start_stop
Browse files Browse the repository at this point in the history
Reimplement suspend/resume support using sdev->manage_start_stop.

* Device suspend/resume is now SCSI layer's responsibility and the
  code is simplified a lot.

* DPM is dropped.  This also simplifies code a lot.  Suspend/resume
  status is port-wide now.

* ata_scsi_device_suspend/resume() and ata_dev_ready() removed.

* Resume now has to wait for disk to spin up before proceeding.  I
  couldn't find easy way out as libata is in EH waiting for the
  disk to be ready and sd is waiting for EH to complete to issue
  START_STOP.

* sdev->manage_start_stop is set to 1 in ata_scsi_slave_config().
  This fixes spindown on shutdown and suspend-to-disk.

Signed-off-by: Tejun Heo <[email protected]>
Signed-off-by: Jeff Garzik <[email protected]>
  • Loading branch information
htejun authored and Jeff Garzik committed May 11, 2007
1 parent 0a3fd05 commit 9666f40
Show file tree
Hide file tree
Showing 45 changed files with 14 additions and 575 deletions.
4 changes: 0 additions & 4 deletions drivers/ata/ahci.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,6 @@ static struct scsi_host_template ahci_sht = {
.slave_configure = ata_scsi_slave_config,
.slave_destroy = ata_scsi_slave_destroy,
.bios_param = ata_std_bios_param,
#ifdef CONFIG_PM
.suspend = ata_scsi_device_suspend,
.resume = ata_scsi_device_resume,
#endif
};

static const struct ata_port_operations ahci_ops = {
Expand Down
6 changes: 1 addition & 5 deletions drivers/ata/ata_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static int generic_set_mode(struct ata_port *ap, struct ata_device **unused)

for (i = 0; i < ATA_MAX_DEVICES; i++) {
struct ata_device *dev = &ap->device[i];
if (ata_dev_ready(dev)) {
if (ata_dev_enabled(dev)) {
/* We don't really care */
dev->pio_mode = XFER_PIO_0;
dev->dma_mode = XFER_MW_DMA_0;
Expand Down Expand Up @@ -90,10 +90,6 @@ static struct scsi_host_template generic_sht = {
.slave_configure = ata_scsi_slave_config,
.slave_destroy = ata_scsi_slave_destroy,
.bios_param = ata_std_bios_param,
#ifdef CONFIG_PM
.resume = ata_scsi_device_resume,
.suspend = ata_scsi_device_suspend,
#endif
};

static struct ata_port_operations generic_port_ops = {
Expand Down
4 changes: 0 additions & 4 deletions drivers/ata/ata_piix.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,6 @@ static struct scsi_host_template piix_sht = {
.slave_configure = ata_scsi_slave_config,
.slave_destroy = ata_scsi_slave_destroy,
.bios_param = ata_std_bios_param,
#ifdef CONFIG_PM
.resume = ata_scsi_device_resume,
.suspend = ata_scsi_device_suspend,
#endif
};

static const struct ata_port_operations piix_pata_ops = {
Expand Down
39 changes: 4 additions & 35 deletions drivers/ata/libata-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2860,7 +2860,7 @@ int ata_do_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev)
dev = &ap->device[i];

/* don't update suspended devices' xfer mode */
if (!ata_dev_ready(dev))
if (!ata_dev_enabled(dev))
continue;

rc = ata_dev_set_mode(dev);
Expand Down Expand Up @@ -5845,37 +5845,11 @@ static int ata_host_request_pm(struct ata_host *host, pm_message_t mesg,
*/
int ata_host_suspend(struct ata_host *host, pm_message_t mesg)
{
int i, j, rc;
int rc;

rc = ata_host_request_pm(host, mesg, 0, ATA_EHI_QUIET, 1);
if (rc)
goto fail;

/* EH is quiescent now. Fail if we have any ready device.
* This happens if hotplug occurs between completion of device
* suspension and here.
*/
for (i = 0; i < host->n_ports; i++) {
struct ata_port *ap = host->ports[i];

for (j = 0; j < ATA_MAX_DEVICES; j++) {
struct ata_device *dev = &ap->device[j];

if (ata_dev_ready(dev)) {
ata_port_printk(ap, KERN_WARNING,
"suspend failed, device %d "
"still active\n", dev->devno);
rc = -EBUSY;
goto fail;
}
}
}

host->dev->power.power_state = mesg;
return 0;

fail:
ata_host_resume(host);
if (rc == 0)
host->dev->power.power_state = mesg;
return rc;
}

Expand Down Expand Up @@ -6889,11 +6863,6 @@ EXPORT_SYMBOL_GPL(ata_pci_default_filter);
EXPORT_SYMBOL_GPL(ata_pci_clear_simplex);
#endif /* CONFIG_PCI */

#ifdef CONFIG_PM
EXPORT_SYMBOL_GPL(ata_scsi_device_suspend);
EXPORT_SYMBOL_GPL(ata_scsi_device_resume);
#endif /* CONFIG_PM */

EXPORT_SYMBOL_GPL(ata_eng_timeout);
EXPORT_SYMBOL_GPL(ata_port_schedule_eh);
EXPORT_SYMBOL_GPL(ata_port_abort);
Expand Down
Loading

0 comments on commit 9666f40

Please sign in to comment.