[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230519032719.2581689-7-evalenti@kernel.org>
Date: Thu, 18 May 2023 20:27:18 -0700
From: Eduardo Valentin <evalenti@...nel.org>
To: eduval@...zon.com, linux-pm@...r.kernel.org
Cc: "Rafael J. Wysocki" <rafael@...nel.org>,
Daniel Lezcano <daniel.lezcano@...aro.org>,
Amit Kucheria <amitk@...nel.org>,
Zhang Rui <rui.zhang@...el.com>,
Jonathan Corbet <corbet@....net>, linux-doc@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH 6/7] ythermal: core: report errors to governors
From: Eduardo Valentin <eduval@...zon.com>
Currently the thermal governors are not allowed to
react on temperature error events as the thermal core
skips the handling and logs an error on kernel buffer.
This patch adds the opportunity to report the errors
when they happen to governors.
Now, if a governor wants to react on temperature read
errors, they can implement the .check_error() callback.
Cc: "Rafael J. Wysocki" <rafael@...nel.org> (supporter:THERMAL)
Cc: Daniel Lezcano <daniel.lezcano@...aro.org> (supporter:THERMAL)
Cc: Amit Kucheria <amitk@...nel.org> (reviewer:THERMAL)
Cc: Zhang Rui <rui.zhang@...el.com> (reviewer:THERMAL)
Cc: Jonathan Corbet <corbet@....net> (maintainer:DOCUMENTATION)
Cc: linux-pm@...r.kernel.org (open list:THERMAL)
Cc: linux-doc@...r.kernel.org (open list:DOCUMENTATION)
Cc: linux-kernel@...r.kernel.org (open list)
Signed-off-by: Eduardo Valentin <eduval@...zon.com>
---
drivers/thermal/thermal_core.c | 9 +++++++++
include/linux/thermal.h | 3 +++
2 files changed, 12 insertions(+)
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 3ba970c0744f..2ff7d9c7c973 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -313,6 +313,12 @@ static void handle_non_critical_trips(struct thermal_zone_device *tz, int trip)
def_governor->throttle(tz, trip);
}
+static void handle_error_temperature(struct thermal_zone_device *tz, int error)
+{
+ if (tz->governor && tz->governor->check_error)
+ tz->governor->check_error(tz, error);
+}
+
void thermal_zone_device_critical(struct thermal_zone_device *tz)
{
/*
@@ -380,6 +386,9 @@ static void update_temperature(struct thermal_zone_device *tz)
dev_warn(&tz->device,
"failed to read out thermal zone (%d)\n",
ret);
+ /* tell the governor its source is hosed */
+ handle_error_temperature(tz, ret);
+
return;
}
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 9dc8292f0314..82c8e09a63e0 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -199,6 +199,8 @@ struct thermal_zone_device {
* thermal zone.
* @throttle: callback called for every trip point even if temperature is
* below the trip point temperature
+ * @check_error: callback called whenever temperature updates fail.
+ * Opportunity for the governor to react on errors.
* @governor_list: node in thermal_governor_list (in thermal_core.c)
*/
struct thermal_governor {
@@ -206,6 +208,7 @@ struct thermal_governor {
int (*bind_to_tz)(struct thermal_zone_device *tz);
void (*unbind_from_tz)(struct thermal_zone_device *tz);
int (*throttle)(struct thermal_zone_device *tz, int trip);
+ void (*check_error)(struct thermal_zone_device *tz, int error);
struct list_head governor_list;
};
--
2.34.1
Powered by blists - more mailing lists