Skip to contentSkip to conversation

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

PATCH Superseded Joseph Lo 2 participants 3 messages Jan 31, 2019 – Feb 1, 2019

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Joseph Lo

author
#0 lore raw

PATCH 1/1 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.

We fix it to check the compatible string before the parsing procedures. So it can make sure it only goes through the idle states that the CPU supported.

---
 drivers/cpuidle/dt_idle_states.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/cpuidle/dt_idle_states.c +5 -0
index 53342b7f1010..4a528908abb3 100644
@@ -180,6 +180,11 @@ int dt_init_idle_driver(struct cpuidle_driver *drv,
 		if (!state_node)
 			break;
 
+		if (!of_device_is_compatible(state_node, matches->compatible)) {
+			err = -EINVAL;
+			break;
+		}
+
 		if (!of_device_is_available(state_node)) {
 			of_node_put(state_node);
 			continue;
Signature · 1 line
2.20.1
#1 lore raw
Quoted 20 lines · Joseph Lo

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.

We fix it to check the compatible string before the parsing procedures. So it can make sure it only goes through the idle states that the CPU supported.

---
 drivers/cpuidle/dt_idle_states.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/cpuidle/dt_idle_states.c +0 -0
index 53342b7f1010..4a528908abb3 100644

drivers/cpuidle/dt_idle_states.c int dt_init_idle_driver(struct cpuidle_driver *drv, · line 187

Quoted 8 lines
drivers/cpuidle/dt_idle_states.c +5 -0
@@ -180,6 +180,11 @@ int dt_init_idle_driver(struct cpuidle_driver *drv,
 		if (!state_node)
 			break;
 
+		if (!of_device_is_compatible(state_node, matches->compatible)) {
+			err = -EINVAL;
+			break;
+		}
+

Does it make sense to use of_match_node to get the matching device id and just pass that to init_state_node instead of the complete array to find the match.

--
Regards,
Sudeep

author
#2 lore raw
Quoted 24 lines · Sudeep Holla
Quoted 23 lines · Joseph Lo

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.

We fix it to check the compatible string before the parsing procedures. So it can make sure it only goes through the idle states that the CPU supported.

---
  drivers/cpuidle/dt_idle_states.c | 5 +++++
  1 file changed, 5 insertions(+)
drivers/cpuidle/dt_idle_states.c +0 -0
index 53342b7f1010..4a528908abb3 100644
@@ -180,6 +180,11 @@ int dt_init_idle_driver(struct cpuidle_driver *drv,
  		if (!state_node)
  			break;
 
Quoted 9 lines

drivers/cpuidle/dt_idle_states.c int dt_init_idle_driver(struct cpuidle_driver *drv, · line 187

Quoted 5 lines
drivers/cpuidle/dt_idle_states.c +5 -0
+		if (!of_device_is_compatible(state_node, matches->compatible)) {
+			err = -EINVAL;
+			break;
+		}
+

Does it make sense to use of_match_node to get the matching device id and just pass that to init_state_node instead of the complete array to find the match.

Yes, that would be even better.

Thanks,
Joseph