Re: [PATCH] [SCHEME 2]powernv/cpuidle: Add support for new idle state device-tree format
Hi Akshay, Thank you for the patch! Yet something to improve: [auto build test ERROR on powerpc/next] [also build test ERROR on v4.17-rc7 next-20180531] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Akshay-Adiga/powernv-cpuidle-Add-support-for-new-idle-state-device-tree-format/20180601-202708 base: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next config: powerpc-allmodconfig (attached as .config) compiler: powerpc64-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0 reproduce: wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=powerpc All errors (new ones prefixed by >>): drivers//cpuidle/cpuidle-powernv.c: In function 'powernv_add_idle_states': >> drivers//cpuidle/cpuidle-powernv.c:403:36: error: 'versions' undeclared >> (first use in this function) "ibm,cpu-idle-state-versions", versions, additional_states) < 0) { ^~~~ drivers//cpuidle/cpuidle-powernv.c:403:36: note: each undeclared identifier is reported only once for each function it appears in >> drivers//cpuidle/cpuidle-powernv.c:436:17: error: 'version' undeclared >> (first use in this function); did you mean 'versions'? if (!( strcmp(version[i] , "ibm,idle-state-v1")) ^~~ versions >> drivers//cpuidle/cpuidle-powernv.c:437:5: error: expected ')' before >> 'continue' continue; ^~~~ >> drivers//cpuidle/cpuidle-powernv.c:511:2: error: expected expression before >> '}' token } ^ drivers//cpuidle/cpuidle-powernv.c:426:8: warning: unused variable 'stops_timebase' [-Wunused-variable] bool stops_timebase = false; ^~ drivers//cpuidle/cpuidle-powernv.c:425:30: warning: unused variable 'target_residency' [-Wunused-variable] unsigned int exit_latency, target_residency; ^~~~ drivers//cpuidle/cpuidle-powernv.c:425:16: warning: unused variable 'exit_latency' [-Wunused-variable] unsigned int exit_latency, target_residency; ^~~~ At top level: drivers//cpuidle/cpuidle-powernv.c:121:12: warning: 'stop_loop' defined but not used [-Wunused-function] static int stop_loop(struct cpuidle_device *dev, ^ drivers//cpuidle/cpuidle-powernv.c:95:12: warning: 'fastsleep_loop' defined but not used [-Wunused-function] static int fastsleep_loop(struct cpuidle_device *dev, ^~ drivers//cpuidle/cpuidle-powernv.c:84:12: warning: 'nap_loop' defined but not used [-Wunused-function] static int nap_loop(struct cpuidle_device *dev, ^~~~ vim +/versions +403 drivers//cpuidle/cpuidle-powernv.c 240 241 extern u32 pnv_get_supported_cpuidle_states(void); 242 static int powernv_add_idle_states(void) 243 { 244 struct device_node *power_mgt,*np_new; 245 int nr_idle_states = 1; /* Snooze */ 246 int dt_idle_states, count, additional_states; 247 u32 latency_ns[CPUIDLE_STATE_MAX]; 248 u32 residency_ns[CPUIDLE_STATE_MAX]; 249 u32 flags[CPUIDLE_STATE_MAX]; 250 u64 psscr_val[CPUIDLE_STATE_MAX]; 251 u64 psscr_mask[CPUIDLE_STATE_MAX]; 252 const char *names[CPUIDLE_STATE_MAX]; 253 u32 has_stop_states = 0; 254 int i, rc; 255 u32 supported_flags = pnv_get_supported_cpuidle_states(); 256 257 258 /* Currently we have snooze statically defined */ 259 260 power_mgt = of_find_node_by_path("/ibm,opal/power-mgt"); 261 if (!power_mgt) { 262 pr_warn("opal: PowerMgmt Node not found\n"); 263 goto out; 264 } 265 266 /* Read values of any property to determine the num of idle states */ 267 dt_idle_states = of_property_count_u32_elems(power_mgt, "ibm,cpu-idle-state-flags"); 268 if (dt_idle_states < 0) { 269 pr_warn("cpuidle-powernv: no idle states found in the DT\n"); 270 goto out; 271 } 272 273 count = of_property_count_u32_elems(power_mgt, 274 "ibm,cpu-idle-state-latencies-ns"); 275 276 if (validate_dt_prop_sizes("ibm,cpu-idle-state-flags", dt_idle_states, 277 "ibm,cpu-idle-state-latencies-ns", 278 count) != 0) 279 goto out; 280 281 count = of_property_count_strings(power_mgt, 282
Re: [PATCH] [SCHEME 2]powernv/cpuidle: Add support for new idle state device-tree format
On Thu, May 31, 2018 at 08:23:20AM +0530, Akshay Adiga wrote: > This patch adds support for new device-tree format for idle state > description. > > Previously if a older kernel runs on a newer firmware, it may enable > all available states irrespective of its capability of handling it. > New device tree format adds a compatible flag, so that only kernel > which has the capability to handle the version of stop state will enable > it. > > Older kernel will still see stop0 and stop0_lite in older format and we > will depricate it after some time. > > Idea is to bump up the version in firmware if we find a bug or > regression in stop states. A fix will be provided in linux which would > now know about the bumped up version of stop states, where as kernel > without fixes would ignore the states. > > New idle state device tree format : > > power-mgt { > ibm,cpu-idle-state-names = "stop0_lite", "stop0"; > ibm,cpu-idle-state-residency-ns = <0x2710 0x4e20>; > ibm,cpu-idle-state-latencies-ns = <0x3e8 0x7d0>; > ibm,cpu-idle-state-psscr-mask = <0x0 0x3003ff 0x0 0x3003ff>; > ibm,cpu-idle-state-psscr = <0x0 0x330 0x0 0x300330>; > ibm,cpu-idle-state-flags = <0x10 0x101000>; > ibm,enabled-stop-levels = <0xec00>; > ibm,idle-states { > ibm,cpu-idle-state-names = "stop1", "stop2", "stop4", "stop5"; > ibm,cpu-idle-state-residency-ns = <0xc350 0x186a0 0x989680 > 0x1312d00>; > ibm,cpu-idle-state-latencies-ns = <0x1388 0x2710 0x186a0 > 0x30d40>; > ibm,cpu-idle-state-psscr-mask = <0x0 0x3003ff 0x0 0x3003ff 0x0 > 0x3003ff 0x0 0x3003ff>; > ibm,cpu-idle-state-psscr = <0x0 0x300331 0x0 0x300332 0x0 > 0x300374 0x0 0x300375>; > ibm,cpu-idle-state-versions = "ibm,idle-state-v1 > ", "ibm,idle-state-v1", "ibm,idle-state-v1", "ibm,idle-state-v1"; > ibm,cpu-idle-state-flags = <0x101000 0x101000 0x207000 > 0x207000>; >} > } > > Signed-off-by: Akshay Adiga > --- This patch is intended to be a RFC. The skiboot patch has been posted here : https://patchwork.ozlabs.org/patch/923121/
[PATCH] [SCHEME 2]powernv/cpuidle: Add support for new idle state device-tree format
This patch adds support for new device-tree format for idle state description. Previously if a older kernel runs on a newer firmware, it may enable all available states irrespective of its capability of handling it. New device tree format adds a compatible flag, so that only kernel which has the capability to handle the version of stop state will enable it. Older kernel will still see stop0 and stop0_lite in older format and we will depricate it after some time. Idea is to bump up the version in firmware if we find a bug or regression in stop states. A fix will be provided in linux which would now know about the bumped up version of stop states, where as kernel without fixes would ignore the states. New idle state device tree format : power-mgt { ibm,cpu-idle-state-names = "stop0_lite", "stop0"; ibm,cpu-idle-state-residency-ns = <0x2710 0x4e20>; ibm,cpu-idle-state-latencies-ns = <0x3e8 0x7d0>; ibm,cpu-idle-state-psscr-mask = <0x0 0x3003ff 0x0 0x3003ff>; ibm,cpu-idle-state-psscr = <0x0 0x330 0x0 0x300330>; ibm,cpu-idle-state-flags = <0x10 0x101000>; ibm,enabled-stop-levels = <0xec00>; ibm,idle-states { ibm,cpu-idle-state-names = "stop1", "stop2", "stop4", "stop5"; ibm,cpu-idle-state-residency-ns = <0xc350 0x186a0 0x989680 0x1312d00>; ibm,cpu-idle-state-latencies-ns = <0x1388 0x2710 0x186a0 0x30d40>; ibm,cpu-idle-state-psscr-mask = <0x0 0x3003ff 0x0 0x3003ff 0x0 0x3003ff 0x0 0x3003ff>; ibm,cpu-idle-state-psscr = <0x0 0x300331 0x0 0x300332 0x0 0x300374 0x0 0x300375>; ibm,cpu-idle-state-versions = "ibm,idle-state-v1 ", "ibm,idle-state-v1", "ibm,idle-state-v1", "ibm,idle-state-v1"; ibm,cpu-idle-state-flags = <0x101000 0x101000 0x207000 0x207000>; } } Signed-off-by: Akshay Adiga --- arch/powerpc/platforms/powernv/idle.c | 60 ++-- drivers/cpuidle/cpuidle-powernv.c | 65 +-- 2 files changed, 112 insertions(+), 13 deletions(-) diff --git a/arch/powerpc/platforms/powernv/idle.c b/arch/powerpc/platforms/powernv/idle.c index 1f12ab1..ab52665 100644 --- a/arch/powerpc/platforms/powernv/idle.c +++ b/arch/powerpc/platforms/powernv/idle.c @@ -622,8 +622,8 @@ int validate_psscr_val_mask(u64 *psscr_val, u64 *psscr_mask, u32 flags) * @dt_idle_states: Number of idle state entries * Returns 0 on success */ -static int __init pnv_power9_idle_init(struct device_node *np, u32 *flags, - int dt_idle_states) +static int __init pnv_power9_idle_init(struct device_node *np, struct device_node *np_new,u32 *flags, + int dt_idle_states, int additional_states) { u64 *psscr_val = NULL; u64 *psscr_mask = NULL; @@ -631,9 +631,10 @@ static int __init pnv_power9_idle_init(struct device_node *np, u32 *flags, u64 max_residency_ns = 0; int rc = 0, i; - psscr_val = kcalloc(dt_idle_states, sizeof(*psscr_val), GFP_KERNEL); - psscr_mask = kcalloc(dt_idle_states, sizeof(*psscr_mask), GFP_KERNEL); - residency_ns = kcalloc(dt_idle_states, sizeof(*residency_ns), + /* TODO: remove ugliness of using additional_states count*/ + psscr_val = kcalloc(dt_idle_states+additional_states, sizeof(*psscr_val), GFP_KERNEL); + psscr_mask = kcalloc(dt_idle_states+additional_states, sizeof(*psscr_mask), GFP_KERNEL); + residency_ns = kcalloc(dt_idle_states+additional_states, sizeof(*residency_ns), GFP_KERNEL); if (!psscr_val || !psscr_mask || !residency_ns) { @@ -648,6 +649,13 @@ static int __init pnv_power9_idle_init(struct device_node *np, u32 *flags, rc = -1; goto out; } + if (of_property_read_u64_array(np_new, + "ibm,cpu-idle-state-psscr", + psscr_val + dt_idle_states, additional_states)) { + pr_warn("cpuidle-powernv: missing addtional ibm,cpu-idle-state-psscr in DT\n"); + rc = -1; + goto out; + } if (of_property_read_u64_array(np, "ibm,cpu-idle-state-psscr-mask", @@ -656,6 +664,13 @@ static int __init pnv_power9_idle_init(struct device_node *np, u32 *flags, rc = -1; goto out; } + if (of_property_read_u64_array(np_new, + "ibm,cpu-idle-state-psscr-mask", + psscr_mask + dt_idle_states, additional_states)) { + pr_warn("cpuidle-powernv: missing ibm,cpu-idle-state-psscr-mask in DT\n"); + rc = -1; + goto out; + } if (of_property_read_u32_array(np, "ibm,cpu-idle-state-residency-ns", @@ -664,7 +679,13 @@ static int __init