From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Rafael J. Wysocki" Subject: [PATCH 3/6] SATA: Blacklisting of systems that spin off disks during ACPI power off Date: Tue, 30 Sep 2008 00:14:28 +0200 Message-ID: <200809300014.28983.rjw@sisk.pl> References: <200808290002.55026.rjw@sisk.pl> <48D17BBE.5020807@garzik.org> <200809300006.24919.rjw@sisk.pl> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <200809300006.24919.rjw@sisk.pl> Content-Disposition: inline Sender: linux-ide-owner@vger.kernel.org To: Jeff Garzik Cc: Tejun Heo , ACPI Devel Maling List , linux-ide@vger.kernel.org, Thomas Renninger , Robert Hancock , LKML , Frans Pop , Maciej Rutecki , Andrew Morton List-Id: linux-acpi@vger.kernel.org From: Rafael J. Wysocki SATA: Blacklisting of systems that spin off disks during ACPI power off Introduce new libata flags ATA_FLAG_NO_POWEROFF_SPINDOWN and ATA_FLAG_NO_HIBERNATE_SPINDOWN that, if set, will prevent disks from being spun off during system power off and hibernation, respectively (to handle the hibernation case we need the new system state SYSTEM_HIBERNATE_ENTER that can be checked against by libata, in analogy with SYSTEM_POWER_OFF). Signed-off-by: Rafael J. Wysocki --- drivers/ata/libata-scsi.c | 19 ++++++++++++++++--- include/linux/libata.h | 2 ++ 2 files changed, 18 insertions(+), 3 deletions(-) Index: linux-2.6/drivers/ata/libata-scsi.c =================================================================== --- linux-2.6.orig/drivers/ata/libata-scsi.c +++ linux-2.6/drivers/ata/libata-scsi.c @@ -1181,6 +1181,17 @@ static unsigned int ata_scsi_start_stop_ tf->command = ATA_CMD_VERIFY; /* READ VERIFY */ } else { + /* Some odd clown BIOSen issue spindown on power off (ACPI S4 + * or S5) causing some drives to spin up and down again. + */ + if ((qc->ap->flags & ATA_FLAG_NO_POWEROFF_SPINDOWN) && + system_state == SYSTEM_POWER_OFF) + goto skip; + + if ((qc->ap->flags & ATA_FLAG_NO_HIBERNATE_SPINDOWN) && + system_state == SYSTEM_HIBERNATE_ENTER) + goto skip; + /* XXX: This is for backward compatibility, will be * removed. Read Documentation/feature-removal-schedule.txt * for more info. @@ -1204,8 +1215,7 @@ static unsigned int ata_scsi_start_stop_ scmd->scsi_done = qc->scsidone; qc->scsidone = ata_delayed_done; } - scmd->result = SAM_STAT_GOOD; - return 1; + goto skip; } /* Issue ATA STANDBY IMMEDIATE command */ @@ -1221,10 +1231,13 @@ static unsigned int ata_scsi_start_stop_ return 0; -invalid_fld: + invalid_fld: ata_scsi_set_sense(scmd, ILLEGAL_REQUEST, 0x24, 0x0); /* "Invalid field in cbd" */ return 1; + skip: + scmd->result = SAM_STAT_GOOD; + return 1; } Index: linux-2.6/include/linux/libata.h =================================================================== --- linux-2.6.orig/include/linux/libata.h +++ linux-2.6/include/linux/libata.h @@ -186,6 +186,8 @@ enum { ATA_FLAG_PIO_POLLING = (1 << 9), /* use polling PIO if LLD * doesn't handle PIO interrupts */ ATA_FLAG_NCQ = (1 << 10), /* host supports NCQ */ + ATA_FLAG_NO_POWEROFF_SPINDOWN = (1 << 11), /* don't spindown before poweroff */ + ATA_FLAG_NO_HIBERNATE_SPINDOWN = (1 << 12), /* don't spindown before hibernation */ ATA_FLAG_DEBUGMSG = (1 << 13), ATA_FLAG_IGN_SIMPLEX = (1 << 15), /* ignore SIMPLEX */ ATA_FLAG_NO_IORDY = (1 << 16), /* controller lacks iordy */