thermal: cpufreq_cooling: Avoid all cluster using global cooling_ops
Subsystems (2)
PATCH 1/1 thermal: cpufreq_cooling: Avoid all cluster using global cooling_ops
Now, all the cooling device use the globle cpufreq_cooling_ops. When the CONFIG_THERMAL_GOV_POWER_ALLOCATOR is enabled, once one cluster init the cpufreq_cooling_ops, it would make all cooling device use the power allocator's ops. If one's em is error because of the "em_is_sane", it would cause the em NULL, but the cooling device's ops is exist, as a result, it would cause panic because of the em.
Add cpufreq_power_cooling_ops to avoid this case.
--- drivers/thermal/cpufreq_cooling.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/thermal/cpufreq_cooling.c +12 -3
@@ -493,6 +493,17 @@ static struct thermal_cooling_device_ops cpufreq_cooling_ops = { .set_cur_state = cpufreq_set_cur_state, }; +#ifdef CONFIG_THERMAL_GOV_POWER_ALLOCATOR +static struct thermal_cooling_device_ops cpufreq_power_cooling_ops = { + .get_max_state = cpufreq_get_max_state, + .get_cur_state = cpufreq_get_cur_state, + .set_cur_state = cpufreq_set_cur_state, + .get_requested_power = cpufreq_get_requested_power, + .state2power = cpufreq_state2power, + .power2state = cpufreq_power2state, +}; +#endif +/** * __cpufreq_cooling_register - helper function to create cpufreq cooling device * @np: a valid struct device_node to the cooling device device tree node
@@ -559,9 +570,7 @@ __cpufreq_cooling_register(struct device_node *np,#ifdef CONFIG_THERMAL_GOV_POWER_ALLOCATOR if (em_is_sane (cpufreq_cdev, em)) { cpufreq_cdev->em = em; - cooling_ops->get_requested_power = cpufreq_get_requested_power; - cooling_ops->state2power = cpufreq_state2power; - cooling_ops->power2state = cpufreq_power2state; + cooling_ops = &cpufreq_power_cooling_ops; } else#endif if (policy->freq_table_sorted ==CPUFREQ_TABLE_UNSORTED ) {
Signature · 1 line
2.17.1
Viresh Kumar
maintainerQuoted 38 lines · Di Shen
Now, all the cooling device use the globle
cpufreq_cooling_ops. When theCONFIG_THERMAL_GOV_POWER_ALLOCATORis enabled, once one cluster init thecpufreq_cooling_ops, it would make all cooling device use the power allocator's ops. If one's em is error because of the "em_is_sane", it would cause the em NULL, but the cooling device's ops is exist, as a result, it would cause panic because of the em.Add
cpufreq_power_cooling_opsto avoid this case.Signed-off-by Di Shen <[email protected]>Signed-off-by Xuewen Yan <[email protected]>--- drivers/thermal/cpufreq_cooling.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)drivers/thermal/cpufreq_cooling.c +11
-0@@ -493,6 +493,17 @@ static struct thermal_cooling_device_ops cpufreq_cooling_ops = { .set_cur_state = cpufreq_set_cur_state, }; +#ifdef CONFIG_THERMAL_GOV_POWER_ALLOCATOR +static struct thermal_cooling_device_ops cpufreq_power_cooling_ops = { + .get_max_state = cpufreq_get_max_state, + .get_cur_state = cpufreq_get_cur_state, + .set_cur_state = cpufreq_set_cur_state, + .get_requested_power = cpufreq_get_requested_power, + .state2power = cpufreq_state2power, + .power2state = cpufreq_power2state, +}; +#endif +/** * __cpufreq_cooling_register - helper function to create cpufreq cooling device * @np: a valid struct device_node to the cooling device device tree node
drivers/thermal/cpufreq_cooling.c __cpufreq_cooling_register(struct device_node *np, · line 576
Quoted 10 lines
drivers/thermal/cpufreq_cooling.c +1
-3@@ -559,9 +570,7 @@ __cpufreq_cooling_register(struct device_node *np,#ifdef CONFIG_THERMAL_GOV_POWER_ALLOCATOR if (em_is_sane (cpufreq_cdev, em)) { cpufreq_cdev->em = em; - cooling_ops->get_requested_power = cpufreq_get_requested_power; - cooling_ops->state2power = cpufreq_state2power; - cooling_ops->power2state = cpufreq_power2state; + cooling_ops = &cpufreq_power_cooling_ops; } else#endif if (policy->freq_table_sorted ==CPUFREQ_TABLE_UNSORTED ) {
Please have a look at this patch in linux-next.
commit 6ee324afdf30 ("drivers/thermal/cpufreq_cooling: Use private callback ops for each cooling device")
This already fixes the problem, right ?
Signature · 1 line
viresh
Yes, it fixes this problem! Thank you:)
BR
Di
Quoted 59 lines · Viresh Kumar
Quoted 38 lines · Di Shen
Now, all the cooling device use the globle
cpufreq_cooling_ops. When theCONFIG_THERMAL_GOV_POWER_ALLOCATORis enabled, once one cluster init thecpufreq_cooling_ops, it would make all cooling device use the power allocator's ops. If one's em is error because of the "em_is_sane", it would cause the em NULL, but the cooling device's ops is exist, as a result, it would cause panic because of the em.Add
cpufreq_power_cooling_opsto avoid this case.Signed-off-by Di Shen <[email protected]>Signed-off-by Xuewen Yan <[email protected]>--- drivers/thermal/cpufreq_cooling.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)drivers/thermal/cpufreq_cooling.c +11
-0@@ -493,6 +493,17 @@ static struct thermal_cooling_device_ops cpufreq_cooling_ops = { .set_cur_state = cpufreq_set_cur_state, }; +#ifdef CONFIG_THERMAL_GOV_POWER_ALLOCATOR +static struct thermal_cooling_device_ops cpufreq_power_cooling_ops = { + .get_max_state = cpufreq_get_max_state, + .get_cur_state = cpufreq_get_cur_state, + .set_cur_state = cpufreq_set_cur_state, + .get_requested_power = cpufreq_get_requested_power, + .state2power = cpufreq_state2power, + .power2state = cpufreq_power2state, +}; +#endif +/** * __cpufreq_cooling_register - helper function to create cpufreq cooling device * @np: a valid struct device_node to the cooling device device tree node drivers/thermal/cpufreq_cooling.c __cpufreq_cooling_register(struct device_node *np, · line 576
Quoted 10 lines
drivers/thermal/cpufreq_cooling.c +1
-3@@ -559,9 +570,7 @@ __cpufreq_cooling_register(struct device_node *np,#ifdef CONFIG_THERMAL_GOV_POWER_ALLOCATOR if (em_is_sane (cpufreq_cdev, em)) { cpufreq_cdev->em = em; - cooling_ops->get_requested_power = cpufreq_get_requested_power; - cooling_ops->state2power = cpufreq_state2power; - cooling_ops->power2state = cpufreq_power2state; + cooling_ops = &cpufreq_power_cooling_ops; } else#endif if (policy->freq_table_sorted ==CPUFREQ_TABLE_UNSORTED ) {Please have a look at this patch in linux-next.
commit
6ee324afdf30("drivers/thermal/cpufreq_cooling: Use private callback ops for each cooling device")This already fixes the problem, right ?
--
viresh