cpuidle: dt: bail out if the idle-state DT node is not compatible

Currently, the DT of the idle states will be parsed first whether it's
compatible or not. This could cause a warning message that comes from if
the CPU doesn't support identical idle states. E.g. Tegra186 can run
with 2 Cortex-A57 and 2 Denver cores with different idle states on
different types of these cores.

So fix it by checking the match node earlier, then it can make sure it
only goes through the idle states that the CPU supported.

Signed-off-by: Joseph Lo <josephl@nvidia.com>
Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
Joseph Lo 2019-02-01 10:16:39 +08:00 committed by Rafael J. Wysocki
parent 8a56bdeb09
commit db10945cf4
1 changed files with 9 additions and 6 deletions

View File

@ -22,16 +22,12 @@
#include "dt_idle_states.h" #include "dt_idle_states.h"
static int init_state_node(struct cpuidle_state *idle_state, static int init_state_node(struct cpuidle_state *idle_state,
const struct of_device_id *matches, const struct of_device_id *match_id,
struct device_node *state_node) struct device_node *state_node)
{ {
int err; int err;
const struct of_device_id *match_id;
const char *desc; const char *desc;
match_id = of_match_node(matches, state_node);
if (!match_id)
return -ENODEV;
/* /*
* CPUidle drivers are expected to initialize the const void *data * CPUidle drivers are expected to initialize the const void *data
* pointer of the passed in struct of_device_id array to the idle * pointer of the passed in struct of_device_id array to the idle
@ -160,6 +156,7 @@ int dt_init_idle_driver(struct cpuidle_driver *drv,
{ {
struct cpuidle_state *idle_state; struct cpuidle_state *idle_state;
struct device_node *state_node, *cpu_node; struct device_node *state_node, *cpu_node;
const struct of_device_id *match_id;
int i, err = 0; int i, err = 0;
const cpumask_t *cpumask; const cpumask_t *cpumask;
unsigned int state_idx = start_idx; unsigned int state_idx = start_idx;
@ -180,6 +177,12 @@ int dt_init_idle_driver(struct cpuidle_driver *drv,
if (!state_node) if (!state_node)
break; break;
match_id = of_match_node(matches, state_node);
if (!match_id) {
err = -ENODEV;
break;
}
if (!of_device_is_available(state_node)) { if (!of_device_is_available(state_node)) {
of_node_put(state_node); of_node_put(state_node);
continue; continue;
@ -198,7 +201,7 @@ int dt_init_idle_driver(struct cpuidle_driver *drv,
} }
idle_state = &drv->states[state_idx++]; idle_state = &drv->states[state_idx++];
err = init_state_node(idle_state, matches, state_node); err = init_state_node(idle_state, match_id, state_node);
if (err) { if (err) {
pr_err("Parsing idle state node %pOF failed with err %d\n", pr_err("Parsing idle state node %pOF failed with err %d\n",
state_node, err); state_node, err);