]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/ata/libata-scsi.c
SATA: Blacklisting of systems that spin off disks during ACPI power off
[linux-2.6-omap-h63xx.git] / drivers / ata / libata-scsi.c
index a1a6e6298c33a4dc622a9c03aba181f70477a4e8..3c4c5ae277ba583074a2f407fe5cf25caf2b0320 100644 (file)
@@ -46,6 +46,7 @@
 #include <linux/libata.h>
 #include <linux/hdreg.h>
 #include <linux/uaccess.h>
+#include <linux/suspend.h>
 
 #include "libata.h"
 
@@ -1303,6 +1304,17 @@ static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc)
 
                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_entering_hibernation())
+                       goto skip;
+
                /* XXX: This is for backward compatibility, will be
                 * removed.  Read Documentation/feature-removal-schedule.txt
                 * for more info.
@@ -1326,8 +1338,7 @@ static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc)
                                scmd->scsi_done = qc->scsidone;
                                qc->scsidone = ata_delayed_done;
                        }
-                       scmd->result = SAM_STAT_GOOD;
-                       return 1;
+                       goto skip;
                }
 
                /* Issue ATA STANDBY IMMEDIATE command */
@@ -1343,10 +1354,13 @@ static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc)
 
        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;
 }