All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Linux PM <linux-pm@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Daniel Lezcano <daniel.lezcano@linaro.org>,
	Lukasz Luba <lukasz.luba@arm.com>,
	Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Subject: [PATCH v1 01/16] thermal: core: Introduce .trip_crossed() callback for thermal governors
Date: Wed, 10 Apr 2024 18:10:53 +0200	[thread overview]
Message-ID: <2009494.usQuhbGJ8B@kreacher> (raw)
In-Reply-To: <13515747.uLZWGnKmhe@kreacher>

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Introduce a new thermal governor callback called .trip_crossed()
that will be invoked whenever a trip point is crossed by the zone
temperature, either on the way up or on the way down.

The trip crossing direction information will be passed to it and if
multiple trips are crossed in the same direction during one thermal zone
update, the new callback will be invoked for them in temperature order,
either ascending or descending, depending on the trip crossing
direction.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/thermal/thermal_core.c |   19 +++++++++++++++++--
 drivers/thermal/thermal_core.h |    4 ++++
 2 files changed, 21 insertions(+), 2 deletions(-)

Index: linux-pm/drivers/thermal/thermal_core.c
===================================================================
--- linux-pm.orig/drivers/thermal/thermal_core.c
+++ linux-pm/drivers/thermal/thermal_core.c
@@ -302,11 +302,21 @@ static void monitor_thermal_zone(struct
 		thermal_zone_device_set_polling(tz, tz->polling_delay_jiffies);
 }
 
