Re: [patch 1/2] Enable link power management for ata drivers

Previous thread: [patch 0/2] SATA Link Power Management patches by Kristen Carlson Accardi on Monday, September 24, 2007 - 6:12 pm. (1 message)

Next thread: [patch 2/2] Enable Aggressive Link Power management for AHCI controllers. by Kristen Carlson Accardi on Monday, September 24, 2007 - 6:14 pm. (2 messages)
To: <jgarzik@...>
Cc: <linux-ide@...>, <linux-kernel@...>, <axboe@...>, <akpm@...>, Kristen Carlson Accardi <kristen.c.accardi@...>
Date: Monday, September 24, 2007 - 6:13 pm

Device Initiated Power Management, which is defined
in SATA 2.5 can be enabled for disks which support it.
This patch enables DIPM when the user sets the link
power management policy to "min_power".

Additionally, libata drivers can define a function
(enable_pm) that will perform hardware specific actions to
enable whatever power management policy the user set up
for Host Initiated Power management (HIPM).
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 <kristen.c.accardi@intel.com>
---
Documentation/scsi/link_power_management_policy.txt | 19 +
drivers/ata/libata-core.c | 194 +++++++++++++++++++-
drivers/ata/libata-eh.c | 5
drivers/ata/libata-scsi.c | 83 ++++++++
include/linux/ata.h | 7
include/linux/libata.h | 25 ++
6 files changed, 322 insertions(+), 11 deletions(-)

Index: libata-dev/drivers/ata/libata-scsi.c
===================================================================
--- libata-dev.orig/drivers/ata/libata-scsi.c 2007-09-24 13:43:10.000000000 -0700
+++ libata-dev/drivers/ata/libata-scsi.c 2007-09-24 13:46:22.000000000 -0700
@@ -110,6 +110,78 @@ static struct scsi_transport_template at
};

+static const struct {
+ enum link_pm value;
+ char *name;
+} link_pm_policy[] = {
+ { NOT_AVAILABLE, "max_performance" },
+ { MIN_POWER, "min_power" },
+ { MAX_PERFORMANCE, "max_performance" },
+ { MEDIUM_POWER, "medium_power" },
+};
+
+const char *ata_scsi_link_pm_policy(enum link_pm policy)
+{
+ int i;
+ char *name = NULL;
+
+ for (i = 0; i < ARRAY_SIZE(link_pm_policy); i++) {
+ if (link_pm_policy[i].value == policy) {
+ name = link_pm_policy[i].name;
+ break;
+ ...

To: Kristen Carlson Accardi <kristen.c.accardi@...>
Cc: <linux-ide@...>, <linux-kernel@...>, <axboe@...>, <akpm@...>, Tejun Heo <htejun@...>
Date: Thursday, October 25, 2007 - 1:21 am

applied as the attached two patches to jgarzik/libata-dev.git#alpm

open issues:

1) need to check ata_dev_set_feature() return value in
ata_dev_set_dipm() and do something useful with it

2) as the name implies, this probably better belongs in ata_link.

3) however, the feature is tightly coupled to the host controller. in
theory PMP -might- do this, but I think its unlikely. as such I was OK
with the present arrangement.

4) there has been some discussion of software-initiated device/link
power management, but I think this should go in, in parallel with those
discussions. ALPM
* is quite self-contained
* gives a noticable power savings

I'm definitely interested in seeing somebody pursue software-initiated
link PM as well...

Jeff

To: Kristen Carlson Accardi <kristen.c.accardi@...>
Cc: <jgarzik@...>, <linux-ide@...>, <linux-kernel@...>, <axboe@...>, <akpm@...>
Date: Monday, September 24, 2007 - 7:12 pm

^
|
are you sure this
should be 76?

we can also change the first statement a bit:

and:

-

To: roel <12o3l@...>
Cc: <jgarzik@...>, <linux-ide@...>, <linux-kernel@...>, <axboe@...>, <akpm@...>
Date: Monday, September 24, 2007 - 7:41 pm

On Tue, 25 Sep 2007 01:12:32 +0200

I feel this is equivalent functionality and not as readable.
-

To: Kristen Carlson Accardi <kristen.c.accardi@...>
Cc: roel <12o3l@...>, <linux-ide@...>, <linux-kernel@...>, <akpm@...>, Alan <alan@...>
Date: Monday, September 24, 2007 - 7:59 pm

Poke around for Alan Cox's cleanup of this area of linux/ata.h.

It converts several macros to inline functions (encouraged), and also
illustrates a nice, clean way of testing an ID word's validity.
[obviously the final implementation varies, depending on that ID word's
history]

Alan or Andrew, got a copy somewhere? My feeble search skills don't
seem to turn it up at the moment, even though I had a copy in my hands
quite recently.

Jeff

-

To: Jeff Garzik <jgarzik@...>
Cc: Kristen Carlson Accardi <kristen.c.accardi@...>, roel <12o3l@...>, <linux-ide@...>, <linux-kernel@...>, <akpm@...>
Date: Tuesday, September 25, 2007 - 5:50 am

Its in -mm and I thought you put a copy in your tree after I said it
hadn't upset anything in -mm ?

Alan
-

To: Alan Cox <alan@...>
Cc: Kristen Carlson Accardi <kristen.c.accardi@...>, roel <12o3l@...>, <linux-ide@...>, <linux-kernel@...>, <akpm@...>
Date: Tuesday, September 25, 2007 - 10:45 pm

it didn't apply straightaway to my tree for whatever reason, IIRC

-

To: roel <12o3l@...>
Cc: Kristen Carlson Accardi <kristen.c.accardi@...>, <jgarzik@...>, <linux-ide@...>, Linux Kernel Mailing List <linux-kernel@...>, <axboe@...>, Andrew Morton <akpm@...>
Date: Monday, September 24, 2007 - 7:28 pm

int foo(int i, int j) {

return !(i & 8) || !j;
}

int moo(int i, int j) {

return !((i & 8) && j);
}

gcc -O2 -S:

.globl foo
.type foo, @function
foo:
shrl $3, %edi
xorl $1, %edi
testl %esi, %esi
sete %al
orl %eax, %edi
andl $1, %edi
movl %edi, %eax
ret
.globl moo
.type moo, @function
moo:
shrl $3, %edi
xorl $1, %edi
testl %esi, %esi
sete %al
orl %eax, %edi
andl $1, %edi
movl %edi, %eax
ret

- Davide

-

To: Davide Libenzi <davidel@...>
Cc: Kristen Carlson Accardi <kristen.c.accardi@...>, <jgarzik@...>, <linux-ide@...>, Linux Kernel Mailing List <linux-kernel@...>, <axboe@...>, Andrew Morton <akpm@...>
Date: Monday, September 24, 2007 - 8:00 pm

Indeed, no difference, except for the eye.

do you not consider it an improvement or do you not want to change it?
or
don't you consider it an improvement and want to change it?

-

Previous thread: [patch 0/2] SATA Link Power Management patches by Kristen Carlson Accardi on Monday, September 24, 2007 - 6:12 pm. (1 message)

Next thread: [patch 2/2] Enable Aggressive Link Power management for AHCI controllers. by Kristen Carlson Accardi on Monday, September 24, 2007 - 6:14 pm. (2 messages)