Message ID | 20200303203559.23995-4-ulf.hansson@linaro.org |
---|---|
State | Superseded |
Headers | show |
Series | cpuidle: psci: Some fixes when using the hierarchical layout | expand |
On Wed, 4 Mar 2020 at 13:12, Sudeep Holla <sudeep.holla@arm.com> wrote: > > On Tue, Mar 03, 2020 at 09:35:58PM +0100, Ulf Hansson wrote: > > To make the code a bit more readable, but also to prepare some code to be > > re-used, let's move the OSI specific initialization out of the > > psci_dt_cpu_init_idle() and into a separate function. > > > > Fixes: a65a397f2451 ("cpuidle: psci: Add support for PM domains by using genpd") > > Not sure if this fixes anything but I am fine to have this if next one is > a real fix. Yep, that's what I had in mind as well. > > > Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> > > --- > > > > Changes in v2: > > - Adopted suggestions from Stephen to use IS_ERR_OR_NULL and > > PTR_ERR_OR_ZERO, which further clarified the code. > > > > --- > > drivers/cpuidle/cpuidle-psci.c | 46 ++++++++++++++++++++-------------- > > 1 file changed, 27 insertions(+), 19 deletions(-) > > > > diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c > > index edd7a54ef0d3..bae9140a65a5 100644 > > --- a/drivers/cpuidle/cpuidle-psci.c > > +++ b/drivers/cpuidle/cpuidle-psci.c > > @@ -160,6 +160,29 @@ int __init psci_dt_parse_state_node(struct device_node *np, u32 *state) > > return 0; > > } > > > > +static int __init psci_dt_cpu_init_topology(struct cpuidle_driver *drv, > > + struct psci_cpuidle_data *data, > > + unsigned int state_count, int cpu) > > +{ > > + /* Currently limit the hierarchical topology to be used in OSI mode. */ > > + if (!psci_has_osi_support()) > > + return 0; > > + > > + data->dev = psci_dt_attach_cpu(cpu); > > + if (IS_ERR_OR_NULL(data->dev)) > > + return PTR_ERR_OR_ZERO(data->dev); > > + > > This is what I was asking to do before this was merged when I meant to drop > if(data->dev) check. So happy to see it :) I probably didn't get you point well enough. Sorry. > > Reviewed-by: Sudeep Holla <sudeep.holla@arm.com> Thanks! Kind regards Uffe
diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c index edd7a54ef0d3..bae9140a65a5 100644 --- a/drivers/cpuidle/cpuidle-psci.c +++ b/drivers/cpuidle/cpuidle-psci.c @@ -160,6 +160,29 @@ int __init psci_dt_parse_state_node(struct device_node *np, u32 *state) return 0; } +static int __init psci_dt_cpu_init_topology(struct cpuidle_driver *drv, + struct psci_cpuidle_data *data, + unsigned int state_count, int cpu) +{ + /* Currently limit the hierarchical topology to be used in OSI mode. */ + if (!psci_has_osi_support()) + return 0; + + data->dev = psci_dt_attach_cpu(cpu); + if (IS_ERR_OR_NULL(data->dev)) + return PTR_ERR_OR_ZERO(data->dev); + + /* + * Using the deepest state for the CPU to trigger a potential selection + * of a shared state for the domain, assumes the domain states are all + * deeper states. + */ + drv->states[state_count - 1].enter = psci_enter_domain_idle_state; + psci_cpuidle_use_cpuhp = true; + + return 0; +} + static int __init psci_dt_cpu_init_idle(struct cpuidle_driver *drv, struct device_node *cpu_node, unsigned int state_count, int cpu) @@ -193,25 +216,10 @@ static int __init psci_dt_cpu_init_idle(struct cpuidle_driver *drv, goto free_mem; } - /* Currently limit the hierarchical topology to be used in OSI mode. */ - if (psci_has_osi_support()) { - data->dev = psci_dt_attach_cpu(cpu); - if (IS_ERR(data->dev)) { - ret = PTR_ERR(data->dev); - goto free_mem; - } - - /* - * Using the deepest state for the CPU to trigger a potential - * selection of a shared state for the domain, assumes the - * domain states are all deeper states. - */ - if (data->dev) { - drv->states[state_count - 1].enter = - psci_enter_domain_idle_state; - psci_cpuidle_use_cpuhp = true; - } - } + /* Initialize optional data, used for the hierarchical topology. */ + ret = psci_dt_cpu_init_topology(drv, data, state_count, cpu); + if (ret < 0) + goto free_mem; /* Idle states parsed correctly, store them in the per-cpu struct. */ data->psci_states = psci_states;
To make the code a bit more readable, but also to prepare some code to be re-used, let's move the OSI specific initialization out of the psci_dt_cpu_init_idle() and into a separate function. Fixes: a65a397f2451 ("cpuidle: psci: Add support for PM domains by using genpd") Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> --- Changes in v2: - Adopted suggestions from Stephen to use IS_ERR_OR_NULL and PTR_ERR_OR_ZERO, which further clarified the code. --- drivers/cpuidle/cpuidle-psci.c | 46 ++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 19 deletions(-) -- 2.20.1