+static struct thermal_governor *thermal_get_tz_governor(struct thermal_zone_device *tz)
+{
+	if (tz->governor)
+		return tz->governor;
+
+	return def_governor;
+}
+
 static void handle_non_critical_trips(struct thermal_zone_device *tz,
 				      const struct thermal_trip *trip)
 {
-	tz->governor ? tz->governor->throttle(tz, trip) :
-		       def_governor->throttle(tz, trip);
+	struct thermal_governor *governor = thermal_get_tz_governor(tz);
+
+	if (governor->throttle)
+		governor->throttle(tz, trip);
 }
 
 void thermal_governor_update_tz(struct thermal_zone_device *tz,
@@ -470,6 +480,7 @@ static int thermal_trip_notify_cmp(void
 void __thermal_zone_device_update(struct thermal_zone_device *tz,
 				  enum thermal_notify_event event)
 {
+	struct thermal_governor *governor = thermal_get_tz_governor(tz);
 	struct thermal_trip_desc *td;
 	LIST_HEAD(way_down_list);
 	LIST_HEAD(way_up_list);
@@ -493,12 +504,16 @@ void __thermal_zone_device_update(struct
 	list_for_each_entry(td, &way_up_list, notify_list_node) {
 		thermal_notify_tz_trip_up(tz, &td->trip);
 		thermal_debug_tz_trip_up(tz, &td->trip);
+		if (governor->trip_crossed)
+			governor->trip_crossed(tz, &td->trip, true);
 	}
 
 	list_sort(NULL, &way_down_list, thermal_trip_notify_cmp);
 	list_for_each_entry(td, &way_down_list, notify_list_node) {
 		thermal_notify_tz_trip_down(tz, &td->trip);
 		thermal_debug_tz_trip_down(tz, &td->trip);
+		if (governor->trip_crossed)
+			governor->trip_crossed(tz, &td->trip, false);
 	}
 
 	monitor_thermal_zone(tz);
Index: linux-pm/drivers/thermal/thermal_core.h
===================================================================
--- linux-pm.orig/drivers/thermal/thermal_core.h
+++ linux-pm/drivers/thermal/thermal_core.h
@@ -30,6 +30,7 @@ struct thermal_trip_desc {
  *		otherwise it fails.
  * @unbind_from_tz:	callback called when a governor is unbound from a
  *			thermal zone.
+ * @trip_crossed:	called for trip points that have just been crossed
  * @throttle:	callback called for every trip point even if temperature is
  *		below the trip point temperature
  * @update_tz:	callback called when thermal zone internals have changed, e.g.
@@ -40,6 +41,9 @@ struct thermal_governor {
 	const char *name;
 	int (*bind_to_tz)(struct thermal_zone_device *tz);
 	void (*unbind_from_tz)(struct thermal_zone_device *tz);
+	void (*trip_crossed)(struct thermal_zone_device *tz,
+			     const struct thermal_trip *trip,
+			     bool crossed_up);
 	int (*throttle)(struct thermal_zone_device *tz,
 			const struct thermal_trip *trip);
 	void (*update_tz)(struct thermal_zone_device *tz,




  parent reply	other threads:[~2024-04-10 17:44 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-10 15:41 [PATCH v1 00/16] thermal: core: Redesign the governor interface Rafael J. Wysocki
2024-04-10 16:04 ` [PATCH v1 02/16] thermal: gov_bang_bang: Use .trip_crossed() instead of .throttle() Rafael J. Wysocki
2024-04-19  9:34   ` Lukasz Luba
2024-04-23 17:04   ` Daniel Lezcano
2024-04-10 16:05 ` [PATCH v1 03/16] thermal: gov_bang_bang: Clean up thermal_zone_trip_update() Rafael J. Wysocki
2024-04-19  9:41   ` Lukasz Luba
2024-04-23 17:05   ` Daniel Lezcano
2024-04-10 16:06 ` [PATCH v1 04/16] thermal: gov_bang_bang: Fold thermal_zone_trip_update() into its caller Rafael J. Wysocki
2024-04-19  9:42   ` Lukasz Luba
2024-04-23 17:06   ` Daniel Lezcano
2024-04-10 16:08 ` [PATCH v1 05/16] thermal: core: Introduce .manage() callback for thermal governors Rafael J. Wysocki
2024-04-19  9:44   ` Lukasz Luba
2024-04-23 17:07   ` Daniel Lezcano
2024-04-10 16:10 ` [PATCH v1 06/16] thermal: gov_power_allocator: Use .manage() callback instead of .throttle() Rafael J. Wysocki
2024-04-19  9:50   ` Lukasz Luba
2024-04-10 16:10 ` Rafael J. Wysocki [this message]
2024-04-19  8:47   ` [PATCH v1 01/16] thermal: core: Introduce .trip_crossed() callback for thermal governors Lukasz Luba
2024-04-23 17:14   ` Daniel Lezcano
2024-04-23 17:25     ` Rafael J. Wysocki
2024-04-23 17:58       ` Daniel Lezcano
2024-04-10 16:12 ` [PATCH v1 07/16] thermal: gov_power_allocator: Eliminate a redundant variable Rafael J. Wysocki
2024-04-19  9:56   ` Lukasz Luba
2024-04-23 17:35   ` Daniel Lezcano
2024-04-23 17:54     ` Rafael J. Wysocki
2024-04-23 18:00       ` Daniel Lezcano
2024-04-23 18:05         ` Rafael J. Wysocki
2024-04-23 18:09           ` Daniel Lezcano
2024-04-10 16:13 ` [PATCH v1 08/16] thermal: gov_step_wise: Use .manage() callback instead of .throttle() Rafael J. Wysocki
2024-04-19 17:20   ` Lukasz Luba
2024-04-24  7:54   ` Daniel Lezcano
2024-04-10 16:43 ` [PATCH v1 09/16] thermal: gov_step_wise: Use trip thresholds instead of trip temperatures Rafael J. Wysocki
2024-04-19 19:11   ` Lukasz Luba
2024-04-24  7:03   ` Daniel Lezcano
2024-04-10 16:44 ` [PATCH v1 10/16] thermal: gov_step_wise: Clean up thermal_zone_trip_update() Rafael J. Wysocki
2024-04-19 18:21   ` Lukasz Luba
2024-04-10 16:57 ` [PATCH v1 11/16] thermal: gov_fair_share: Use .manage() callback instead of .throttle() Rafael J. Wysocki
2024-04-19 18:28   ` Lukasz Luba
2024-04-10 16:58 ` [PATCH v1 12/16] thermal: gov_fair_share: Use trip thresholds instead of trip temperatures Rafael J. Wysocki
2024-04-19 19:18   ` Lukasz Luba
2024-04-10 17:00 ` [PATCH v1 13/16] thermal: gov_fair_share: Eliminate unnecessary integer divisions Rafael J. Wysocki
2024-04-19 18:46   ` Lukasz Luba
2024-04-10 17:03 ` [PATCH v1 14/16] thermal: gov_user_space: Use .trip_crossed() instead of .throttle() Rafael J. Wysocki
2024-04-19 18:16   ` Lukasz Luba
2024-04-24  9:14   ` Daniel Lezcano
2024-04-24 11:32     ` Srinivas Pandruvada
2024-04-24 11:34       ` Daniel Lezcano
2024-04-24 11:44         ` Srinivas Pandruvada
2024-04-10 17:42 ` [PATCH v1 15/16] thermal: core: Drop the .throttle() governor callback Rafael J. Wysocki
2024-04-19 18:50   ` Lukasz Luba
2024-04-24  9:11   ` Daniel Lezcano
2024-04-10 17:44 ` [PATCH v1 16/16] thermal: core: Relocate critical and hot trip handling Rafael J. Wysocki
2024-04-19 18:52   ` Lukasz Luba
2024-04-24  9:17   ` Daniel Lezcano

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=2009494.usQuhbGJ8B@kreacher \
    --to=rjw@rjwysocki.net \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lukasz.luba@arm.com \
    --cc=srinivas.pandruvada@linux.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.