From: "thermal-bot for Daniel Lezcano" <tip-bot2@linutronix.de>
To: linux-pm@vger.kernel.org
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>,
Zhang Rui <rui.zhang@intel.com>,
Lukasz Luba <lukasz.luba@arm.com>,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
amitk@kernel.org
Subject: [thermal: thermal/next] thermal/core/governors: Use thermal_zone_get_trip() instead of ops functions
Date: Fri, 09 Dec 2022 15:26:36 -0000 [thread overview]
Message-ID: <167059959602.4906.4944440999955328252.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20221003092602.1323944-5-daniel.lezcano@linaro.org>
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: 598b0cbd91f5b2359c3abc2ac88f7ac03b86049c
Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//598b0cbd91f5b2359c3abc2ac88f7ac03b86049c
Author: Daniel Lezcano <daniel.lezcano@linaro.org>
AuthorDate: Mon, 03 Oct 2022 11:25:37 +02:00
Committer: Daniel Lezcano <daniel.lezcano@kernel.org>
CommitterDate: Thu, 08 Dec 2022 14:30:42 +01:00
thermal/core/governors: Use thermal_zone_get_trip() instead of ops functions
The governors are using the ops->get_trip_* functions, Replace these
calls with thermal_zone_get_trip().
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Zhang Rui <rui.zhang@intel.com>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com> # IPA
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://lore.kernel.org/r/20221003092602.1323944-5-daniel.lezcano@linaro.org
---
drivers/thermal/gov_bang_bang.c | 37 +++++++++++--------
drivers/thermal/gov_fair_share.c | 18 +++------
drivers/thermal/gov_power_allocator.c | 51 +++++++++++---------------
drivers/thermal/gov_step_wise.c | 22 +++++------
4 files changed, 61 insertions(+), 67 deletions(-)
diff --git a/drivers/thermal/gov_bang_bang.c b/drivers/thermal/gov_bang_bang.c
index a08bbe3..1b12106 100644
--- a/drivers/thermal/gov_bang_bang.c
+++ b/drivers/thermal/gov_bang_bang.c
@@ -13,26 +13,28 @@
#include "thermal_core.h"
-static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip)
+static int thermal_zone_trip_update(struct thermal_zone_device *tz, int trip_id)
{
- int trip_temp, trip_hyst;
+ struct thermal_trip trip;
struct thermal_instance *instance;
+ int ret;
- tz->ops->get_trip_temp(tz, trip, &trip_temp);
+ ret = __thermal_zone_get_trip(tz, trip_id, &trip);
+ if (ret) {
+ pr_warn_once("Failed to retrieve trip point %d\n", trip_id);
+ return ret;
+ }
- if (!tz->ops->get_trip_hyst) {
- pr_warn_once("Undefined get_trip_hyst for thermal zone %s - "
- "running with default hysteresis zero\n", tz->type);
- trip_hyst = 0;
- } else
- tz->ops->get_trip_hyst(tz, trip, &trip_hyst);
+ if (!trip.hysteresis)
+ dev_info_once(&tz->device,
+ "Zero hysteresis value for thermal zone %s\n", tz->type);
dev_dbg(&tz->device, "Trip%d[temp=%d]:temp=%d:hyst=%d\n",
- trip, trip_temp, tz->temperature,
- trip_hyst);
+ trip_id, trip.temperature, tz->temperature,
+ trip.hysteresis);
list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
- if (instance->trip != trip)
+ if (instance->trip != trip_id)
continue;
/* in case fan is in initial state, switch the fan off */
@@ -50,10 +52,10 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip)
* enable fan when temperature exceeds trip_temp and disable
* the fan in case it falls below trip_temp minus hysteresis
*/
- if (instance->target == 0 && tz->temperature >= trip_temp)
+ if (instance->target == 0 && tz->temperature >= trip.temperature)
instance->target = 1;
else if (instance->target == 1 &&
- tz->temperature <= trip_temp - trip_hyst)
+ tz->temperature <= trip.temperature - trip.hysteresis)
instance->target = 0;
dev_dbg(&instance->cdev->device, "target=%d\n",
@@ -63,6 +65,8 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip)
instance->cdev->updated = false; /* cdev needs update */
mutex_unlock(&instance->cdev->lock);
}
+
+ return 0;
}
/**
@@ -95,10 +99,13 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip)
static int bang_bang_control(struct thermal_zone_device *tz, int trip)
{
struct thermal_instance *instance;
+ int ret;
lockdep_assert_held(&tz->lock);
- thermal_zone_trip_update(tz, trip);
+ ret = thermal_zone_trip_update(tz, trip);
+ if (ret)
+ return ret;
list_for_each_entry(instance, &tz->thermal_instances, tz_node)
thermal_cdev_update(instance->cdev);
diff --git a/drivers/thermal/gov_fair_share.c b/drivers/thermal/gov_fair_share.c
index 1cfeac1..aad7d5f 100644
--- a/drivers/thermal/gov_fair_share.c
+++ b/drivers/thermal/gov_fair_share.c
@@ -21,16 +21,12 @@
*/
static int get_trip_level(struct thermal_zone_device *tz)
{
- int count = 0;
- int trip_temp;
- enum thermal_trip_type trip_type;
-
- if (tz->num_trips == 0 || !tz->ops->get_trip_temp)
- return 0;
+ struct thermal_trip trip;
+ int count;
for (count = 0; count < tz->num_trips; count++) {
- tz->ops->get_trip_temp(tz, count, &trip_temp);
- if (tz->temperature < trip_temp)
+ __thermal_zone_get_trip(tz, count, &trip);
+ if (tz->temperature < trip.temperature)
break;
}
@@ -38,10 +34,8 @@ static int get_trip_level(struct thermal_zone_device *tz)
* count > 0 only if temperature is greater than first trip
* point, in which case, trip_point = count - 1
*/
- if (count > 0) {
- tz->ops->get_trip_type(tz, count - 1, &trip_type);
- trace_thermal_zone_trip(tz, count - 1, trip_type);
- }
+ if (count > 0)
+ trace_thermal_zone_trip(tz, count - 1, trip.type);
return count;
}
diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c
index 2d1aeab..eafb288 100644
--- a/drivers/thermal/gov_power_allocator.c
+++ b/drivers/thermal/gov_power_allocator.c
@@ -125,16 +125,15 @@ static void estimate_pid_constants(struct thermal_zone_device *tz,
u32 sustainable_power, int trip_switch_on,
int control_temp)
{
+ struct thermal_trip trip;
+ u32 temperature_threshold = control_temp;
int ret;
- int switch_on_temp;
- u32 temperature_threshold;
s32 k_i;
- ret = tz->ops->get_trip_temp(tz, trip_switch_on, &switch_on_temp);
- if (ret)
- switch_on_temp = 0;
+ ret = __thermal_zone_get_trip(tz, trip_switch_on, &trip);
+ if (!ret)
+ temperature_threshold -= trip.temperature;
- temperature_threshold = control_temp - switch_on_temp;
/*
* estimate_pid_constants() tries to find appropriate default
* values for thermal zones that don't provide them. If a
@@ -520,10 +519,10 @@ static void get_governor_trips(struct thermal_zone_device *tz,
last_passive = INVALID_TRIP;
for (i = 0; i < tz->num_trips; i++) {
- enum thermal_trip_type type;
+ struct thermal_trip trip;
int ret;
- ret = tz->ops->get_trip_type(tz, i, &type);
+ ret = __thermal_zone_get_trip(tz, i, &trip);
if (ret) {
dev_warn(&tz->device,
"Failed to get trip point %d type: %d\n", i,
@@ -531,14 +530,14 @@ static void get_governor_trips(struct thermal_zone_device *tz,
continue;
}
- if (type == THERMAL_TRIP_PASSIVE) {
+ if (trip.type == THERMAL_TRIP_PASSIVE) {
if (!found_first_passive) {
params->trip_switch_on = i;
found_first_passive = true;
} else {
last_passive = i;
}
- } else if (type == THERMAL_TRIP_ACTIVE) {
+ } else if (trip.type == THERMAL_TRIP_ACTIVE) {
last_active = i;
} else {
break;
@@ -633,7 +632,7 @@ static int power_allocator_bind(struct thermal_zone_device *tz)
{
int ret;
struct power_allocator_params *params;
- int control_temp;
+ struct thermal_trip trip;
ret = check_power_actors(tz);
if (ret)
@@ -659,13 +658,12 @@ static int power_allocator_bind(struct thermal_zone_device *tz)
get_governor_trips(tz, params);
if (tz->num_trips > 0) {
- ret = tz->ops->get_trip_temp(tz,
- params->trip_max_desired_temperature,
- &control_temp);
+ ret = __thermal_zone_get_trip(tz, params->trip_max_desired_temperature,
+ &trip);
if (!ret)
estimate_pid_constants(tz, tz->tzp->sustainable_power,
params->trip_switch_on,
- control_temp);
+ trip.temperature);
}
reset_pid_controller(params);
@@ -695,11 +693,11 @@ static void power_allocator_unbind(struct thermal_zone_device *tz)
tz->governor_data = NULL;
}
-static int power_allocator_throttle(struct thermal_zone_device *tz, int trip)
+static int power_allocator_throttle(struct thermal_zone_device *tz, int trip_id)
{
- int ret;
- int switch_on_temp, control_temp;
struct power_allocator_params *params = tz->governor_data;
+ struct thermal_trip trip;
+ int ret;
bool update;
lockdep_assert_held(&tz->lock);
@@ -708,13 +706,12 @@ static int power_allocator_throttle(struct thermal_zone_device *tz, int trip)
* We get called for every trip point but we only need to do
* our calculations once
*/
- if (trip != params->trip_max_desired_temperature)
+ if (trip_id != params->trip_max_desired_temperature)
return 0;
- ret = tz->ops->get_trip_temp(tz, params->trip_switch_on,
- &switch_on_temp);
- if (!ret && (tz->temperature < switch_on_temp)) {
- update = (tz->last_temperature >= switch_on_temp);
+ 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);
@@ -723,16 +720,14 @@ static int power_allocator_throttle(struct thermal_zone_device *tz, int trip)
tz->passive = 1;
- ret = tz->ops->get_trip_temp(tz, params->trip_max_desired_temperature,
- &control_temp);
+ ret = __thermal_zone_get_trip(tz, params->trip_max_desired_temperature, &trip);
if (ret) {
- dev_warn(&tz->device,
- "Failed to get the maximum desired temperature: %d\n",
+ dev_warn(&tz->device, "Failed to get the maximum desired temperature: %d\n",
ret);
return ret;
}
- return allocate_power(tz, control_temp);
+ return allocate_power(tz, trip.temperature);
}
static struct thermal_governor thermal_gov_power_allocator = {
diff --git a/drivers/thermal/gov_step_wise.c b/drivers/thermal/gov_step_wise.c
index cdd3354..31235e1 100644
--- a/drivers/thermal/gov_step_wise.c
+++ b/drivers/thermal/gov_step_wise.c
@@ -95,30 +95,28 @@ static void update_passive_instance(struct thermal_zone_device *tz,
tz->passive += value;
}
-static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip)
+static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip_id)
{
- int trip_temp;
- enum thermal_trip_type trip_type;
enum thermal_trend trend;
struct thermal_instance *instance;
+ struct thermal_trip trip;
bool throttle = false;
int old_target;
- tz->ops->get_trip_temp(tz, trip, &trip_temp);
- tz->ops->get_trip_type(tz, trip, &trip_type);
+ __thermal_zone_get_trip(tz, trip_id, &trip);
- trend = get_tz_trend(tz, trip);
+ trend = get_tz_trend(tz, trip_id);
- if (tz->temperature >= trip_temp) {
+ if (tz->temperature >= trip.temperature) {
throttle = true;
- trace_thermal_zone_trip(tz, trip, trip_type);
+ trace_thermal_zone_trip(tz, trip_id, trip.type);
}
dev_dbg(&tz->device, "Trip%d[type=%d,temp=%d]:trend=%d,throttle=%d\n",
- trip, trip_type, trip_temp, trend, throttle);
+ trip_id, trip.type, trip.temperature, trend, throttle);
list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
- if (instance->trip != trip)
+ if (instance->trip != trip_id)
continue;
old_target = instance->target;
@@ -132,11 +130,11 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip)
/* Activate a passive thermal instance */
if (old_target == THERMAL_NO_TARGET &&
instance->target != THERMAL_NO_TARGET)
- update_passive_instance(tz, trip_type, 1);
+ update_passive_instance(tz, trip.type, 1);
/* Deactivate a passive thermal instance */
else if (old_target != THERMAL_NO_TARGET &&
instance->target == THERMAL_NO_TARGET)
- update_passive_instance(tz, trip_type, -1);
+ update_passive_instance(tz, trip.type, -1);
instance->initialized = true;
mutex_lock(&instance->cdev->lock);
next prev parent reply other threads:[~2022-12-09 15:27 UTC|newest]
Thread overview: 77+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20221003092704eucas1p2875c1f996dfd60a58f06cf986e02e8eb@eucas1p2.samsung.com>
2022-10-03 9:25 ` [PATCH v8 00/29] Rework the trip points creation Daniel Lezcano
2022-10-03 9:25 ` [PATCH v8 01/29] thermal/core: Add a generic thermal_zone_get_trip() function Daniel Lezcano
2022-12-09 15:26 ` [thermal: thermal/next] " thermal-bot for Daniel Lezcano
2023-03-12 12:14 ` [PATCH v8 01/29] " Ido Schimmel
2023-03-13 10:45 ` Daniel Lezcano
2023-03-13 12:12 ` Ido Schimmel
2022-10-03 9:25 ` [PATCH v8 02/29] thermal/sysfs: Always expose hysteresis attributes Daniel Lezcano
2022-12-09 15:26 ` [thermal: thermal/next] " thermal-bot for Daniel Lezcano
2022-10-03 9:25 ` [PATCH v8 03/29] thermal/core: Add a generic thermal_zone_set_trip() function Daniel Lezcano
2022-10-03 11:56 ` Rafael J. Wysocki
2022-12-09 15:26 ` [thermal: thermal/next] " thermal-bot for Daniel Lezcano
2022-10-03 9:25 ` [PATCH v8 04/29] thermal/core/governors: Use thermal_zone_get_trip() instead of ops functions Daniel Lezcano
2022-12-09 15:26 ` thermal-bot for Daniel Lezcano [this message]
2022-10-03 9:25 ` [PATCH v8 05/29] thermal/of: Use generic thermal_zone_get_trip() function Daniel Lezcano
2022-12-09 15:26 ` [thermal: thermal/next] " thermal-bot for Daniel Lezcano
2022-10-03 9:25 ` [PATCH v8 06/29] thermal/of: Remove unused functions Daniel Lezcano
2022-12-09 15:26 ` [thermal: thermal/next] " thermal-bot for Daniel Lezcano
2022-10-03 9:25 ` [PATCH v8 07/29] thermal/drivers/exynos: Use generic thermal_zone_get_trip() function Daniel Lezcano
2022-12-09 15:26 ` [thermal: thermal/next] " thermal-bot for Daniel Lezcano
2022-10-03 9:25 ` [PATCH v8 08/29] thermal/drivers/exynos: of_thermal_get_ntrips() Daniel Lezcano
2022-12-09 15:26 ` [thermal: thermal/next] " thermal-bot for Daniel Lezcano
2022-10-03 9:25 ` [PATCH v8 09/29] thermal/drivers/exynos: Replace of_thermal_is_trip_valid() by thermal_zone_get_trip() Daniel Lezcano
2022-12-09 15:26 ` [thermal: thermal/next] " thermal-bot for Daniel Lezcano
2022-10-03 9:25 ` [PATCH v8 10/29] thermal/drivers/tegra: Use generic thermal_zone_get_trip() function Daniel Lezcano
2022-12-09 15:26 ` [thermal: thermal/next] " thermal-bot for Daniel Lezcano
2022-10-03 9:25 ` [PATCH v8 11/29] thermal/drivers/uniphier: " Daniel Lezcano
2022-12-09 15:26 ` [thermal: thermal/next] " thermal-bot for Daniel Lezcano
2022-10-03 9:25 ` [PATCH v8 12/29] thermal/drivers/hisi: " Daniel Lezcano
2022-12-09 15:26 ` [thermal: thermal/next] " thermal-bot for Daniel Lezcano
2022-10-03 9:25 ` [PATCH v8 13/29] thermal/drivers/qcom: " Daniel Lezcano
2022-12-09 15:26 ` [thermal: thermal/next] " thermal-bot for Daniel Lezcano
2022-10-03 9:25 ` [PATCH v8 14/29] thermal/drivers/armada: " Daniel Lezcano
2022-12-09 15:26 ` [thermal: thermal/next] " thermal-bot for Daniel Lezcano
2022-10-03 9:25 ` [PATCH v8 15/29] thermal/drivers/rcar_gen3: Use the generic function to get the number of trips Daniel Lezcano
2022-12-09 15:26 ` [thermal: thermal/next] " thermal-bot for Daniel Lezcano
2022-10-03 9:25 ` [PATCH v8 16/29] thermal/of: Remove of_thermal_get_ntrips() Daniel Lezcano
2022-12-09 15:26 ` [thermal: thermal/next] " thermal-bot for Daniel Lezcano
2022-10-03 9:25 ` [PATCH v8 17/29] thermal/of: Remove of_thermal_is_trip_valid() Daniel Lezcano
2022-12-09 15:26 ` [thermal: thermal/next] " thermal-bot for Daniel Lezcano
2022-10-03 9:25 ` [PATCH v8 18/29] thermal/of: Remove of_thermal_set_trip_hyst() Daniel Lezcano
2022-12-09 15:26 ` [thermal: thermal/next] " thermal-bot for Daniel Lezcano
2022-10-03 9:25 ` [PATCH v8 19/29] thermal/of: Remove of_thermal_get_crit_temp() Daniel Lezcano
2022-10-03 12:50 ` Marek Szyprowski
2022-10-03 13:29 ` [PATCH] thermal/drivers/exynos: Fix NULL pointer dereference when getting the critical temp Daniel Lezcano
2022-10-03 13:40 ` Krzysztof Kozlowski
2022-10-03 13:50 ` Marek Szyprowski
2022-10-17 13:48 ` Marek Szyprowski
2022-10-17 14:14 ` Daniel Lezcano
2022-10-03 13:31 ` [PATCH v8 19/29] thermal/of: Remove of_thermal_get_crit_temp() Daniel Lezcano
2022-12-09 15:26 ` [thermal: thermal/next] " thermal-bot for Daniel Lezcano
2022-10-03 9:25 ` [PATCH v8 20/29] thermal/drivers/st: Use generic trip points Daniel Lezcano
2022-12-09 15:26 ` [thermal: thermal/next] " thermal-bot for Daniel Lezcano
2022-10-03 9:25 ` [PATCH v8 21/29] thermal/drivers/imx: Use generic thermal_zone_get_trip() function Daniel Lezcano
2022-12-09 15:26 ` [thermal: thermal/next] " thermal-bot for Daniel Lezcano
2022-10-03 9:25 ` [PATCH v8 22/29] thermal/drivers/rcar: " Daniel Lezcano
2022-12-09 15:26 ` [thermal: thermal/next] " thermal-bot for Daniel Lezcano
2022-10-03 9:25 ` [PATCH v8 23/29] thermal/drivers/broadcom: " Daniel Lezcano
2022-12-09 15:26 ` [thermal: thermal/next] " thermal-bot for Daniel Lezcano
2022-10-03 9:25 ` [PATCH v8 24/29] thermal/drivers/da9062: " Daniel Lezcano
2022-12-09 15:26 ` [thermal: thermal/next] " thermal-bot for Daniel Lezcano
2022-10-03 9:25 ` [PATCH v8 25/29] thermal/drivers/ti: Remove unused macros ti_thermal_get_trip_value() / ti_thermal_trip_is_valid() Daniel Lezcano
2022-12-09 15:26 ` [thermal: thermal/next] " thermal-bot for Daniel Lezcano
2022-10-03 9:25 ` [PATCH v8 26/29] thermal/drivers/acerhdf: Use generic thermal_zone_get_trip() function Daniel Lezcano
2022-12-09 15:26 ` [thermal: thermal/next] " thermal-bot for Daniel Lezcano
2022-10-03 9:26 ` [PATCH v8 27/29] thermal/drivers/cxgb4: " Daniel Lezcano
2022-12-09 15:26 ` [thermal: thermal/next] " thermal-bot for Daniel Lezcano
2022-10-03 9:26 ` [PATCH v8 28/29] thermal/intel/int340x: Replace parameter to simplify Daniel Lezcano
2022-12-09 15:26 ` [thermal: thermal/next] " thermal-bot for Daniel Lezcano
2022-10-03 9:26 ` [PATCH v8 29/29] thermal/drivers/intel: Use generic thermal_zone_get_trip() function Daniel Lezcano
2022-12-09 15:26 ` [thermal: thermal/next] " thermal-bot for Daniel Lezcano
2022-10-03 14:10 ` [PATCH v8 00/29] Rework the trip points creation Marek Szyprowski
2022-10-03 15:36 ` Daniel Lezcano
2022-10-03 21:18 ` Daniel Lezcano
2022-10-05 12:37 ` Daniel Lezcano
2022-10-05 13:05 ` Marek Szyprowski
2022-10-06 6:55 ` Daniel Lezcano
2022-10-06 16:25 ` Marek Szyprowski
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=167059959602.4906.4944440999955328252.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=amitk@kernel.org \
--cc=daniel.lezcano@linaro.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=rafael.j.wysocki@intel.com \
--cc=rui.zhang@intel.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;
as well as URLs for NNTP newsgroup(s).