From: Preeti U Murthy <hidden> Date: 2014-10-14 07:53:14
We hard code the metrics relevant for cpuidle states in the kernel today.
Instead pick them up from the device tree so that they remain relevant
and updated for the system that the kernel is running on.
Cc: linux-pm@vger.kernel.org
Cc: Rafael J. Wysocki <redacted>
Cc: devicetree@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Preeti U. Murthy <redacted>
Signed-off-by: Shreyas B. Prabhu <redacted>
---
drivers/cpuidle/cpuidle-powernv.c | 27 ++++++++++++++++++++++-----
1 file changed, 22 insertions(+), 5 deletions(-)
@@ -165,7 +165,8 @@ static int powernv_add_idle_states(void)intnr_idle_states=1;/* Snooze */intdt_idle_states;const__be32*idle_state_flags;-u32len_flags,flags;+const__be32*idle_state_latency;+u32len_flags,flags,latency_ns;inti;/* Currently we have snooze statically defined */
@@ -182,18 +183,32 @@ static int powernv_add_idle_states(void)returnnr_idle_states;}+idle_state_latency=of_get_property(power_mgt,+"ibm,cpu-idle-state-latencies-ns",NULL);+if(!idle_state_latency){+pr_warn("DT-PowerMgmt: missing ibm,cpu-idle-state-latencies-ns\n");+returnnr_idle_states;+}+dt_idle_states=len_flags/sizeof(u32);for(i=0;i<dt_idle_states;i++){flags=be32_to_cpu(idle_state_flags[i]);++/* Cpuidle accepts exit_latency in us and we estimate+*targetresidencytobe10xexit_latency+*/+latency_ns=be32_to_cpu(idle_state_latency[i]);if(flags&IDLE_USE_INST_NAP){/* Add NAP state */strcpy(powernv_states[nr_idle_states].name,"Nap");strcpy(powernv_states[nr_idle_states].desc,"Nap");powernv_states[nr_idle_states].flags=CPUIDLE_FLAG_TIME_VALID;-powernv_states[nr_idle_states].exit_latency=10;-powernv_states[nr_idle_states].target_residency=100;+powernv_states[nr_idle_states].exit_latency=+((unsignedint)latency_ns)/1000;+powernv_states[nr_idle_states].target_residency=+((unsignedint)latency_ns/100);powernv_states[nr_idle_states].enter=&nap_loop;nr_idle_states++;}
@@ -204,8 +219,10 @@ static int powernv_add_idle_states(void)strcpy(powernv_states[nr_idle_states].desc,"FastSleep");powernv_states[nr_idle_states].flags=CPUIDLE_FLAG_TIME_VALID|CPUIDLE_FLAG_TIMER_STOP;-powernv_states[nr_idle_states].exit_latency=300;-powernv_states[nr_idle_states].target_residency=1000000;+powernv_states[nr_idle_states].exit_latency=+((unsignedint)latency_ns)/1000;+powernv_states[nr_idle_states].target_residency=+((unsignedint)latency_ns/100);powernv_states[nr_idle_states].enter=&fastsleep_loop;nr_idle_states++;}
From: Rafael J. Wysocki <hidden> Date: 2014-10-21 13:13:25
On Tuesday, October 14, 2014 01:23:00 PM Preeti U Murthy wrote:
We hard code the metrics relevant for cpuidle states in the kernel today.
Instead pick them up from the device tree so that they remain relevant
and updated for the system that the kernel is running on.
Cc: linux-pm@vger.kernel.org
Cc: Rafael J. Wysocki <redacted>
Cc: devicetree@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Preeti U. Murthy <redacted>
Signed-off-by: Shreyas B. Prabhu <redacted>
@@ -165,7 +165,8 @@ static int powernv_add_idle_states(void)intnr_idle_states=1;/* Snooze */intdt_idle_states;const__be32*idle_state_flags;-u32len_flags,flags;+const__be32*idle_state_latency;+u32len_flags,flags,latency_ns;inti;/* Currently we have snooze statically defined */
@@ -182,18 +183,32 @@ static int powernv_add_idle_states(void)returnnr_idle_states;}+idle_state_latency=of_get_property(power_mgt,+"ibm,cpu-idle-state-latencies-ns",NULL);+if(!idle_state_latency){+pr_warn("DT-PowerMgmt: missing ibm,cpu-idle-state-latencies-ns\n");+returnnr_idle_states;+}+dt_idle_states=len_flags/sizeof(u32);for(i=0;i<dt_idle_states;i++){flags=be32_to_cpu(idle_state_flags[i]);++/* Cpuidle accepts exit_latency in us and we estimate+*targetresidencytobe10xexit_latency+*/+latency_ns=be32_to_cpu(idle_state_latency[i]);if(flags&IDLE_USE_INST_NAP){/* Add NAP state */strcpy(powernv_states[nr_idle_states].name,"Nap");strcpy(powernv_states[nr_idle_states].desc,"Nap");powernv_states[nr_idle_states].flags=CPUIDLE_FLAG_TIME_VALID;-powernv_states[nr_idle_states].exit_latency=10;-powernv_states[nr_idle_states].target_residency=100;+powernv_states[nr_idle_states].exit_latency=+((unsignedint)latency_ns)/1000;+powernv_states[nr_idle_states].target_residency=+((unsignedint)latency_ns/100);powernv_states[nr_idle_states].enter=&nap_loop;nr_idle_states++;}
@@ -204,8 +219,10 @@ static int powernv_add_idle_states(void)strcpy(powernv_states[nr_idle_states].desc,"FastSleep");powernv_states[nr_idle_states].flags=CPUIDLE_FLAG_TIME_VALID|CPUIDLE_FLAG_TIMER_STOP;-powernv_states[nr_idle_states].exit_latency=300;-powernv_states[nr_idle_states].target_residency=1000000;+powernv_states[nr_idle_states].exit_latency=+((unsignedint)latency_ns)/1000;+powernv_states[nr_idle_states].target_residency=+((unsignedint)latency_ns/100);powernv_states[nr_idle_states].enter=&fastsleep_loop;nr_idle_states++;}--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
From: Lorenzo Pieralisi <hidden> Date: 2014-10-24 14:30:45
On Tue, Oct 14, 2014 at 08:53:00AM +0100, Preeti U Murthy wrote:
We hard code the metrics relevant for cpuidle states in the kernel today.
Instead pick them up from the device tree so that they remain relevant
and updated for the system that the kernel is running on.
Cc: linux-pm@vger.kernel.org
Cc: Rafael J. Wysocki <redacted>
Cc: devicetree@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Preeti U. Murthy <redacted>
Signed-off-by: Shreyas B. Prabhu <redacted>
---
drivers/cpuidle/cpuidle-powernv.c | 27 ++++++++++++++++++++++-----
1 file changed, 22 insertions(+), 5 deletions(-)
Device tree properties should be documented, and these bindings are
getting very similar to the ones I have just completed for ARM,
I wonder whether we should take the generic bits out of ARM bindings (ie
exit_latency) and make those available to other architectures.
Thanks,
Lorenzo
@@ -165,7 +165,8 @@ static int powernv_add_idle_states(void)intnr_idle_states=1;/* Snooze */intdt_idle_states;const__be32*idle_state_flags;-u32len_flags,flags;+const__be32*idle_state_latency;+u32len_flags,flags,latency_ns;inti;/* Currently we have snooze statically defined */
@@ -182,18 +183,32 @@ static int powernv_add_idle_states(void)returnnr_idle_states;}+idle_state_latency=of_get_property(power_mgt,+"ibm,cpu-idle-state-latencies-ns",NULL);+if(!idle_state_latency){+pr_warn("DT-PowerMgmt: missing ibm,cpu-idle-state-latencies-ns\n");+returnnr_idle_states;+}+dt_idle_states=len_flags/sizeof(u32);for(i=0;i<dt_idle_states;i++){flags=be32_to_cpu(idle_state_flags[i]);++/* Cpuidle accepts exit_latency in us and we estimate+*targetresidencytobe10xexit_latency+*/+latency_ns=be32_to_cpu(idle_state_latency[i]);if(flags&IDLE_USE_INST_NAP){/* Add NAP state */strcpy(powernv_states[nr_idle_states].name,"Nap");strcpy(powernv_states[nr_idle_states].desc,"Nap");powernv_states[nr_idle_states].flags=CPUIDLE_FLAG_TIME_VALID;-powernv_states[nr_idle_states].exit_latency=10;-powernv_states[nr_idle_states].target_residency=100;+powernv_states[nr_idle_states].exit_latency=+((unsignedint)latency_ns)/1000;+powernv_states[nr_idle_states].target_residency=+((unsignedint)latency_ns/100);powernv_states[nr_idle_states].enter=&nap_loop;nr_idle_states++;}
@@ -204,8 +219,10 @@ static int powernv_add_idle_states(void)strcpy(powernv_states[nr_idle_states].desc,"FastSleep");powernv_states[nr_idle_states].flags=CPUIDLE_FLAG_TIME_VALID|CPUIDLE_FLAG_TIMER_STOP;-powernv_states[nr_idle_states].exit_latency=300;-powernv_states[nr_idle_states].target_residency=1000000;+powernv_states[nr_idle_states].exit_latency=+((unsignedint)latency_ns)/1000;+powernv_states[nr_idle_states].target_residency=+((unsignedint)latency_ns/100);powernv_states[nr_idle_states].enter=&fastsleep_loop;nr_idle_states++;}--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2014-10-27 03:34:36
On Fri, 2014-10-24 at 15:30 +0100, Lorenzo Pieralisi wrote:
On Tue, Oct 14, 2014 at 08:53:00AM +0100, Preeti U Murthy wrote:
quoted
We hard code the metrics relevant for cpuidle states in the kernel today.
Instead pick them up from the device tree so that they remain relevant
and updated for the system that the kernel is running on.
Device tree properties should be documented, and these bindings are
getting very similar to the ones I have just completed for ARM,
I wonder whether we should take the generic bits out of ARM bindings (ie
exit_latency) and make those available to other architectures.
The firmware that emits those properties is already in the field, so it would
have been nice to use a generic binding but it's too late now.
cheers