linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eduardo Valentin <evalenti@kernel.org>
To: eduval@amazon.com, linux-pm@vger.kernel.org
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
	Daniel Lezcano <daniel.lezcano@linaro.org>,
	Amit Kucheria <amitk@kernel.org>, Zhang Rui <rui.zhang@intel.com>,
	Jonathan Corbet <corbet@lwn.net>,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 6/7] ythermal: core: report errors to governors
Date: Thu, 18 May 2023 20:27:18 -0700	[thread overview]
Message-ID: <20230519032719.2581689-7-evalenti@kernel.org> (raw)
In-Reply-To: <20230519032719.2581689-1-evalenti@kernel.org>

From: Eduardo Valentin <eduval@amazon.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@kernel.org> (supporter:THERMAL)
Cc: Daniel Lezcano <daniel.lezcano@linaro.org> (supporter:THERMAL)
Cc: Amit Kucheria <amitk@kernel.org> (reviewer:THERMAL)
Cc: Zhang Rui <rui.zhang@intel.com> (reviewer:THERMAL)
Cc: Jonathan Corbet <corbet@lwn.net> (maintainer:DOCUMENTATION)
Cc: linux-pm@vger.kernel.org (open list:THERMAL)
Cc: linux-doc@vger.kernel.org (open list:DOCUMENTATION)
Cc: linux-kernel@vger.kernel.org (open list)

Signed-off-by: Eduardo Valentin <eduval@amazon.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


  parent reply	other threads:[~2023-05-19  3:28 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-19  3:27 [PATCH 0/7] thermal: enhancements on thermal stats Eduardo Valentin
2023-05-19  3:27 ` [PATCH 1/7] thermal: stats: track time each dev changes due to tz Eduardo Valentin
2023-06-20 13:43   ` Rafael J. Wysocki
2023-06-21  4:37     ` Eduardo Valentin
2023-05-19  3:27 ` [PATCH 2/7] thermal: stats: track number of change requests " Eduardo Valentin
2023-06-20 17:12   ` Rafael J. Wysocki
2023-06-21  4:40     ` Eduardo Valentin
2023-05-19  3:27 ` [PATCH 3/7] thermal: stats: introduce thermal zone stats/ directory Eduardo Valentin
2023-05-19  3:27 ` [PATCH 4/7] thermal: stats: introduce thermal zone stats/min_gradient Eduardo Valentin
2023-06-20 17:17   ` Rafael J. Wysocki
2023-05-19  3:27 ` [PATCH 5/7] thermal: stats: introduce tz time in trip Eduardo Valentin
2023-06-20 17:27   ` Rafael J. Wysocki
2023-06-21  4:45     ` Eduardo Valentin
2023-06-23 16:40       ` Rafael J. Wysocki
2023-06-28 20:00         ` Eduardo Valentin
2023-05-19  3:27 ` Eduardo Valentin [this message]
2023-06-20 17:29   ` [PATCH 6/7] ythermal: core: report errors to governors Rafael J. Wysocki
2023-06-21  4:49     ` Eduardo Valentin
2023-05-19  3:27 ` [PATCH 7/7] thermal: stats: add error accounting to thermal zone Eduardo Valentin
2023-06-20 17:32   ` Rafael J. Wysocki
2023-06-21  4:50     ` Eduardo Valentin
2023-05-24 18:22 ` [PATCH 0/7] thermal: enhancements on thermal stats Rafael J. Wysocki
2023-06-05 23:28   ` Eduardo Valentin
2023-06-20 19:05 ` Daniel Lezcano
2023-06-21  4:24   ` Eduardo Valentin

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=20230519032719.2581689-7-evalenti@kernel.org \
    --to=evalenti@kernel.org \
    --cc=amitk@kernel.org \
    --cc=corbet@lwn.net \
    --cc=daniel.lezcano@linaro.org \
    --cc=eduval@amazon.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    --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).