thermal: rename thermal_cooling_device_stats_update()
Subsystems (3)
Zhang Rui
reviewerRFC PATCH 1/5 thermal: rename thermal_cooling_device_stats_update()
Rename thermal_cooling_device_stats_update() tothermal_cdev_stats_update_cur()
--- drivers/thermal/thermal_core.h | 4 ++-- drivers/thermal/thermal_helpers.c | 2 +- drivers/thermal/thermal_sysfs.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/thermal/thermal_core.h +2 -2
@@ -81,11 +81,11 @@ ssize_t weight_store(struct device *, struct device_attribute *, const char *, size_t);#ifdef CONFIG_THERMAL_STATISTICS -void thermal_cooling_device_stats_update (struct thermal_cooling_device *cdev, +void thermal_cdev_stats_update_cur (struct thermal_cooling_device *cdev,unsigned long new_state);#else static inline void -thermal_cooling_device_stats_update (struct thermal_cooling_device *cdev, +thermal_cdev_stats_update_cur (struct thermal_cooling_device *cdev,unsigned long new_state) {}#endif /* CONFIG_THERMAL_STATISTICS */
drivers/thermal/thermal_helpers.c +1 -1
@@ -186,7 +186,7 @@ void thermal_cdev_update(struct thermal_cooling_device *cdev) }if (!cdev->ops->set_cur_state (cdev, target)) -thermal_cooling_device_stats_update (cdev, target); +thermal_cdev_stats_update_cur (cdev, target); cdev->updated = true;mutex_unlock (&cdev->lock);
drivers/thermal/thermal_sysfs.c +2 -2
@@ -716,7 +716,7 @@ cur_state_store(struct device *dev, struct device_attribute *attr, result = cdev->ops->set_cur_state (cdev, state);if (!result) -thermal_cooling_device_stats_update (cdev, state); +thermal_cdev_stats_update_cur (cdev, state);mutex_unlock (&cdev->lock);return result ? result : count;
@@ -765,7 +765,7 @@ static void update_time_in_state(struct cooling_dev_stats *stats) stats->last_time = now; } -void thermal_cooling_device_stats_update (struct thermal_cooling_device *cdev, +void thermal_cdev_stats_update_cur (struct thermal_cooling_device *cdev,unsigned long new_state) {struct cooling_dev_stats *stats = cdev->stats;
Signature · 1 line
2.17.1
Zhang Rui
reviewerRFC PATCH 2/5 thermal: create statistics table in two steps
Part of cooling device stats table is created based on the number of cooling states supported, and this may be changed at runtime. Introduce cooling_device_stats_resize() to handle this piece of the statistics table.
Plus, check the existence of the statistics table before access because the table may fail to be created during cooling device registration.
--- drivers/thermal/thermal_sysfs.c | 56 ++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 14 deletions(-)
drivers/thermal/thermal_sysfs.c +42 -14
@@ -770,6 +770,9 @@ void thermal_cdev_stats_update_cur(struct thermal_cooling_device *cdev, {struct cooling_dev_stats *stats = cdev->stats; +if (!stats) +return ; +spin_lock (&stats->lock);if (stats->state == new_state)
@@ -904,33 +907,52 @@ static const struct attribute_group cooling_device_stats_attr_group = { .name = "stats" }; -static void cooling_device_stats_setup (struct thermal_cooling_device *cdev) +static int cooling_device_stats_resize (struct thermal_cooling_device *cdev) { -struct cooling_dev_stats *stats; +struct cooling_dev_stats *stats = cdev->stats;unsigned long states; -int var; +int ret; -if (cdev->ops->get_max_state (cdev, &states)) -return ; + ret = cdev->ops->get_max_state (cdev, &states); +if (ret) +return ret; states++;/* Total number of states is highest state + 1 */ - var =sizeof (*stats); - var +=sizeof (*stats->time_in_state) * states; - var +=sizeof (*stats->trans_table) * states * states; + stats->time_in_state =kcalloc (states,sizeof (*stats->time_in_state),GFP_KERNEL ); +if (!stats->time_in_state) +return -ENOMEM ; - stats =kzalloc (var,GFP_KERNEL ); -if (!stats) -return ; + stats->trans_table =kcalloc (states,sizeof (*stats->trans_table) * states,GFP_KERNEL ); +if (!stats->trans_table) { +kfree (stats->time_in_state); +return -ENOMEM ; + } - stats->time_in_state = (ktime_t *)(stats +1 ); - stats->trans_table = (unsigned int *)(stats->time_in_state + states); - cdev->stats = stats; stats->last_time =ktime_get (); stats->max_states = states; +return 0 ; +} +static void cooling_device_stats_setup (struct thermal_cooling_device *cdev) +{ +struct cooling_dev_stats *stats; +int var, ret; + + stats =kzalloc (sizeof (*stats),GFP_KERNEL ); +if (!stats) +return ; + + cdev->stats = stats;spin_lock_init (&stats->lock); + ret =cooling_device_stats_resize (cdev); +if (ret) { +kfree (cdev->stats); + cdev->stats =NULL ; +return ; + } +/* Fill the empty slot left in cooling_device_attr_groups */ var =ARRAY_SIZE (cooling_device_attr_groups) -2 ; cooling_device_attr_groups[var] = &cooling_device_stats_attr_group;
@@ -938,6 +960,12 @@ static void cooling_device_stats_setup(struct thermal_cooling_device *cdev)static void cooling_device_stats_destroy (struct thermal_cooling_device *cdev) { +struct cooling_dev_stats *stats = cdev->stats; + +if (!stats) +return ; +kfree (stats->time_in_state); +kfree (stats->trans_table);kfree (cdev->stats); cdev->stats =NULL ; }
Signature · 1 line
2.17.1
Zhang Rui
reviewerRFC PATCH 3/5 thermal: support statistics table resizing at runtime
In reply to Zhang RuiIntroduce thermal_cdev_stats_update_max() which can be used to update the cooling device statistics table when maximum cooling state of a cooling device is changed.
--- drivers/thermal/thermal_sysfs.c | 65 ++++++++++++++++++++++++++------- include/linux/thermal.h | 7 ++++ 2 files changed, 58 insertions(+), 14 deletions(-)
drivers/thermal/thermal_sysfs.c +51 -14
@@ -745,6 +745,10 @@ static const struct attribute_group *cooling_device_attr_groups[] = { }; #ifdef CONFIG_THERMAL_STATISTICS +static int cooling_device_stats_resize(struct thermal_cooling_device *cdev, + unsigned long cur_state, + unsigned long max_state); + struct cooling_dev_stats { spinlock_t lock; unsigned int total_trans;
@@ -787,6 +791,23 @@ void thermal_cdev_stats_update_cur(struct thermal_cooling_device *cdev,spin_unlock (&stats->lock); } +void thermal_cdev_stats_update_max (struct thermal_cooling_device *cdev) +{ +struct cooling_dev_stats *stats = cdev->stats; +unsigned long cur_state, max_state; + +if (!stats) +return ; + +if (cdev->ops->get_max_state (cdev, &max_state)) +return ; + +if (cdev->ops->get_cur_state (cdev, &cur_state)) +return ; + +cooling_device_stats_resize (cdev, cur_state, max_state); +} +static ssize_t total_trans_show (struct device *dev,struct device_attribute *attr,char *buf) {
@@ -907,36 +928,44 @@ static const struct attribute_group cooling_device_stats_attr_group = { .name = "stats" }; -static int cooling_device_stats_resize (struct thermal_cooling_device *cdev) +static int cooling_device_stats_resize (struct thermal_cooling_device *cdev, +unsigned long cur_state, +unsigned long max_state) {struct cooling_dev_stats *stats = cdev->stats; -unsigned long states; -int ret; - - ret = cdev->ops->get_max_state (cdev, &states); -if (ret) -return ret; +unsigned long states = max_state +1 ; +void *time_in_state, *trans_table; - states++;/* Total number of states is highest state + 1 */ +if (stats->max_states == states) +return 0 ; - stats->time_in_state =kcalloc (states,sizeof (*stats->time_in_state),GFP_KERNEL ); -if (!stats->time_in_state) + time_in_state =kcalloc (states,sizeof (*stats->time_in_state),GFP_KERNEL ); +if (!time_in_state)return -ENOMEM ; - stats->trans_table =kcalloc (states,sizeof (*stats->trans_table) * states,GFP_KERNEL ); -if (!stats->trans_table) { -kfree (stats->time_in_state); + trans_table =kcalloc (states,sizeof (*stats->trans_table) * states,GFP_KERNEL ); +if (!trans_table) { +kfree (time_in_state);return -ENOMEM ; } +spin_lock (&stats->lock); +kfree (stats->time_in_state); +kfree (stats->trans_table); + stats->time_in_state = time_in_state; + stats->trans_table = trans_table; stats->last_time =ktime_get (); stats->max_states = states; + stats->state = cur_state; + stats->total_trans =0 ; +spin_unlock (&stats->lock);return 0 ; }static void cooling_device_stats_setup (struct thermal_cooling_device *cdev) {struct cooling_dev_stats *stats; +unsigned long max_state;int var, ret; stats =kzalloc (sizeof (*stats),GFP_KERNEL );
@@ -946,7 +975,15 @@ static void cooling_device_stats_setup(struct thermal_cooling_device *cdev) cdev->stats = stats;spin_lock_init (&stats->lock); - ret =cooling_device_stats_resize (cdev); + ret = cdev->ops->get_max_state (cdev, &max_state); +if (ret) +return ; + +/** +* cooling device current state will be updated soon +* during registration +**/ + ret =cooling_device_stats_resize (cdev,0 , max_state);if (ret) {kfree (cdev->stats); cdev->stats =NULL ;
include/linux/thermal.h +7 -0
@@ -533,4 +533,11 @@ static inline void thermal_notify_framework(struct thermal_zone_device *tz, { }#endif /* CONFIG_THERMAL */ +#ifdef CONFIG_THERMAL_STATISTICS +void thermal_cdev_stats_update_max (struct thermal_cooling_device *cdev); +#else +static inline void +thermal_cdev_stats_update_max (struct thermal_cooling_device *cdev) {} +#endif /* CONFIG_THERMAL_STATISTICS */ +#endif /* __THERMAL_H__ */
Signature · 1 line
2.17.1
Re: [RFC PATCH 3/5] thermal: support statistics table resizing at runtime
Quoted 6 lines · Zhang Rui
Introduce
thermal_cdev_stats_update_max()which can be used to update the cooling device statistics table when maximum cooling state of a cooling device is changed.Signed-off-by Zhang Rui <[email protected]>
Just a couple of small nitpicking:
Quoted 10 lines
drivers/thermal/thermal_sysfs.c +6
-0@@ -787,6 +791,23 @@ void thermal_cdev_stats_update_cur(struct thermal_cooling_device *cdev,spin_unlock (&stats->lock); } +void thermal_cdev_stats_update_max (struct thermal_cooling_device *cdev) +{ +struct cooling_dev_stats *stats = cdev->stats; +unsigned long cur_state, max_state; + +if (!stats)
drivers/thermal/thermal_sysfs.c void thermal_cdev_stats_update_cur(struct thermal_cooling_device *cdev, · line 809
Quoted 10 lines
drivers/thermal/thermal_sysfs.c +10
-0+return ; + +if (cdev->ops->get_max_state (cdev, &max_state)) +return ; + +if (cdev->ops->get_cur_state (cdev, &cur_state)) +return ; + +cooling_device_stats_resize (cdev, cur_state, max_state); +}
Don't we need to export this?
drivers/thermal/thermal_sysfs.c static void cooling_device_stats_setup(struct thermal_cooling_device *cdev) · line 985
Quoted 13 lines
drivers/thermal/thermal_sysfs.c +8
-1@@ -946,7 +975,15 @@ static void cooling_device_stats_setup(struct thermal_cooling_device *cdev) cdev->stats = stats;spin_lock_init (&stats->lock); - ret =cooling_device_stats_resize (cdev); + ret = cdev->ops->get_max_state (cdev, &max_state); +if (ret) +return ; + +/** +* cooling device current state will be updated soon +* during registration +**/
This comment style is confusing as if a kernel-doc.
thanks,
Takashi
Zhang Rui
reviewerRe: [RFC PATCH 3/5] thermal: support statistics table resizing at runtime
Quoted 28 lines · Takashi Iwai
Quoted 7 lines · Zhang Rui
Introduce
thermal_cdev_stats_update_max()which can be used to update
the cooling device statistics table when maximum cooling state of a cooling device is changed.Signed-off-by Zhang Rui <[email protected]>Just a couple of small nitpicking:
Quoted 16 lines
drivers/thermal/thermal_sysfs.c +10
-0@@ -787,6 +791,23 @@ void thermal_cdev_stats_update_cur(struct thermal_cooling_device *cdev,spin_unlock (&stats->lock); } +void thermal_cdev_stats_update_max (struct thermal_cooling_device *cdev) +{ +struct cooling_dev_stats *stats = cdev->stats; +unsigned long cur_state, max_state; + +if (!stats) +return ; + +if (cdev->ops->get_max_state (cdev, &max_state)) +return ;
Quoted 8 lines
drivers/thermal/thermal_sysfs.c void thermal_cdev_stats_update_cur(struct thermal_cooling_device *cdev, · line 809
Quoted 6 lines
drivers/thermal/thermal_sysfs.c +6
-0+ +if (cdev->ops->get_cur_state (cdev, &cur_state)) +return ; + +cooling_device_stats_resize (cdev, cur_state, max_state); +}Don't we need to export this?
Oh, right, will fix this.
Quoted 6 lines
Quoted 6 lines
drivers/thermal/thermal_sysfs.c +0
-0@@ -946,7 +975,15 @@ static void cooling_device_stats_setup(struct thermal_cooling_device *cdev) cdev->stats = stats;spin_lock_init (&stats->lock);
Quoted 12 lines
drivers/thermal/thermal_sysfs.c static void cooling_device_stats_setup(struct thermal_cooling_device *cdev) · line 985
Quoted 9 lines
drivers/thermal/thermal_sysfs.c +8
-1- ret =cooling_device_stats_resize (cdev); + ret = cdev->ops->get_max_state (cdev, &max_state); +if (ret) +return ; + +/** +* cooling device current state will be updated soon +* during registration +**/ This comment style is confusing as if a kernel-doc.
will fix it in next version.
thanks,
rui
Quoted 4 lines
thanks,
Takashi
Zhang Rui
reviewerRFC PATCH 4/5 thermal: Add a sanity check for invalid state at stats update
In reply to Zhang RuiFrom: Takashi Iwai <[email protected]>
This is from the origin changelog
"The thermal sysfs handler keeps the statistics table with the fixed size that was determined from the initial max_states() call, and the table entry is updated at each sysfs cur_state write call. And, when the driver's set_cur_state() ops accepts the value given from user-space, the thermal sysfs core blindly applies it to the statistics table entry, which may overflow and cause an Oops. Although it's rather a bug in the driver's ops implementations, we shouldn't crash but rather give a proper warning instead.
This patch adds a sanity check for avoiding such an OOB access and warns with a stack trace to show the suspicious device in question."
Part of the problem described above is gone, but I'd like to keep this patch so that we can detect the other max_state changes from other drivers, and fix the drivers by invoking thermal_cdev_stats_update_max() when necessary.
--- drivers/thermal/thermal_sysfs.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/thermal/thermal_sysfs.c +5 -0
@@ -779,6 +779,11 @@ void thermal_cdev_stats_update_cur(struct thermal_cooling_device *cdev,spin_lock (&stats->lock); +if (dev_WARN_ONCE (&cdev->device, new_state >= stats->max_states, +"new state %ld exceeds max_state %ld" , + new_state, stats->max_states)) + goto unlock; +if (stats->state == new_state) goto unlock;
Signature · 1 line
2.17.1
Zhang Rui
reviewerRFC PATCH 5/5 ACPI: processor: do update when maximum cooling state changed
In reply to Zhang RuiACPI processor cooling device supports 1 cooling state before cpufreq driver probed, and 4 cooling states after cpufreq driver probed. Thus update the statistics table when the cpufeq driver is probed/unprobed.
This fixes an OOB issue when updating the statistics of the processor cooling device.
--- drivers/acpi/processor_thermal.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/acpi/processor_thermal.c +2 -0
@@ -142,6 +142,7 @@ void acpi_thermal_cpufreq_init(struct cpufreq_policy *policy)if (ret <0 )pr_err ("Failed to add freq constraint for CPU%d (%d)\n" , cpu, ret); +thermal_cdev_stats_update_max (pr->cdev); } }
@@ -154,6 +155,7 @@ void acpi_thermal_cpufreq_exit(struct cpufreq_policy *policy)if (pr)freq_qos_remove_request (&pr->thermal_req); + thermal_cdev_stats_update_max(pr->cdev); } }#else /* ! CONFIG_CPU_FREQ */
Signature · 1 line
2.17.1
Re: [RFC PATCH 5/5] ACPI: processor: do update when maximum cooling state changed
Hi Rui,
Quoted 2 lines · Zhang Rui
ACPI processor cooling device supports 1 cooling state before cpufreq driver probed, and 4 cooling states after cpufreq driver probed.
What is this one state ?
Quoted 2 lines
Thus update the statistics table when the cpufeq driver is probed/unprobed.
To be honest, the series seems to skirt a problem in the acpi processor.
If there is a new policy, then there is a new cooling device. Why not unregister the old one and register the new one ?
Quoted 31 lines
This fixes an OOB issue when updating the statistics of the processor cooling device.
Fixes 8ea229511e06 ("thermal: Add cooling device's statistics in sysfs")Reported-by Takashi Iwai <[email protected]>Signed-off-by Zhang Rui <[email protected]>--- drivers/acpi/processor_thermal.c | 2 ++ 1 file changed, 2 insertions(+)drivers/acpi/processor_thermal.c +2
-0@@ -142,6 +142,7 @@ void acpi_thermal_cpufreq_init(struct cpufreq_policy *policy)if (ret <0 )pr_err ("Failed to add freq constraint for CPU%d (%d)\n" , cpu, ret); +thermal_cdev_stats_update_max (pr->cdev); } }@@ -154,6 +155,7 @@ void acpi_thermal_cpufreq_exit(struct cpufreq_policy *policy)if (pr)freq_qos_remove_request (&pr->thermal_req); + thermal_cdev_stats_update_max(pr->cdev); } }#else /* ! CONFIG_CPU_FREQ */
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Zhang Rui
reviewerRe: [RFC PATCH 5/5] ACPI: processor: do update when maximum cooling state changed
Quoted 9 lines · Daniel Lezcano
Hi Rui,
Quoted 3 lines · Zhang Rui
ACPI processor cooling device supports 1 cooling state before cpufreq
driver probed, and 4 cooling states after cpufreq driver probed.What is this one state ?
One state means its original state and we can not set it to others.
ACPI processor cooling states are combined of p-state cooling states and a couple of optional t-state cooling states.
Say, if we have a processor device supports 7 throttling states, it actually supports 8 cooling states with cpufreq driver unprobed, and 11 cooling states with cpufreq driver probed.
Quoted 10 lines
Quoted 3 lines
Thus update the statistics table when the cpufeq driver is probed/unprobed.
To be honest, the series seems to skirt a problem in the acpi processor.
If there is a new policy, then there is a new cooling device. Why not unregister the old one and register the new one ?
Good point.
IMO, the real problem is that do we support dynamic max_cooling_state or not in the thermal framework.
Previously, I thought we don't have a hard rule of static max_cooling_state because we always invoke .get_max_state() callback when we need it. But after a second thought, actually we do have this limitation. For example, when binding cooling devices to thermal zones, the upper limit is set based on the return value of .get_max_state() at the binding time, and we never update the upper limit later. So this ACPI processor issue is not just about statistics table update issue, we actually lose some of its cooling states.
Thus, a new max_state means that all the previous setting of the cooling_device, i.e. all the thermal instances of the cooling device, needs to get updated.
And to fix this, it's better to
a. unregister and re-register the cooling device as you suggested. or
b. introduce an API that updates the cooling device entirely instead of statistics table only.
For either of the above solutions, we'd better to cleanup the code to invoke .get_max_state() during registration/max_state_reset phase, once, and then always use cached value later.
And plus, if we want to follow solution a), it's better to remove .get_max_state() callback and use an integer instead so that every driver knows this limitation.
I'd vote for solution a) if there is no soc thermal driver that may return dynamic max_states.
Do I still miss something?
thanks,
rui
Quoted 40 lines
Quoted 38 lines
This fixes an OOB issue when updating the statistics of the processor
cooling device.Fixes 8ea229511e06 ("thermal: Add cooling device's statistics insysfs")
Reported-by Takashi Iwai <[email protected]>Signed-off-by Zhang Rui <[email protected]>--- drivers/acpi/processor_thermal.c | 2 ++ 1 file changed, 2 insertions(+)drivers/acpi/processor_thermal.c +1
-0@@ -142,6 +142,7 @@ void acpi_thermal_cpufreq_init(struct cpufreq_policy *policy)if (ret <0 )pr_err ("Failed to add freq constraint for CPU%d (%d)\n", cpu, ret); +thermal_cdev_stats_update_max (pr->cdev); }}
drivers/acpi/processor_thermal.c +1
-0@@ -154,6 +155,7 @@ void acpi_thermal_cpufreq_exit(struct cpufreq_policy *policy)if (pr)freq_qos_remove_request (&pr->thermal_req); +thermal_cdev_stats_update_max (pr->cdev); } }#else /* !
CONFIG_CPU_FREQ*/
Re: [RFC PATCH 5/5] ACPI: processor: do update when maximum cooling state changed
Quoted 61 lines · Zhang Rui
Quoted 9 lines · Daniel Lezcano
Hi Rui,
Quoted 3 lines · Zhang Rui
ACPI processor cooling device supports 1 cooling state before cpufreq
driver probed, and 4 cooling states after cpufreq driver probed.What is this one state ?
One state means its original state and we can not set it to others.
ACPI processor cooling states are combined of p-state cooling states and a couple of optional t-state cooling states.
Say, if we have a processor device supports 7 throttling states, it actually supports 8 cooling states with cpufreq driver unprobed, and 11 cooling states with cpufreq driver probed.
Quoted 10 lines
Quoted 3 lines
Thus update the statistics table when the cpufeq driver is probed/unprobed.
To be honest, the series seems to skirt a problem in the acpi processor.
If there is a new policy, then there is a new cooling device. Why not unregister the old one and register the new one ?
Good point.
IMO, the real problem is that do we support dynamicmax_cooling_stateor not in the thermal framework.
Previously, I thought we don't have a hard rule of staticmax_cooling_statebecause we always invoke .get_max_state() callback when we need it. But after a second thought, actually we do have this limitation. For example, when binding cooling devices to thermal zones, the upper limit is set based on the return value of .get_max_state() at the binding time, and we never update the upper limit later. So this ACPI processor issue is not just about statistics table update issue, we actually lose some of its cooling states.Thus, a new
max_statemeans that all the previous setting of thecooling_device, i.e. all the thermal instances of the cooling device, needs to get updated.And to fix this, it's better to
a. unregister and re-register the cooling device as you suggested. or
b. introduce an API that updates the cooling device entirely instead of statistics table only.For either of the above solutions, we'd better to cleanup the code to invoke .get_max_state() during registration/max_state_reset phase, once, and then always use cached value later.
And plus, if we want to follow solution a), it's better to remove .get_max_state() callback and use an integer instead so that every driver knows this limitation.
I'd vote for solution a) if there is no soc thermal driver that may return dynamicmax_states.
Quoted 1 line
Do I still miss something?
I agree for the a) solution too.
But regarding the get_max_state() callback being converted to a integer, the driver int3406_thermal.c computes the upper and lower limits which are updated on a INT3406_BRIGHTNESS_LIMITS_CHANGED notification and get_max_state() does uppper - lower.
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Zhang Rui
reviewerRe: [RFC PATCH 5/5] ACPI: processor: do update when maximum cooling state changed
Quoted 78 lines · Daniel Lezcano
Quoted 75 lines · Zhang Rui
Quoted 10 lines · Daniel Lezcano
Hi Rui,
Quoted 4 lines · Zhang Rui
ACPI processor cooling device supports 1 cooling state before cpufreq
driver probed, and 4 cooling states after cpufreq driver probed.What is this one state ?
One state means its original state and we can not set it to others.
ACPI processor cooling states are combined of p-state cooling states
and a couple of optional t-state cooling states.Say, if we have a processor device supports 7 throttling states, it actually supports 8 cooling states with cpufreq driver unprobed, and 11
cooling states with cpufreq driver probed.Quoted 11 lines
Quoted 3 lines
Thus update the statistics table when the cpufeq driver is probed/unprobed.
To be honest, the series seems to skirt a problem in the acpi processor.
If there is a new policy, then there is a new cooling device. Why not
unregister the old one and register the new one ?Good point.
IMO, the real problem is that do we support dynamicmax_cooling_state
or not in the thermal framework.
Previously, I thought we don't have a hard rule of staticmax_cooling_statebecause we always invoke .get_max_state() callback
when we need it. But after a second thought, actually we do have this
limitation. For example, when binding cooling devices to thermal zones,
the upper limit is set based on the return value of .get_max_state() at
the binding time, and we never update the upper limit later. So this ACPI processor issue is not just about statistics table update
issue, we actually lose some of its cooling states.Thus, a new
max_statemeans that all the previous setting of thecooling_device, i.e. all the thermal instances of the cooling device,
needs to get updated.And to fix this, it's better to
a. unregister and re-register the cooling device as you suggested. or
b. introduce an API that updates the cooling device entirely instead of
statistics table only.For either of the above solutions, we'd better to cleanup the code to
invoke .get_max_state() during registration/max_state_reset phase, once, and then always use cached value later.
And plus, if we want to follow solution a), it's better to remove .get_max_state() callback and use an integer instead so that every driver knows this limitation.
I'd vote for solution a) if there is no soc thermal driver that may return dynamicmax_states.Quoted 1 line
Do I still miss something?
Quoted 8 lines
I agree for the a) solution too.
But regarding the
get_max_state()callback being converted to a integer,
the driverint3406_thermal.ccomputes the upper and lower limits which
are updated on aINT3406_BRIGHTNESS_LIMITS_CHANGEDnotification andget_max_state()does uppper - lower.
Right, this is another case shows that it's better to support dynamic max_state.
IMO, this is not difficult to do. We just need to introduce a new API, which reuses the current cdev device, and reset its every thermal instance, and update all the thermal zones the cdev is involved. what do you think?
thanks,
rui
Re: [RFC PATCH 5/5] ACPI: processor: do update when maximum cooling state changed
Hi Rui,
Quoted 1 line · Zhang Rui
On Fri, 2020-04-10 at 14:10 +0200, Daniel Lezcano wrote:
[ ... ]
Quoted 28 lines
Quoted 19 lines
Quoted 17 lines
And to fix this, it's better to
a. unregister and re-register the cooling device as you suggested. or
b. introduce an API that updates the cooling device entirely instead of
statistics table only.For either of the above solutions, we'd better to cleanup the code to
invoke .get_max_state() during registration/max_state_reset phase, once, and then always use cached value later.
And plus, if we want to follow solution a), it's better to remove .get_max_state() callback and use an integer instead so that every driver knows this limitation.
I'd vote for solution a) if there is no soc thermal driver that may return dynamicmax_states.Quoted 1 line
Do I still miss something?
Quoted 8 lines
I agree for the a) solution too.
But regarding the
get_max_state()callback being converted to a integer,
the driverint3406_thermal.ccomputes the upper and lower limits which
are updated on aINT3406_BRIGHTNESS_LIMITS_CHANGEDnotification andget_max_state()does uppper - lower.
Quoted 6 lines
Right, this is another case shows that it's better to support dynamic
max_state.
IMO, this is not difficult to do. We just need to introduce a new API, which reuses the current cdev device, and reset its every thermal instance, and update all the thermal zones the cdev is involved. what do you think?
I like how the thermal framework is designed but I think there are too many API for the thermal framework and it deserves a simplification rather than adding more of them.
There is no place where the get_max_state is cached except in the stats structure.
In the function thermal_cooling_device_stats_update():
Is it possible to just compare the 'new_state' parameter withstats->max_state and if it is greater increase the stats table and update max_state to the new_state ?
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Zhang Rui
reviewerRe: [RFC PATCH 5/5] ACPI: processor: do update when maximum cooling state changed
Quoted 55 lines · Daniel Lezcano
Hi Rui,
Quoted 1 line · Zhang Rui
On Fri, 2020-04-10 at 14:10 +0200, Daniel Lezcano wrote:
[ ... ]
Quoted 35 lines
Quoted 27 lines
Quoted 23 lines
And to fix this, it's better to
a. unregister and re-register the cooling device as you suggested.
or
b. introduce an API that updates the cooling device entirely instead of
statistics table only.For either of the above solutions, we'd better to cleanup the code
to
invoke .get_max_state() during registration/max_state_reset phase,
once, and then always use cached value later.
And plus, if we want to follow solution a), it's better to remove
.get_max_state() callback and use an integer instead so that every
driver knows this limitation.
I'd vote for solution a) if there is no soc thermal driver that may
return dynamicmax_states.Quoted 1 line
Do I still miss something?
I agree for the a) solution too.
Quoted 7 lines
But regarding the
get_max_state()callback being converted to a integer,
the driverint3406_thermal.ccomputes the upper and lower limits which
are updated on aINT3406_BRIGHTNESS_LIMITS_CHANGEDnotification andget_max_state()does uppper - lower.Quoted 8 lines
Right, this is another case shows that it's better to support dynamic
max_state.
IMO, this is not difficult to do. We just need to introduce a new API,
which reuses the current cdev device, and reset its every thermal instance, and update all the thermal zones the cdev is involved. what do you think?
Quoted 4 lines
I like how the thermal framework is designed but I think there are too
many API for the thermal framework and it deserves a simplification rather than adding more of them.
I agree.
Quoted 4 lines
There is no place where the
get_max_stateis cached except in the stats
structure.
why we can not have a cdev->max_state field, and get it updated right after .get_max_state().
and .get_max_state() is only invoked
a) during cooling device registration
b) when cooling device update its max_state via the new API.
Quoted 7 lines
In the function
thermal_cooling_device_stats_update():Is it possible to just compare the '
new_state' parameter withstats->max_stateand if it is greater increase the stats table and updatemax_stateto thenew_state?
the problem is that thermal_cooling_device_stats_update() is invoked only if thermal zone are updated or the cur_state sysfs attribute is changed.
There is no way for a cooling device driver to tell thermal framework that it has changed.
Say, for the problem on hand, the statistics table will not be updated in time when cpufreq driver probed.
thanks,
rui
Re: [RFC PATCH 5/5] ACPI: processor: do update when maximum cooling state changed
Quoted 1 line · Zhang Rui
On Sun, 2020-04-12 at 12:07 +0200, Daniel Lezcano wrote:
[ ... ]
Quoted 13 lines
why we can not have a
cdev->max_statefield, and get it updated right after .get_max_state().
and .get_max_state() is only invoked
a) during cooling device registration
b) when cooling device update itsmax_statevia the new API.Quoted 7 lines
In the function
thermal_cooling_device_stats_update():Is it possible to just compare the '
new_state' parameter withstats->max_stateand if it is greater increase the stats table and updatemax_stateto thenew_state?
Quoted 7 lines
the problem is that
thermal_cooling_device_stats_update()is invoked only if thermal zone are updated or thecur_statesysfs attribute is changed.
There is no way for a cooling device driver to tell thermal framework that it has changed.
Say, for the problem on hand, the statistics table will not be updated in time when cpufreq driver probed.
Except I'm missing something, the statistics are only read from userspace via sysfs.
userspace is not notified about a stat change. Is it really a problem the table is not updated right at the probe time ? Does it really matter if the user sees the old table until an update happens on a new higher max state ?
The table is always consistent whenever the userspace reads the content.
A new entry will appear only if it is used, no?
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Zhang Rui
reviewerRe: [RFC PATCH 5/5] ACPI: processor: do update when maximum cooling state changed
Quoted 33 lines · Daniel Lezcano
Quoted 1 line · Zhang Rui
On Sun, 2020-04-12 at 12:07 +0200, Daniel Lezcano wrote:
[ ... ]
Quoted 16 lines
why we can not have a
cdev->max_statefield, and get it updated right
after .get_max_state().
and .get_max_state() is only invoked
a) during cooling device registration
b) when cooling device update itsmax_statevia the new API.Quoted 8 lines
In the function
thermal_cooling_device_stats_update():Is it possible to just compare the '
new_state' parameter withstats->max_stateand if it is greater increase the stats table and
updatemax_stateto thenew_state?Quoted 11 lines
the problem is that
thermal_cooling_device_stats_update()is invoked
only if thermal zone are updated or thecur_statesysfs attribute is
changed.
There is no way for a cooling device driver to tell thermal framework
that it has changed.
Say, for the problem on hand, the statistics table will not be updated
in time when cpufreq driver probed.
Quoted 2 lines
Except I'm missing something, the statistics are only read from userspace via sysfs.
I agree.
Quoted 9 lines
userspace is not notified about a stat change. Is it really a problem the table is not updated right at the probe time ?
Does it really matter
if the user sees the old table until an update happens on a new higher
max state ?
Quoted 6 lines
The table is always consistent whenever the userspace reads the content.
A new entry will appear only if it is used, no?
Hmm, IMO, stats table is not the biggest problem here.
The problem is that thermal framework is not aware of the max_state change, and the thermal instances are never updated according to the new max_state.
So, we should invoke .get_max_state() in thermal_zone_device_update() and update the thermal instances accordingly.
And then, what we need to do is just to do stats update right after .get_max_state() being invoked.
About how to update the stats table, I think adding new entries is not enough, because the meaning of each cooling state may change when max_state changes, thus I'd prefer a full reset/resizing of the table.
thanks,
rui
Quoted 5 lines
Re: [RFC PATCH 5/5] ACPI: processor: do update when maximum cooling state changed
Quoted 62 lines · Zhang Rui
Quoted 33 lines · Daniel Lezcano
Quoted 1 line · Zhang Rui
On Sun, 2020-04-12 at 12:07 +0200, Daniel Lezcano wrote:
[ ... ]
Quoted 16 lines
why we can not have a
cdev->max_statefield, and get it updated right
after .get_max_state().
and .get_max_state() is only invoked
a) during cooling device registration
b) when cooling device update itsmax_statevia the new API.Quoted 8 lines
In the function
thermal_cooling_device_stats_update():Is it possible to just compare the '
new_state' parameter withstats->max_stateand if it is greater increase the stats table and
updatemax_stateto thenew_state?Quoted 11 lines
the problem is that
thermal_cooling_device_stats_update()is invoked
only if thermal zone are updated or thecur_statesysfs attribute is
changed.
There is no way for a cooling device driver to tell thermal framework
that it has changed.
Say, for the problem on hand, the statistics table will not be updated
in time when cpufreq driver probed.Quoted 2 lines
Except I'm missing something, the statistics are only read from userspace via sysfs.
I agree.
Quoted 9 lines
userspace is not notified about a stat change. Is it really a problem the table is not updated right at the probe time ?
Does it really matter
if the user sees the old table until an update happens on a new higher
max state ?Quoted 6 lines
The table is always consistent whenever the userspace reads the content.
A new entry will appear only if it is used, no?
Hmm, IMO, stats table is not the biggest problem here.
The problem is that thermal framework is not aware of themax_statechange, and the thermal instances are never updated according to the newmax_state.
So, we should invoke .get_max_state() inthermal_zone_device_update()and update the thermal instances accordingly.
And then, what we need to do is just to do stats update right after .get_max_state() being invoked.
Quoted 3 lines
About how to update the stats table, I think adding new entries is not enough, because the meaning of each cooling state may change when
max_statechanges, thus I'd prefer a full reset/resizing of the table.
Ok, I understand. Are planning to use the existing API:
thermal_zone_device_update(tz, THERMAL_TABLE_CHANGED);
?
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Zhang Rui
reviewerRe: [RFC PATCH 5/5] ACPI: processor: do update when maximum cooling state changed
Quoted 74 lines · Daniel Lezcano
Quoted 67 lines · Zhang Rui
Quoted 36 lines · Daniel Lezcano
Quoted 1 line · Zhang Rui
On Sun, 2020-04-12 at 12:07 +0200, Daniel Lezcano wrote:
[ ... ]
Quoted 18 lines
why we can not have a
cdev->max_statefield, and get it updated right
after .get_max_state().
and .get_max_state() is only invoked
a) during cooling device registration
b) when cooling device update itsmax_statevia the new API.Quoted 10 lines
In the function
thermal_cooling_device_stats_update():Is it possible to just compare the '
new_state' parameter
withstats->max_stateand if it is greater increase the stats table
and
updatemax_stateto thenew_state?Quoted 12 lines
the problem is that
thermal_cooling_device_stats_update()is invoked
only if thermal zone are updated or thecur_statesysfs attribute
is
changed.
There is no way for a cooling device driver to tell thermal framework
that it has changed.
Say, for the problem on hand, the statistics table will not be updated
in time when cpufreq driver probed.Quoted 2 lines
Except I'm missing something, the statistics are only read from userspace via sysfs.
I agree.
Quoted 9 lines
userspace is not notified about a stat change. Is it really a problem
the table is not updated right at the probe time ?
Does it really matter
if the user sees the old table until an update happens on a new higher
max state ?Quoted 5 lines
The table is always consistent whenever the userspace reads the content.
A new entry will appear only if it is used, no?
Hmm, IMO, stats table is not the biggest problem here. The problem is that thermal framework is not aware of the
max_statechange, and the thermal instances are never updated according to the
newmax_state.
So, we should invoke .get_max_state() inthermal_zone_device_update()
and update the thermal instances accordingly.
And then, what we need to do is just to do stats update right after .get_max_state() being invoked.Quoted 5 lines
About how to update the stats table, I think adding new entries is not
enough, because the meaning of each cooling state may change whenmax_statechanges, thus I'd prefer a full reset/resizing of the table.
Quoted 3 lines
Ok, I understand. Are planning to use the existing API:
thermal_zone_device_update(tz, THERMAL_TABLE_CHANGED);
we can not use THERMAL_TABLE_CHANGED because cooling device driver can not invoke thermal_zone_device_update().
So, the cooling device max_state is changed, but the thermal framework will not know this until the cooling device being used for a temperature change.
For the cooling devices that are not used by any thermal zones, the stats files are probably out of date, but maybe nobody cares. Or we can fix this by updating stats table for every stats sysfs attribute access.
thanks,
rui
Rafael J. Wysocki
maintainerRe: [RFC PATCH 5/5] ACPI: processor: do update when maximum cooling state changed
In reply to Zhang RuiQuoted 53 lines · Zhang Rui
Quoted 9 lines · Daniel Lezcano
Hi Rui,
Quoted 3 lines · Zhang Rui
ACPI processor cooling device supports 1 cooling state before cpufreq
driver probed, and 4 cooling states after cpufreq driver probed.What is this one state ?
One state means its original state and we can not set it to others.
ACPI processor cooling states are combined of p-state cooling states and a couple of optional t-state cooling states.
Say, if we have a processor device supports 7 throttling states, it actually supports 8 cooling states with cpufreq driver unprobed, and 11 cooling states with cpufreq driver probed.
Quoted 10 lines
Quoted 3 lines
Thus update the statistics table when the cpufeq driver is probed/unprobed.
To be honest, the series seems to skirt a problem in the acpi processor.
If there is a new policy, then there is a new cooling device. Why not unregister the old one and register the new one ?
Good point.
IMO, the real problem is that do we support dynamicmax_cooling_stateor not in the thermal framework.
Previously, I thought we don't have a hard rule of staticmax_cooling_statebecause we always invoke .get_max_state() callback when we need it. But after a second thought, actually we do have this limitation. For example, when binding cooling devices to thermal zones, the upper limit is set based on the return value of .get_max_state() at the binding time, and we never update the upper limit later. So this ACPI processor issue is not just about statistics table update issue, we actually lose some of its cooling states.Thus, a new
max_statemeans that all the previous setting of thecooling_device, i.e. all the thermal instances of the cooling device, needs to get updated.And to fix this, it's better to
a. unregister and re-register the cooling device as you suggested. or
b. introduce an API that updates the cooling device entirely instead of statistics table only.
Quoted 8 lines
For either of the above solutions, we'd better to cleanup the code to invoke .get_max_state() during registration/max_state_reset phase, once, and then always use cached value later.
And plus, if we want to follow solution a), it's better to remove .get_max_state() callback and use an integer instead so that every driver knows this limitation.
I'd vote for solution a) if there is no soc thermal driver that may return dynamicmax_states.
I believe I mentioned one more option, which would be to introduce an optional callback into struct thermal_cooling_device_ops to return the maximum possible return value of .get_max_state(), say .get_max_state_limit(). That would be used for the allocation of the stats table and the drivers where the .get_max_state() return value could not change might set the new callback to NULL.
Then, upon a change of the .get_max_state() return value, the driver providing it would be responsible for rearranging the stats to reflect the new set of available states.
Cheers!
Zhang Rui
reviewerRe: [RFC PATCH 5/5] ACPI: processor: do update when maximum cooling state changed
Quoted 78 lines · Rafael J. Wysocki
Quoted 66 lines · Zhang Rui
Quoted 10 lines · Daniel Lezcano
Hi Rui,
Quoted 4 lines · Zhang Rui
ACPI processor cooling device supports 1 cooling state before cpufreq
driver probed, and 4 cooling states after cpufreq driver probed.What is this one state ?
One state means its original state and we can not set it to others.
ACPI processor cooling states are combined of p-state cooling states
and a couple of optional t-state cooling states.Say, if we have a processor device supports 7 throttling states, it actually supports 8 cooling states with cpufreq driver unprobed, and 11
cooling states with cpufreq driver probed.Quoted 11 lines
Quoted 3 lines
Thus update the statistics table when the cpufeq driver is probed/unprobed.
To be honest, the series seems to skirt a problem in the acpi processor.
If there is a new policy, then there is a new cooling device. Why not
unregister the old one and register the new one ?Good point.
IMO, the real problem is that do we support dynamicmax_cooling_state
or not in the thermal framework.
Previously, I thought we don't have a hard rule of staticmax_cooling_statebecause we always invoke .get_max_state() callback
when we need it. But after a second thought, actually we do have this
limitation. For example, when binding cooling devices to thermal zones,
the upper limit is set based on the return value of .get_max_state() at
the binding time, and we never update the upper limit later. So this ACPI processor issue is not just about statistics table update
issue, we actually lose some of its cooling states.Thus, a new
max_statemeans that all the previous setting of thecooling_device, i.e. all the thermal instances of the cooling device,
needs to get updated.And to fix this, it's better to
a. unregister and re-register the cooling device as you suggested. or
b. introduce an API that updates the cooling device entirely instead of
statistics table only.Quoted 9 lines
For either of the above solutions, we'd better to cleanup the code to
invoke .get_max_state() during registration/max_state_reset phase, once, and then always use cached value later.
And plus, if we want to follow solution a), it's better to remove .get_max_state() callback and use an integer instead so that every driver knows this limitation.
I'd vote for solution a) if there is no soc thermal driver that may return dynamicmax_states.
Quoted 8 lines
I believe I mentioned one more option, which would be to introduce an optional callback into struct
thermal_cooling_device_opsto return the
maximum possible return value of .get_max_state(), say .get_max_state_limit(). That would be used for the allocation of the stats table and the drivers where the .get_max_state() return value could not change might set the new callback to NULL.
For a dynamic max_state cooling device, now the problem is not just about the statistics table.
Take the ACPI processor cooling device for example, we set its internal limit based on the return value of .get_max_state() during the cooling device registration, thus if it returns 1, actually we can not use deep cooling state later at all.
Plus, when a max_state changed, the meaning of each cooling state may also actually changed. Say, for ACPI processor, cooling state 2 means 60% of max_freq with cpufreq driver, but means ACPI processor T2 throttle state with cpuferq driver unprobed.
That says, if we don't do a full unregistration and registration in this case, at least we need to keep the device node but re-evaluate .get_max_state() and update all its thermal instances, as long as the statistics table change.
thanks,
rui
Quoted 6 lines
Then, upon a change of the .get_max_state() return value, the driver providing it would be responsible for rearranging the stats to reflect
the new set of available states.Cheers!
kbuild test robot
build botRe: [RFC PATCH 5/5] ACPI: processor: do update when maximum cooling state changed
In reply to Zhang Rui[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please…
Hi Zhang,
[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on pm/linux-next]
[also build test WARNING on linus/master v5.7-rc1 next-20200413] [cannot apply to soc-thermal/next]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Zhang-Rui/thermal-rename-thermal_cooling_device_stats_update/20200408-122131 base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
If you fix the issue, kindly add following tag as appropriate
cppcheck warnings: (new ones prefixed by >>)
>> drivers/acpi/processor_thermal.c:158:33: warning: Either the condition 'if(pr)' is redundant or there is possible null pointer dereference: pr. [nullPointerRedundantCheck]
thermal_cdev_stats_update_max(pr->cdev);
^
drivers/acpi/processor_thermal.c:156:6: note: Assuming that condition 'if(pr)' is not redundant
if (pr)
^
drivers/acpi/processor_thermal.c:154:38: note: Assignment 'pr=per_cpu(processors,policy->cpu)', assigned value is 0
struct acpi_processor *pr = per_cpu(processors, policy->cpu);
^
drivers/acpi/processor_thermal.c:158:33: note: Null pointer dereference
thermal_cdev_stats_update_max(pr->cdev);
^vim +158 drivers/acpi/processor_thermal.c
148
149 void acpi_thermal_cpufreq_exit(struct cpufreq_policy *policy)
150 {
151 unsigned int cpu;
152
153 for_each_cpu(cpu, policy->related_cpus) {
154 struct acpi_processor *pr = per_cpu(processors, policy->cpu);
155
156 if (pr)
157 freq_qos_remove_request(&pr->thermal_req);
> 158 thermal_cdev_stats_update_max(pr->cdev);
159 }
160 }
161 #else /* ! CONFIG_CPU_FREQ */
162 static int cpufreq_get_max_state(unsigned int cpu)
163 {
164 return 0;
165 }
166
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Re: [RFC PATCH 5/5] ACPI: processor: do update when maximum cooling state changed
In reply to Zhang RuiHi Zhang,
url: https://github.com/0day-ci/linux/commits/Zhang-Rui/thermal-rename-thermal_cooling_device_stats_update/20200408-122131 base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
If you fix the issue, kindly add following tag as appropriate
smatch warnings:drivers/acpi/processor_thermal.c:158 acpi_thermal_cpufreq_exit() error: we previously assumed 'pr' could be null (see line 156)
# https://github.com/0day-ci/linux/commit/7d1c8f3879a36c7230c2842c651c4a3ce66b3d61
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout 7d1c8f3879a36c7230c2842c651c4a3ce66b3d61
vim +/pr +158 drivers/acpi/processor_thermal.c
3000ce3c52f8b8 Rafael J. Wysocki 2019-10-16 149 void acpi_thermal_cpufreq_exit(struct cpufreq_policy *policy)
4be44fcd3bf648 Len Brown 2005-08-05 150 {
a1bb46c36ce389 Rafael J. Wysocki 2019-10-25 151 unsigned int cpu;
a1bb46c36ce389 Rafael J. Wysocki 2019-10-25 152
a1bb46c36ce389 Rafael J. Wysocki 2019-10-25 153 for_each_cpu(cpu, policy->related_cpus) {
3000ce3c52f8b8 Rafael J. Wysocki 2019-10-16 154 struct acpi_processor *pr = per_cpu(processors, policy->cpu);
^1da177e4c3f41 Linus Torvalds 2005-04-16 155
2d8b39a62a5d38 Rafael J. Wysocki 2019-10-15 @156 if (pr)
^^Check
3000ce3c52f8b8 Rafael J. Wysocki 2019-10-16 157 freq_qos_remove_request(&pr->thermal_req);
7d1c8f3879a36c Zhang Rui 2020-04-08 @158 thermal_cdev_stats_update_max(pr->cdev);
^^^^^^^^Unchecked dereference.
^1da177e4c3f41 Linus Torvalds 2005-04-16 159 }
a1bb46c36ce389 Rafael J. Wysocki 2019-10-25 160 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 161 #else /* ! CONFIG_CPU_FREQ */
d9460fd227ed2c Zhang Rui 2008-01-17 162 static int cpufreq_get_max_state(unsigned int cpu)
d9460fd227ed2c Zhang Rui 2008-01-17 163 {
d9460fd227ed2c Zhang Rui 2008-01-17 164 return 0;
d9460fd227ed2c Zhang Rui 2008-01-17 165 }---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Quoted 5 lines · Zhang Rui
Rename
thermal_cooling_device_stats_update()tothermal_cdev_stats_update_cur()Signed-off-by Zhang Rui <[email protected]>
Thanks for the patch set! I did a quick test and it seems working fine. Also through a glance, the patches are good, just a few trivial issues as posted in another mail.
So, feel free to take my tags for the whole series:
Takashi
Zhang Rui
reviewerQuoted 8 lines · Takashi Iwai
Quoted 5 lines · Zhang Rui
Rename
thermal_cooling_device_stats_update()tothermal_cdev_stats_update_cur()Signed-off-by Zhang Rui <[email protected]>
Quoted 9 lines
Thanks for the patch set! I did a quick test and it seems working fine. Also through a glance, the patches are good, just a few trivial
issues as posted in another mail.So, feel free to take my tags for the whole series:
Tested-by Takashi Iwai <[email protected]>Reviewed-by Takashi Iwai <[email protected]>
Thanks for the test and review.
I will refresh the patch set with your comments addressed and also with the changelog of your patch rephrased.
thanks,
rui
Quoted 3 lines · Zhang Rui
Rename
thermal_cooling_device_stats_update()tothermal_cdev_stats_update_cur()
Missing a reason for this change.
Quoted 65 lines
Signed-off-by Zhang Rui <[email protected]>--- drivers/thermal/thermal_core.h | 4 ++-- drivers/thermal/thermal_helpers.c | 2 +- drivers/thermal/thermal_sysfs.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)drivers/thermal/thermal_core.h +2
-2@@ -81,11 +81,11 @@ ssize_t weight_store(struct device *, struct device_attribute *, const char *, size_t);#ifdef CONFIG_THERMAL_STATISTICS -void thermal_cooling_device_stats_update (struct thermal_cooling_device *cdev, +void thermal_cdev_stats_update_cur (struct thermal_cooling_device *cdev,unsigned long new_state);#else static inline void -thermal_cooling_device_stats_update (struct thermal_cooling_device *cdev, +thermal_cdev_stats_update_cur (struct thermal_cooling_device *cdev,unsigned long new_state) {}#endif /* CONFIG_THERMAL_STATISTICS */ drivers/thermal/thermal_helpers.c +1
-1@@ -186,7 +186,7 @@ void thermal_cdev_update(struct thermal_cooling_device *cdev) }if (!cdev->ops->set_cur_state (cdev, target)) -thermal_cooling_device_stats_update (cdev, target); +thermal_cdev_stats_update_cur (cdev, target); cdev->updated = true;mutex_unlock (&cdev->lock);drivers/thermal/thermal_sysfs.c +2
-3@@ -716,7 +716,7 @@ cur_state_store(struct device *dev, struct device_attribute *attr, result = cdev->ops->set_cur_state (cdev, state);if (!result) -thermal_cooling_device_stats_update (cdev, state); +thermal_cdev_stats_update_cur (cdev, state);mutex_unlock (&cdev->lock);return result ? result : count;@@ -765,7 +765,7 @@ static void update_time_in_state(struct cooling_dev_stats *stats) stats->last_time = now; } -void thermal_cooling_device_stats_update (struct thermal_cooling_device *cdev, +void thermal_cdev_stats_update_cur (struct thermal_cooling_device *cdev,unsigned long new_state) {struct cooling_dev_stats *stats = cdev->stats; --2.17.1