From: Di Shen <di.shen@unisoc.com>
To: <lukasz.luba@arm.com>, <rafael@kernel.org>
Cc: <daniel.lezcano@linaro.org>, <amitk@kernel.org>,
<rui.zhang@intel.com>, <linux-pm@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <xuewen.yan@unisoc.com>
Subject: [PATCH] thermal/core/power_allocator: avoid cdev->state can not be reset
Date: Thu, 9 Mar 2023 21:55:15 +0800 [thread overview]
Message-ID: <20230309135515.1232-1-di.shen@unisoc.com> (raw)
Commit 0952177f2a1f (thermal/core/power_allocator: Update once cooling devices when temp is low)
add a update flag to update cooling device only once when temp is low.
But when the switch_on_temp is set to be a higher value, the cooling device state
may not be reset to max, because the last_temp is smaller than the switch_on_temp.
For example:
First:
swicth_on_temp=70 control_temp=85;
Then userspace change the trip_temp:
swicth_on_temp=45 control_temp=55 cur_temp=54
Then userspace reset the trip_temp:
swicth_on_temp=70 control_temp=85 cur_temp=57 last_temp=54
At this time, the cooling device state should be reset to be max.
However, because cur_temp(57) < switch_on_temp(70)
last_temp(54) < swicth_on_temp(70) --> update = false
When update is false, the cooling device state can not be reset.
So delete the update condition, so that the cooling device state
could be reset.
Fixes: 0952177f2a1f (thermal/core/power_allocator: Update once cooling devices when temp is low)
Signed-off-by: Di Shen <di.shen@unisoc.com>
---
drivers/thermal/gov_power_allocator.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c
index 0eaf1527d3e3..153bf528b98c 100644
--- a/drivers/thermal/gov_power_allocator.c
+++ b/drivers/thermal/gov_power_allocator.c
@@ -560,7 +560,7 @@ static void reset_pid_controller(struct power_allocator_params *params)
params->prev_err = 0;
}
-static void allow_maximum_power(struct thermal_zone_device *tz, bool update)
+static void allow_maximum_power(struct thermal_zone_device *tz)
{
struct thermal_instance *instance;
struct power_allocator_params *params = tz->governor_data;
@@ -582,8 +582,7 @@ static void allow_maximum_power(struct thermal_zone_device *tz, bool update)
*/
cdev->ops->get_requested_power(cdev, &req_power);
- if (update)
- __thermal_cdev_update(instance->cdev);
+ __thermal_cdev_update(instance->cdev);
mutex_unlock(&instance->cdev->lock);
}
@@ -697,7 +696,6 @@ static int power_allocator_throttle(struct thermal_zone_device *tz, int trip_id)
struct power_allocator_params *params = tz->governor_data;
struct thermal_trip trip;
int ret;
- bool update;
lockdep_assert_held(&tz->lock);
@@ -710,10 +708,9 @@ static int power_allocator_throttle(struct thermal_zone_device *tz, int trip_id)
ret = __thermal_zone_get_trip(tz, params->trip_switch_on, &trip);
if (!ret && (tz->temperature < trip.temperature)) {
- update = (tz->last_temperature >= trip.temperature);
tz->passive = 0;
reset_pid_controller(params);
- allow_maximum_power(tz, update);
+ allow_maximum_power(tz);
return 0;
}
--
2.17.1
next reply other threads:[~2023-03-09 13:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-09 13:55 Di Shen [this message]
2023-03-10 7:31 ` [PATCH] thermal/core/power_allocator: avoid cdev->state can not be reset Di Shen
2023-03-10 15:13 ` Lukasz Luba
2023-03-13 1:40 ` Xuewen Yan
2023-03-13 9:35 ` Lukasz Luba
2023-03-13 11:10 ` Xuewen Yan
2023-03-13 11:18 ` Lukasz Luba
2023-03-14 2:41 ` Xuewen Yan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230309135515.1232-1-di.shen@unisoc.com \
--to=di.shen@unisoc.com \
--cc=amitk@kernel.org \
--cc=daniel.lezcano@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=rafael@kernel.org \
--cc=rui.zhang@intel.com \
--cc=xuewen.yan@unisoc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox