Commit 8a745f1f39b7a20047a362b67ce9151c07d14440

Authored by Kristen Carlson Accardi
Committed by Jeff Garzik
1 parent 0afc6f5ba9

libata: Power off empty ports

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>

Showing 3 changed files with 10 additions and 3 deletions Side-by-side Diff

drivers/ata/libata-core.c
... ... @@ -3619,8 +3619,14 @@
3619 3619 scontrol |= (0x2 << 8);
3620 3620 break;
3621 3621 case ATA_LPM_MIN_POWER:
3622   - /* no restrictions on LPM transitions */
3623   - scontrol &= ~(0x3 << 8);
  3622 + if (ata_link_nr_enabled(link) > 0)
  3623 + /* no restrictions on LPM transitions */
  3624 + scontrol &= ~(0x3 << 8);
  3625 + else {
  3626 + /* empty port, power off */
  3627 + scontrol &= ~0xf;
  3628 + scontrol |= (0x1 << 2);
  3629 + }
3624 3630 break;
3625 3631 default:
3626 3632 WARN_ON(1);
drivers/ata/libata-eh.c
... ... @@ -3423,7 +3423,7 @@
3423 3423 return rc;
3424 3424 }
3425 3425  
3426   -static int ata_link_nr_enabled(struct ata_link *link)
  3426 +int ata_link_nr_enabled(struct ata_link *link)
3427 3427 {
3428 3428 struct ata_device *dev;
3429 3429 int cnt = 0;
include/linux/libata.h
... ... @@ -1151,6 +1151,7 @@
1151 1151 ata_reset_fn_t softreset, ata_reset_fn_t hardreset,
1152 1152 ata_postreset_fn_t postreset);
1153 1153 extern void ata_std_error_handler(struct ata_port *ap);
  1154 +extern int ata_link_nr_enabled(struct ata_link *link);
1154 1155  
1155 1156 /*
1156 1157 * Base operations to inherit from and initializers for sht