libata: Power off empty ports
authorKristen Carlson Accardi <kristen@linux.intel.com>
Fri, 4 Mar 2011 18:24:11 +0000 (10:24 -0800)
committerJeff Garzik <jgarzik@pobox.com>
Fri, 20 May 2011 00:50:53 +0000 (20:50 -0400)
Give users the option of completely powering off unoccupied
SATA ports using the existing min_power link_power_management_policy
option.  When the use selects this option on an empty port, we
will power the port off by setting DET to off.  For occupied ports,
behavior is unchanged.

Signed-off-by: Kristen Carlson Accardi <kristen@linux.intel.com>
Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
drivers/ata/libata-core.c
drivers/ata/libata-eh.c
include/linux/libata.h

index 76c3c15cb1e66680e11f9c5fb670d616e564acc5..736bee5dafebcffc3e13bcf9f8a4b48d13680903 100644 (file)
@@ -3619,8 +3619,14 @@ int sata_link_scr_lpm(struct ata_link *link, enum ata_lpm_policy policy,
                scontrol |= (0x2 << 8);
                break;
        case ATA_LPM_MIN_POWER:
-               /* no restrictions on LPM transitions */
-               scontrol &= ~(0x3 << 8);
+               if (ata_link_nr_enabled(link) > 0)
+                       /* no restrictions on LPM transitions */
+                       scontrol &= ~(0x3 << 8);
+               else {
+                       /* empty port, power off */
+                       scontrol &= ~0xf;
+                       scontrol |= (0x1 << 2);
+               }
                break;
        default:
                WARN_ON(1);
index dad9fd660f379907b6bb80856d8e047959d1917a..dfb6e9d3d759921419d8713fc7c48764ad943207 100644 (file)
@@ -3423,7 +3423,7 @@ fail:
        return rc;
 }
 
-static int ata_link_nr_enabled(struct ata_link *link)
+int ata_link_nr_enabled(struct ata_link *link)
 {
        struct ata_device *dev;
        int cnt = 0;
index 04f32a3eb26b85dd9ea0b0e786f282c0c799f30d..5a9926b340720f12340dce0a51b0ac329be93f14 100644 (file)
@@ -1151,6 +1151,7 @@ extern void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset,
                      ata_reset_fn_t softreset, ata_reset_fn_t hardreset,
                      ata_postreset_fn_t postreset);
 extern void ata_std_error_handler(struct ata_port *ap);
+extern int ata_link_nr_enabled(struct ata_link *link);
 
 /*
  * Base operations to inherit from and initializers for sht