libata: reimplement suspend/resume support using sdev->manage_start_stop
PATCH 1/2 libata: reimplement suspend/resume support using sdev->manage_start_stop
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.
---
This and the following patch should fix all the spindown problems both on shutdown and STD. These patches are against v2.6.21-rc7 + updates from scsi-misc-2.6. The git tree is available at the following URL.
http://htj.dyndns.org/git/?p=libata-tj.git;a=shortlog;h=spindown
git://htj.dyndns.org/libata-tj spindown
I'll post combined patch against 2.6.21-rc7 as a reply to this thread. Please test the combined patch and verify it works.
Thanks.
drivers/ata/ahci.c | 4 - drivers/ata/ata_generic.c | 6 +- drivers/ata/ata_piix.c | 4 - drivers/ata/libata-core.c | 39 +------ drivers/ata/libata-eh.c | 237 +-------------------------------------- drivers/ata/libata-scsi.c | 129 +--------------------- drivers/ata/pata_ali.c | 4 - drivers/ata/pata_amd.c | 4 - drivers/ata/pata_atiixp.c | 4 - drivers/ata/pata_cmd640.c | 2 - drivers/ata/pata_cmd64x.c | 4 - drivers/ata/pata_cs5520.c | 4 - drivers/ata/pata_cs5530.c | 4 - drivers/ata/pata_cs5535.c | 4 - drivers/ata/pata_cypress.c | 4 - drivers/ata/pata_efar.c | 4 - drivers/ata/pata_hpt366.c | 4 - drivers/ata/pata_hpt3x3.c | 4 - drivers/ata/pata_it8213.c | 4 - drivers/ata/pata_it821x.c | 4 - drivers/ata/pata_ixp4xx_cf.c | 2 +- drivers/ata/pata_jmicron.c | 4 - drivers/ata/pata_marvell.c | 4 - drivers/ata/pata_mpc52xx.c | 4 - drivers/ata/pata_mpiix.c | 4 - drivers/ata/pata_netcell.c | 4 - drivers/ata/pata_ns87410.c | 4 - drivers/ata/pata_oldpiix.c | 4 - drivers/ata/pata_opti.c | 4 - drivers/ata/pata_optidma.c | 4 - drivers/ata/pata_pdc202xx_old.c | 4 - drivers/ata/pata_radisys.c | 4 - drivers/ata/pata_rz1000.c | 6 +- drivers/ata/pata_sc1200.c | 4 - drivers/ata/pata_scc.c | 4 - drivers/ata/pata_serverworks.c | 4 - drivers/ata/pata_sil680.c | 4 - drivers/ata/pata_sis.c | 4 - drivers/ata/pata_triflex.c | 4 - drivers/ata/pata_via.c | 4 - drivers/ata/sata_inic162x.c | 4 - drivers/ata/sata_nv.c | 8 -- drivers/ata/sata_sil.c | 4 - drivers/ata/sata_sil24.c | 4 - include/linux/libata.h | 14 +-- 45 files changed, 14 insertions(+), 573 deletions(-)
drivers/ata/ahci.c +0 -4
@@ -246,10 +246,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 = {
drivers/ata/ata_generic.c +1 -5
@@ -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 ;
@@ -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 = {
drivers/ata/ata_piix.c +0 -4
@@ -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 = {
drivers/ata/libata-core.c +4 -35
@@ -2823,7 +2823,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);
@@ -5758,37 +5758,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; }
@@ -6801,11 +6775,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);
drivers/ata/libata-eh.c +4 -233
307 lines not on this page · raw message
drivers/ata/libata-scsi.c +2 -127
141 lines not on this page · raw message
drivers/ata/pata_ali.c +0 -4
@@ -291,10 +291,6 @@ static struct scsi_host_template ali_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 };/*
drivers/ata/pata_amd.c +0 -4
@@ -323,10 +323,6 @@ static struct scsi_host_template amd_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 amd33_port_ops = {
drivers/ata/pata_atiixp.c +0 -4
@@ -229,10 +229,6 @@ static struct scsi_host_template atiixp_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 atiixp_port_ops = {
drivers/ata/pata_cmd640.c +0 -2
@@ -181,8 +181,6 @@ static struct scsi_host_template cmd640_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, - .resume = ata_scsi_device_resume, - .suspend = ata_scsi_device_suspend, };static struct ata_port_operations cmd640_port_ops = {
drivers/ata/pata_cmd64x.c +0 -4
@@ -266,10 +266,6 @@ static struct scsi_host_template cmd64x_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 cmd64x_port_ops = {
drivers/ata/pata_cs5520.c +0 -4
@@ -155,10 +155,6 @@ static struct scsi_host_template cs5520_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 cs5520_port_ops = {
drivers/ata/pata_cs5530.c +0 -4
@@ -176,10 +176,6 @@ static struct scsi_host_template cs5530_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 cs5530_port_ops = {
drivers/ata/pata_cs5535.c +0 -4
@@ -172,10 +172,6 @@ static struct scsi_host_template cs5535_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 cs5535_port_ops = {
drivers/ata/pata_cypress.c +0 -4
@@ -125,10 +125,6 @@ static struct scsi_host_template cy82c693_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 cy82c693_port_ops = {
drivers/ata/pata_efar.c +0 -4
@@ -246,10 +246,6 @@ static struct scsi_host_template efar_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 efar_ops = {
drivers/ata/pata_hpt366.c +0 -4
@@ -331,10 +331,6 @@ static struct scsi_host_template hpt36x_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 };/*
drivers/ata/pata_hpt3x3.c +0 -4
@@ -100,10 +100,6 @@ static struct scsi_host_template hpt3x3_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 hpt3x3_port_ops = {
drivers/ata/pata_it8213.c +0 -4
@@ -255,10 +255,6 @@ static struct scsi_host_template it8213_sht = { .dma_boundary = ATA_DMA_BOUNDARY, .slave_configure = ata_scsi_slave_config, .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 it8213_ops = {
drivers/ata/pata_it821x.c +0 -4
@@ -620,10 +620,6 @@ static struct scsi_host_template it821x_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 it821x_smart_port_ops = {
drivers/ata/pata_ixp4xx_cf.c +1 -1
@@ -31,7 +31,7 @@ static int ixp4xx_set_mode(struct ata_port *ap, struct ata_device **error)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)) {ata_dev_printk (dev,KERN_INFO ,"configured for PIO0\n" ); dev->pio_mode =XFER_PIO_0 ; dev->xfer_mode =XFER_PIO_0 ;
drivers/ata/pata_jmicron.c +0 -4
@@ -137,10 +137,6 @@ static struct scsi_host_template jmicron_sht = { .slave_destroy = ata_scsi_slave_destroy, /* Use standard CHS mapping rules */ .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 jmicron_ops = {
drivers/ata/pata_marvell.c +0 -4
@@ -104,10 +104,6 @@ static struct scsi_host_template marvell_sht = { .slave_destroy = ata_scsi_slave_destroy, /* Use standard CHS mapping rules */ .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 marvell_ops = {
drivers/ata/pata_mpc52xx.c +0 -4
@@ -280,10 +280,6 @@ static struct scsi_host_template mpc52xx_ata_sht = { .dma_boundary = ATA_DMA_BOUNDARY, .slave_configure = ata_scsi_slave_config, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .suspend = ata_scsi_device_suspend, - .resume = ata_scsi_device_resume, -#endif };static struct ata_port_operations mpc52xx_ata_port_ops = {
drivers/ata/pata_mpiix.c +0 -4
@@ -164,10 +164,6 @@ static struct scsi_host_template mpiix_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 mpiix_port_ops = {
drivers/ata/pata_netcell.c +0 -4
@@ -37,10 +37,6 @@ static struct scsi_host_template netcell_sht = { .slave_destroy = ata_scsi_slave_destroy, /* Use standard CHS mapping rules */ .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 netcell_ops = {
drivers/ata/pata_ns87410.c +0 -4
@@ -156,10 +156,6 @@ static struct scsi_host_template ns87410_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 ns87410_port_ops = {
drivers/ata/pata_oldpiix.c +0 -4
@@ -232,10 +232,6 @@ static struct scsi_host_template oldpiix_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 oldpiix_pata_ops = {
drivers/ata/pata_opti.c +0 -4
@@ -177,10 +177,6 @@ static struct scsi_host_template opti_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 opti_port_ops = {
drivers/ata/pata_optidma.c +0 -4
@@ -362,10 +362,6 @@ static struct scsi_host_template optidma_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 optidma_port_ops = {
drivers/ata/pata_pdc202xx_old.c +0 -4
@@ -244,10 +244,6 @@ static struct scsi_host_template pdc202xx_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 pdc2024x_port_ops = {
drivers/ata/pata_radisys.c +0 -4
@@ -200,10 +200,6 @@ static struct scsi_host_template radisys_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 radisys_pata_ops = {
drivers/ata/pata_rz1000.c +1 -5
@@ -40,7 +40,7 @@ static int rz1000_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->xfer_mode =XFER_PIO_0 ;
@@ -69,10 +69,6 @@ static struct scsi_host_template rz1000_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 rz1000_port_ops = {
drivers/ata/pata_sc1200.c +0 -4
@@ -194,10 +194,6 @@ static struct scsi_host_template sc1200_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 sc1200_port_ops = {
drivers/ata/pata_scc.c +0 -4
@@ -984,10 +984,6 @@ static struct scsi_host_template scc_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 scc_pata_ops = {
drivers/ata/pata_serverworks.c +0 -4
@@ -313,10 +313,6 @@ static struct scsi_host_template serverworks_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 serverworks_osb4_port_ops = {
drivers/ata/pata_sil680.c +0 -4
@@ -230,10 +230,6 @@ static struct scsi_host_template sil680_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 struct ata_port_operations sil680_port_ops = {
drivers/ata/pata_sis.c +0 -4
@@ -520,10 +520,6 @@ static struct scsi_host_template sis_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 sis_133_ops = {
drivers/ata/pata_triflex.c +0 -4
@@ -192,10 +192,6 @@ static struct scsi_host_template triflex_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 triflex_port_ops = {
drivers/ata/pata_via.c +0 -4
@@ -300,10 +300,6 @@ static struct scsi_host_template via_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 via_port_ops = {
drivers/ata/sata_inic162x.c +0 -4
@@ -135,10 +135,6 @@ static struct scsi_host_template inic_sht = { .slave_configure = inic_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 int scr_map[] = {
drivers/ata/sata_nv.c +0 -8
@@ -323,10 +323,6 @@ static struct scsi_host_template nv_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 struct scsi_host_template nv_adma_sht = {
@@ -345,10 +341,6 @@ static struct scsi_host_template nv_adma_sht = { .slave_configure = nv_adma_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 nv_generic_ops = {
drivers/ata/sata_sil.c +0 -4
@@ -182,10 +182,6 @@ static struct scsi_host_template sil_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 sil_ops = {
drivers/ata/sata_sil24.c +0 -4
@@ -380,10 +380,6 @@ static struct scsi_host_template sil24_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 sil24_ops = {
include/linux/libata.h +1 -13
@@ -140,7 +140,6 @@ enum {ATA_DFLAG_PIO = (1 <<8 ),/* device limited to PIO mode */ ATA_DFLAG_NCQ_OFF = (1 <<9 ),/* device limited to non-NCQ mode */ -ATA_DFLAG_SUSPENDED = (1 <<10 ),/* device suspended */ ATA_DFLAG_INIT_MASK = (1 <<16 ) -1 , ATA_DFLAG_DETACH = (1 << 16),
@@ -268,13 +267,9 @@ enum {ATA_EH_REVALIDATE = (1 <<0 ),ATA_EH_SOFTRESET = (1 <<1 ),ATA_EH_HARDRESET = (1 <<2 ), -ATA_EH_SUSPEND = (1 <<3 ), -ATA_EH_RESUME = (1 <<4 ), -ATA_EH_PM_FREEZE = (1 <<5 ),ATA_EH_RESET_MASK =ATA_EH_SOFTRESET |ATA_EH_HARDRESET , -ATA_EH_PERDEV_MASK =ATA_EH_REVALIDATE |ATA_EH_SUSPEND | -ATA_EH_RESUME |ATA_EH_PM_FREEZE , +ATA_EH_PERDEV_MASK =ATA_EH_REVALIDATE ,/* ata_eh_info->flags */ ATA_EHI_HOTPLUGGED = (1 << 0), /* could have been hotplugged */
@@ -740,8 +735,6 @@ extern int sata_scr_write_flush(struct ata_port *ap, int reg, u32 val);extern int ata_port_online (struct ata_port *ap);extern int ata_port_offline (struct ata_port *ap);#ifdef CONFIG_PM -extern int ata_scsi_device_resume (struct scsi_device *); -extern int ata_scsi_device_suspend (struct scsi_device *,pm_message_t mesg);extern int ata_host_suspend (struct ata_host *host,pm_message_t mesg);extern void ata_host_resume (struct ata_host *host);#endif
@@ -1016,11 +1009,6 @@ static inline unsigned int ata_dev_absent(const struct ata_device *dev)return ata_class_absent (dev->class); } -static inline unsigned int ata_dev_ready (const struct ata_device *dev) -{ -return ata_dev_enabled (dev) && !(dev->flags &ATA_DFLAG_SUSPENDED ); -} -/* * port helpers */
Signature · 1 line
1.5.0.3
PATCH 1/1 libata: skip FLUSH and STADNBYNOW1 during shutdown if device is already spun down
libata didn't use to spin down disks properly on shutdown and userland shutdown(8) worked around it by synchronizing cache and spinning down by itself before telling the kernel to shutdown. However, this userland work around collides with libata shutdown because some drives spin up if it receives FLUSH or STANDBYNOW1 while spun down. This results in unpleasant spin down-up-down sequence.
This patch makes libata skip FLUSH and STANDBYNOW1 during shutdown if the drive is already spun down. Note that whether FLUSH has been performed is not checked. This is because some userland shutdown(8)'s only do STANDBYNOW1. Transition to standby mode implies cache flush, so this should be safe.
libata prints informational messages when skipping commands. This is for debugging and to urge distributions to update shutdown(8) such that it doesn't do superflous flush and spindown.
--- drivers/ata/libata-scsi.c | 29 +++++++++++++++++++++++++++++ include/linux/libata.h | 1 + 2 files changed, 30 insertions(+), 0 deletions(-)
drivers/ata/libata-scsi.c +29 -0
@@ -1309,6 +1309,7 @@ nothing_to_do:static void ata_scsi_qc_complete (struct ata_queued_cmd *qc) {struct ata_port *ap = qc->ap; +struct ata_device *adev = qc->dev;struct scsi_cmnd *cmd = qc->scsicmd;u8 *cdb = cmd->cmnd;int need_sense = (qc->err_mask !=0 );
@@ -1349,6 +1350,13 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc) } } +/* Set spundown status. Some userland tools use STANDBY +* instead of STANDBYNOW1. Take both into account. +*/ +if (unlikely (qc->tf.command ==ATA_CMD_STANDBY || + qc->tf.command ==ATA_CMD_STANDBYNOW1 )) + adev->flags |=ATA_DFLAG_SPUNDOWN ; +if (need_sense && !ap->ops->error_handler)ata_dump_status (ap->print_id, &qc->result_tf);
@@ -1454,6 +1462,27 @@ static int ata_scsi_translate(struct ata_device *dev, struct scsi_cmnd *cmd,if (xlat_func (qc)) goto early_finish; +/* Some userland shutdown(8) spins down device to work around +* previous kernel bugs. Issuing cache flush or spin down +* again might spin up some drives. Skip cache flush and +* spindown for ->shutdown if it's already spun down. +*/ +switch (qc->tf.command) { +case ATA_CMD_FLUSH : +case ATA_CMD_FLUSH_EXT : +case ATA_CMD_STANDBYNOW1 :/* ->shutdown always uses STANDBYNOW1 */ +if (unlikely ((system_state >SYSTEM_RUNNING ) && + (dev->flags &ATA_DFLAG_SPUNDOWN ))) { +ata_dev_printk (dev,KERN_INFO ,"already spun down, " +"skipping cmd 0x%x\n" , qc->tf.command); + cmd->result =SAM_STAT_GOOD ; + goto early_finish; + } +break ; +default : + dev->flags &= ~ATA_DFLAG_SPUNDOWN ; + } +/* select device, send command to hardware */ ata_qc_issue (qc);
include/linux/libata.h +1 -0
@@ -136,6 +136,7 @@ enum {ATA_DFLAG_CDB_INTR = (1 <<2 ),/* device asserts INTRQ when ready for CDB */ ATA_DFLAG_NCQ = (1 <<3 ),/* device supports NCQ */ ATA_DFLAG_FLUSH_EXT = (1 <<4 ),/* do FLUSH_EXT instead of FLUSH */ +ATA_DFLAG_SPUNDOWN = (1 <<5 ),/* device is spun down by user */ ATA_DFLAG_CFG_MASK = (1 <<8 ) -1 , ATA_DFLAG_PIO = (1 << 8), /* device limited to PIO mode */
Signature · 1 line
1.5.0.3
Re: [PATCH] libata: skip FLUSH and STADNBYNOW1 during shutdown if device is already spun down
Quoted 7 lines · Tejun Heo
libata didn't use to spin down disks properly on shutdown and userland shutdown(8) worked around it by synchronizing cache and spinning down by itself before telling the kernel to shutdown. However, this userland work around collides with libata shutdown because some drives spin up if it receives FLUSH or STANDBYNOW1 while spun down. This results in unpleasant spin down-up-down sequence.
Quoted 5 lines
This patch makes libata skip FLUSH and STANDBYNOW1 during shutdown if the drive is already spun down. Note that whether FLUSH has been performed is not checked. This is because some userland shutdown(8)'s only do STANDBYNOW1. Transition to standby mode implies cache flush, so this should be safe.
Are we sure this is true in all cases? The ATA spec doesn't explicitly say that STANDBY IMMEDIATE implies a cache flush. Granted it would be retarded for a drive to spin itself down with data still pending in the write cache, but firmware people have done some strange things..
Quoted 24 lines
libata prints informational messages when skipping commands. This is for debugging and to urge distributions to update shutdown(8) such that it doesn't do superflous flush and spindown.
Signed-off-by Tejun Heo <[email protected]>--- drivers/ata/libata-scsi.c | 29 +++++++++++++++++++++++++++++ include/linux/libata.h | 1 + 2 files changed, 30 insertions(+), 0 deletions(-)drivers/ata/libata-scsi.c +1
-0@@ -1309,6 +1309,7 @@ nothing_to_do:static void ata_scsi_qc_complete (struct ata_queued_cmd *qc) {struct ata_port *ap = qc->ap; +struct ata_device *adev = qc->dev;struct scsi_cmnd *cmd = qc->scsicmd;u8 *cdb = cmd->cmnd;int need_sense = (qc->err_mask !=0 );
drivers/ata/libata-scsi.c static void ata_scsi_qc_complete(struct ata_queued_cmd *qc) · line 1358
Quoted 9 lines
drivers/ata/libata-scsi.c +6
-0@@ -1349,6 +1350,13 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc) } } +/* Set spundown status. Some userland tools use STANDBY +* instead of STANDBYNOW1. Take both into account. +*/ +if (unlikely (qc->tf.command ==ATA_CMD_STANDBY || + qc->tf.command ==ATA_CMD_STANDBYNOW1 )) + adev->flags |=ATA_DFLAG_SPUNDOWN ;
Is checking for STANDBY really valid here? STANDBY does not do an immediate entry to standby mode, it only sets the standby timer. Therefore just because userspace issued a standby command, does not mean the drive is really spun down currently.
Could we use CHECK POWER MODE to see if the drive is currently spun down rather than tracking whether a standby was already issued? That would handle the case above as well, we could tell if the drive had actually spun down on a timer or not.
Quoted 44 lines
drivers/ata/libata-scsi.c +22
-0+if (need_sense && !ap->ops->error_handler)ata_dump_status (ap->print_id, &qc->result_tf);@@ -1454,6 +1462,27 @@ static int ata_scsi_translate(struct ata_device *dev, struct scsi_cmnd *cmd,if (xlat_func (qc)) goto early_finish; +/* Some userland shutdown(8) spins down device to work around +* previous kernel bugs. Issuing cache flush or spin down +* again might spin up some drives. Skip cache flush and +* spindown for ->shutdown if it's already spun down. +*/ +switch (qc->tf.command) { +case ATA_CMD_FLUSH : +case ATA_CMD_FLUSH_EXT : +case ATA_CMD_STANDBYNOW1 :/* ->shutdown always uses STANDBYNOW1 */ +if (unlikely ((system_state >SYSTEM_RUNNING ) && + (dev->flags &ATA_DFLAG_SPUNDOWN ))) { +ata_dev_printk (dev,KERN_INFO ,"already spun down, " +"skipping cmd 0x%x\n" , qc->tf.command); + cmd->result =SAM_STAT_GOOD ; + goto early_finish; + } +break ; +default : + dev->flags &= ~ATA_DFLAG_SPUNDOWN ; + } +/* select device, send command to hardware */ ata_qc_issue (qc);include/linux/libata.h +1
-0@@ -136,6 +136,7 @@ enum {ATA_DFLAG_CDB_INTR = (1 <<2 ),/* device asserts INTRQ when ready for CDB */ ATA_DFLAG_NCQ = (1 <<3 ),/* device supports NCQ */ ATA_DFLAG_FLUSH_EXT = (1 <<4 ),/* do FLUSH_EXT instead of FLUSH */ +ATA_DFLAG_SPUNDOWN = (1 <<5 ),/* device is spun down by user */ ATA_DFLAG_CFG_MASK = (1 <<8 ) -1 , ATA_DFLAG_PIO = (1 << 8), /* device limited to PIO mode */
Re: [PATCH] libata: skip FLUSH and STADNBYNOW1 during shutdown if device is already spun down
Quoted 10 lines · Robert Hancock
Quoted 5 lines
This patch makes libata skip FLUSH and STANDBYNOW1 during shutdown if the drive is already spun down. Note that whether FLUSH has been performed is not checked. This is because some userland shutdown(8)'s only do STANDBYNOW1. Transition to standby mode implies cache flush, so this should be safe.
Are we sure this is true in all cases? The ATA spec doesn't explicitly say that STANDBY IMMEDIATE implies a cache flush. Granted it would be retarded for a drive to spin itself down with data still pending in the write cache, but firmware people have done some strange things..
I was somehow thinking the ATA spec requires cache flush on entering STANDBY. Can't find anything about it now, which means shutdown(8) on my debian is broken. :-(
Quoted 11 lines
drivers/ata/libata-scsi.c static void ata_scsi_qc_complete(struct ata_queued_cmd *qc) · line 1358
Quoted 6 lines
drivers/ata/libata-scsi.c +6
-0+/* Set spundown status. Some userland tools use STANDBY +* instead of STANDBYNOW1. Take both into account. +*/ +if (unlikely (qc->tf.command ==ATA_CMD_STANDBY || + qc->tf.command ==ATA_CMD_STANDBYNOW1 )) + adev->flags |=ATA_DFLAG_SPUNDOWN ;Is checking for STANDBY really valid here? STANDBY does not do an immediate entry to standby mode, it only sets the standby timer. Therefore just because userspace issued a standby command, does not mean the drive is really spun down currently.
Heh heh, got you. STANDBY does put the device into STANDBY mode immediately. It's STANDBY_IMMEDIATE + timer adjustment.
Quoted 4 lines
Could we use CHECK POWER MODE to see if the drive is currently spun down rather than tracking whether a standby was already issued? That would handle the case above as well, we could tell if the drive had actually spun down on a timer or not.
Thought about that but that would require passing shutdown STANDBY_IMMEDIATE to EH and do multi command sequence there. It can be done but I think it's too complex.
Gee... We're in trouble. It's just too dangerous to skip FLUSH if STANDBY doesn't imply FLUSH and some dists don't do FLUSH in front of STANDBY. I think the best way would be implementing the original compat kernel parameter and printing big fat warning message to tell the user that their shutdown(8) needs to be updated. Any better ideas?
Signature · 1 line
tejun