cpuidle/powernv : Add Description for cpuidle state
Subsystems (2)
PATCH 1/1 cpuidle/powernv : Add Description for cpuidle state
Names of cpuidle states were being used for description of states in POWER as no descriptions were added in device tree. This patch reads description for idle states which have been added in device tree.
The description for idle states in case of POWER can be printed using "cpupower monitor -l" or "cpupower idle-info".
---
The skiboot patch which adds description for idle states in device tree can be found here: https://patchwork.ozlabs.org/patch/921637/
drivers/cpuidle/cpuidle-powernv.c | 17 +++++++++++++---- include/linux/cpuidle.h | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-)
drivers/cpuidle/cpuidle-powernv.c +13 -4
@@ -133,7 +133,7 @@ static int stop_loop(struct cpuidle_device *dev,static struct cpuidle_state powernv_states[CPUIDLE_STATE_MAX ] = { {/* Snooze */ .name ="snooze" , - .desc ="snooze" , + .desc ="idle polling state" , .exit_latency =0 , .target_residency =0 , .enter = snooze_loop },
@@ -206,6 +206,7 @@ static int powernv_cpuidle_driver_init(void) } static inline void add_powernv_state(int index, const char *name, + const char *desc, unsigned int flags, int (*idle_fn)(struct cpuidle_device *, struct cpuidle_driver *,
@@ -215,7 +216,7 @@ static inline void add_powernv_state(int index, const char *name, u64 psscr_val, u64 psscr_mask) { strlcpy(powernv_states[index].name, name, CPUIDLE_NAME_LEN); -strlcpy (powernv_states[index].desc, name,CPUIDLE_NAME_LEN ); +strlcpy (powernv_states[index].desc, desc,CPUIDLE_DESC_LEN ); powernv_states[index].flags = flags; powernv_states[index].target_residency = target_residency; powernv_states[index].exit_latency = exit_latency;
@@ -250,6 +251,7 @@ static int powernv_add_idle_states(void)u64 psscr_val[CPUIDLE_STATE_MAX ];u64 psscr_mask[CPUIDLE_STATE_MAX ];const char *names[CPUIDLE_STATE_MAX ]; +const char *descs[CPUIDLE_STATE_MAX ];u32 has_stop_states =0 ;int i, rc;u32 supported_flags =pnv_get_supported_cpuidle_states ();
@@ -311,6 +313,11 @@ static int powernv_add_idle_states(void)pr_warn ("cpuidle-powernv: missing ibm,cpu-idle-state-names in DT\n" ); goto out; } +if (of_property_read_string_array (power_mgt, +"ibm,cpu-idle-state-descs" , descs, dt_idle_states) <0 ) { +pr_warn ("cpuidle-powernv: missing ibm,cpu-idle-state-descs in DT\n" ); + goto out; + }/* * If the idle states use stop instruction, probe for psscr values
@@ -414,10 +421,11 @@ static int powernv_add_idle_states(void) target_residency =100 ;/* Add NAP state */ add_powernv_state (nr_idle_states,"Nap" , +"stop processor execution" ,CPUIDLE_FLAG_NONE , nap_loop, target_residency, exit_latency,0 ,0 ); }else if (has_stop_states && !stops_timebase) { -add_powernv_state (nr_idle_states, names[i], +add_powernv_state (nr_idle_states, names[i], descs[i],CPUIDLE_FLAG_NONE , stop_loop, target_residency, exit_latency, psscr_val[i], psscr_mask[i]);
@@ -434,11 +442,12 @@ static int powernv_add_idle_states(void) target_residency =300000 ;/* Add FASTSLEEP state */ add_powernv_state (nr_idle_states,"FastSleep" , +"Core and L2 clock gating" ,CPUIDLE_FLAG_TIMER_STOP , fastsleep_loop, target_residency, exit_latency,0 ,0 ); }else if (has_stop_states && stops_timebase) { -add_powernv_state (nr_idle_states, names[i], +add_powernv_state (nr_idle_states, names[i], descs[i],CPUIDLE_FLAG_TIMER_STOP , stop_loop, target_residency, exit_latency, psscr_val[i], psscr_mask[i]);
include/linux/cpuidle.h +1 -1
@@ -17,7 +17,7 @@#define CPUIDLE_STATE_MAX 10#define CPUIDLE_NAME_LEN 16 -#define CPUIDLE_DESC_LEN 32 +#define CPUIDLE_DESC_LEN 60struct module ;
Signature · 1 line
2.14.1
drivers/cpuidle/cpuidle-powernv.c static inline void add_powernv_state(int index, const char *name, · line 219
Quoted 6 lines · Abhishek Goel
drivers/cpuidle/cpuidle-powernv.c +1
-1@@ -215,7 +216,7 @@ static inline void add_powernv_state(int index, const char *name, u64 psscr_val, u64 psscr_mask) { strlcpy(powernv_states[index].name, name, CPUIDLE_NAME_LEN); -strlcpy (powernv_states[index].desc, name,CPUIDLE_NAME_LEN ); +strlcpy (powernv_states[index].desc, desc,CPUIDLE_DESC_LEN );
We should still fall back to using name in the event of desc being null, as not all firmware will expose the descriptions.
drivers/cpuidle/cpuidle-powernv.c static int powernv_add_idle_states(void) · line 320
Quoted 9 lines
drivers/cpuidle/cpuidle-powernv.c +5
-0@@ -311,6 +313,11 @@ static int powernv_add_idle_states(void)pr_warn ("cpuidle-powernv: missing ibm,cpu-idle-state-names in DT\n" ); goto out; } +if (of_property_read_string_array (power_mgt, +"ibm,cpu-idle-state-descs" , descs, dt_idle_states) <0 ) { +pr_warn ("cpuidle-powernv: missing ibm,cpu-idle-state-descs in DT\n" ); + goto out; + }
I don't think pr_warn is appropriate here, as for all current released firmware we don't have that property. I think perhaps just silently continuing on is okay, as we have to keep compatibility with that firmware.
include/linux/cpuidle.h line 20
Quoted 8 lines
include/linux/cpuidle.h +1
-1@@ -17,7 +17,7 @@#define CPUIDLE_STATE_MAX 10#define CPUIDLE_NAME_LEN 16 -#define CPUIDLE_DESC_LEN 32 +#define CPUIDLE_DESC_LEN 60
Do we really get that long?
Signature · 2 lines
Stewart Smith OPAL Architect, IBM.
Michael Ellerman
reviewerQuoted 11 lines · Stewart Smith
drivers/cpuidle/cpuidle-powernv.c static inline void add_powernv_state(int index, const char *name, · line 219
Quoted 6 lines · Abhishek Goel
drivers/cpuidle/cpuidle-powernv.c +1
-1@@ -215,7 +216,7 @@ static inline void add_powernv_state(int index, const char *name, u64 psscr_val, u64 psscr_mask) { strlcpy(powernv_states[index].name, name, CPUIDLE_NAME_LEN); -strlcpy (powernv_states[index].desc, name,CPUIDLE_NAME_LEN ); +strlcpy (powernv_states[index].desc, desc,CPUIDLE_DESC_LEN );We should still fall back to using name in the event of desc being null, as not all firmware will expose the descriptions.
Quoted 13 lines
drivers/cpuidle/cpuidle-powernv.c static int powernv_add_idle_states(void) · line 320
Quoted 9 lines
drivers/cpuidle/cpuidle-powernv.c +5
-0@@ -311,6 +313,11 @@ static int powernv_add_idle_states(void)pr_warn ("cpuidle-powernv: missing ibm,cpu-idle-state-names in DT\n" ); goto out; } +if (of_property_read_string_array (power_mgt, +"ibm,cpu-idle-state-descs" , descs, dt_idle_states) <0 ) { +pr_warn ("cpuidle-powernv: missing ibm,cpu-idle-state-descs in DT\n" ); + goto out; + }I don't think
pr_warnis appropriate here, as for all current released firmware we don't have that property. I think perhaps just silently continuing on is okay, as we have to keep compatibility with that firmware.
+1
Anyone who's wondering why they're not seeing the names can just look at the device tree on the machine to see if the property is there or not, they don't need a printk in dmesg to tell them.
cheers