ALPM: enable link power management for ata drivers
Subsystems (2)
PATCH 10/25 ALPM: enable link power management for ata drivers
From: Kristen Carlson Accardi <[email protected]>
libata drivers can define a function (enable_pm) that will perform hardware specific actions to enable whatever power management policy the user set up from the scsi sysfs interface if the driver supports it. This power management policy will be activated after all disks have been enumerated and intialized. Drivers should also define disable_pm, which will turn off link power management, but not change link power management policy.
Signed-off-by Kristen Carlson Accardi <[email protected]>
Cc Jeff Garzik <[email protected]>
Cc Tejun Heo <[email protected]>
Cc Alan Cox <[email protected]>
Signed-off-by Andrew Morton <[email protected]>
---
Documentation/scsi/link_power_management_policy.txt | 19 + drivers/ata/libata-core.c | 41 +++ drivers/ata/libata-eh.c | 3 drivers/ata/libata-scsi.c | 118 ++++++++++ include/linux/ata.h | 6 include/linux/libata.h | 21 + 6 files changed, 206 insertions(+), 2 deletions(-)
Documentation/scsi/link_power_management_policy.txt new file +19 -0
@@ -0,0 +1,19 @@ +This parameter allows the user to set the link (interface) power management. +There are 3 possible options: + +Value Effect +---------------------------------------------------------------------------- +min_power Tell the controller to try to make the link use the + least possible power when possible. This may + sacrifice some performance due to increased latency + when coming out of lower power states. + +max_performance Generally, this means no power management. Tell + the controller to have performance be a priority + over power management. + +medium_power Tell the controller to enter a lower power state + when possible, but do not enter the lowest power + state, thus improving latency over min_power setting. + +
drivers/ata/libata-core.c renamed from drivers/ata/libata-core.c~alpm-enable-link-power-management-for-ata-drivers +41 -0
77 lines not on this page · raw message
drivers/ata/libata-eh.c renamed from drivers/ata/libata-eh.c~alpm-enable-link-power-management-for-ata-drivers +3 -0
@@ -2221,6 +2221,9 @@ static int ata_eh_recover(struct ata_por ehc->i.flags &= ~ATA_EHI_SETMODE ; } +if (ehc->i.action &ATA_EHI_LPM ) + ap->ops->enable_pm (ap, ap->pm_policy); + goto out; dev_fail:
drivers/ata/libata-scsi.c renamed from drivers/ata/libata-scsi.c~alpm-enable-link-power-management-for-ata-drivers +118 -0
130 lines not on this page · raw message
include/linux/ata.h renamed from include/linux/ata.h~alpm-enable-link-power-management-for-ata-drivers +6 -0
@@ -355,6 +355,12 @@ struct ata_taskfile { ((u64) (id)[(n) + 0]) )#define ata_id_cdb_intr (id) (((id)[0] & 0x60) == 0x20) +#define ata_id_has_hipm (id) \ + ( (((id)[76] != 0x0000) && ((id)[76] != 0xffff)) && \ + ((id)[76] & (1 << 9)) ) +#define ata_id_has_dipm (id) \ + ( (((id)[76] != 0x0000) && ((id)[76] != 0xffff)) && \ + ((id)[78] & (1 << 3)) )static inline unsigned int ata_id_major_version (const u16 *id) {
include/linux/libata.h renamed from include/linux/libata.h~alpm-enable-link-power-management-for-ata-drivers +19 -2
@@ -139,6 +139,7 @@ enum {ATA_DFLAG_FLUSH_EXT = (1 <<4 ),/* do FLUSH_EXT instead of FLUSH */ ATA_DFLAG_ACPI_PENDING = (1 <<5 ),/* ACPI resume action pending */ ATA_DFLAG_ACPI_FAILED = (1 <<6 ),/* ACPI on devcfg has failed */ +ATA_DFLAG_IPM = (1 <<8 ),/* device supports IPM */ ATA_DFLAG_CFG_MASK = (1 <<12 ) -1 , ATA_DFLAG_PIO = (1 << 8), /* device limited to PIO mode */
@@ -286,6 +287,7 @@ enum {ATA_EHI_RESUME_LINK = (1 <<1 ),/* resume link (reset modifier) */ ATA_EHI_NO_AUTOPSY = (1 <<2 ),/* no autopsy */ ATA_EHI_QUIET = (1 <<3 ),/* be quiet */ +ATA_EHI_LPM = (1 <<4 ),/* link power management action */ ATA_EHI_DID_SOFTRESET = (1 <<16 ),/* already soft-reset this port */ ATA_EHI_DID_HARDRESET = (1 << 17), /* already soft-reset this port */
@@ -310,6 +312,7 @@ enum {ATA_HORKAGE_NODMA = (1 <<1 ),/* DMA problems */ ATA_HORKAGE_NONCQ = (1 <<2 ),/* Don't use NCQ */ ATA_HORKAGE_MAX_SEC_128 = (1 <<3 ),/* Limit max sects to 128 */ + ATA_HORKAGE_IPM = (1 << 4), /* LPM problems */ }; enum hsm_task_states {
@@ -348,6 +351,18 @@ typedef int (*ata_reset_fn_t)(struct ata unsigned long deadline);typedef void (*ata_postreset_fn_t )(struct ata_port *ap,unsigned int *classes); +/* +* host pm policy: If you alter this, you also need to alter scsi_sysfs.c +* (for the ascii descriptions) +*/ +enum link_pm { +NOT_AVAILABLE , +MIN_POWER , +MAX_PERFORMANCE , +MEDIUM_POWER , +}; +extern struct class_device_attribute class_device_attr_link_power_management_policy; +struct ata_ioports {void __iomem *cmd_addr;void __iomem *data_addr;
@@ -574,6 +589,7 @@ struct ata_port {pm_message_t pm_mesg;int *pm_result; +enum link_pm pm_policy;struct timer_list fastdrain_timer;unsigned long fastdrain_cnt;
@@ -639,7 +655,8 @@ struct ata_port_operations {int (*port_suspend) (struct ata_port *ap,pm_message_t mesg);int (*port_resume) (struct ata_port *ap); - +int (*enable_pm) (struct ata_port *ap,enum link_pm policy); +int (*disable_pm) (struct ata_port *ap);int (*port_start) (struct ata_port *ap);void (*port_stop) (struct ata_port *ap);
@@ -847,7 +864,7 @@ extern int ata_cable_40wire(struct ata_pextern int ata_cable_80wire (struct ata_port *ap);extern int ata_cable_sata (struct ata_port *ap);extern int ata_cable_unknown (struct ata_port *ap); - +extern int ata_scsi_set_link_pm_policy (struct ata_port *ap,enum link_pm );/* * Timing helpers */
_