Skip to content

Commit db10945

Browse files
joseph-lo-nvtwrafaeljw
authored andcommitted
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>
1 parent 8a56bde commit db10945

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

drivers/cpuidle/dt_idle_states.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,12 @@
2222
#include "dt_idle_states.h"
2323

2424
static int init_state_node(struct cpuidle_state *idle_state,
25-
const struct of_device_id *matches,
25+
const struct of_device_id *match_id,
2626
struct device_node *state_node)
2727
{
2828
int err;
29-
const struct of_device_id *match_id;
3029
const char *desc;
3130

32-
match_id = of_match_node(matches, state_node);
33-
if (!match_id)
34-
return -ENODEV;
3531
/*
3632
* CPUidle drivers are expected to initialize the const void *data
3733
* 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,
160156
{
161157
struct cpuidle_state *idle_state;
162158
struct device_node *state_node, *cpu_node;
159+
const struct of_device_id *match_id;
163160
int i, err = 0;
164161
const cpumask_t *cpumask;
165162
unsigned int state_idx = start_idx;
@@ -180,6 +177,12 @@ int dt_init_idle_driver(struct cpuidle_driver *drv,
180177
if (!state_node)
181178
break;
182179

180+
match_id = of_match_node(matches, state_node);
181+
if (!match_id) {
182+
err = -ENODEV;
183+
break;
184+
}
185+
183186
if (!of_device_is_available(state_node)) {
184187
of_node_put(state_node);
185188
continue;
@@ -198,7 +201,7 @@ int dt_init_idle_driver(struct cpuidle_driver *drv,
198201
}
199202

200203
idle_state = &drv->states[state_idx++];
201-
err = init_state_node(idle_state, matches, state_node);
204+
err = init_state_node(idle_state, match_id, state_node);
202205
if (err) {
203206
pr_err("Parsing idle state node %pOF failed with err %d\n",
204207
state_node, err);

0 commit comments

Comments
 (0)