[PATCH v1 02/12] thermal: core: Introduce private thermal zone aggregation structures
From: Daniel Lezcano
Date: Thu Nov 19 2026 - 04:47:45 EST
Represent a linear combination of thermal zone temperatures with an
array of source zone pointers and signed coefficients. Reuse the existing
offset in thermal_zone_params for the signed constant adjustment instead
of duplicating it in the aggregation description.
Keep each coefficient in the aggregation entry because it describes
the contribution of a source zone to a particular aggregate, rather
than a property of the source zone itself. The same source zone can
contribute to several aggregates with different coefficients. A single
coefficient in thermal_zone_device could not represent these independent
relationships.
Define the aggregation structures in thermal_core.h and associate the
description with a zone through an optional pointer in thermal_zone_params.
Keep the definitions private to the thermal core, with only an opaque
forward declaration and pointer in the public thermal header. A NULL
pointer denotes a non-aggregated zone.
This establishes the firmware-independent representation for subsequent
aggregation support without changing registration, callbacks, or
temperature handling.
Signed-off-by: Daniel Lezcano <daniel.lezcano@xxxxxxxxxxxxxxxx>
---
drivers/thermal/thermal_core.h | 23 +++++++++++++++++++++++
include/linux/thermal.h | 4 ++++
2 files changed, 27 insertions(+)
diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
index 7b91717d9d74..a5fdf5c24b6c 100644
--- a/drivers/thermal/thermal_core.h
+++ b/drivers/thermal/thermal_core.h
@@ -63,6 +63,29 @@ struct thermal_governor {
struct list_head governor_list;
};
+/**
+ * struct thermal_zone_aggregate_entry - source zone and its coefficient
+ * @tz: source thermal zone
+ * @coefficient: signed multiplier for the source zone temperature
+ */
+struct thermal_zone_aggregate_entry {
+ struct thermal_zone_device *tz;
+ s32 coefficient;
+};
+
+/**
+ * struct thermal_zone_aggregate - linear combination of source zone temperatures
+ * @entries: array of source thermal zones and their coefficients
+ * @num_entries: number of entries in the array
+ *
+ * Represents the sum of each source zone temperature multiplied by its
+ * coefficient. The constant offset is stored in struct thermal_zone_params.
+ */
+struct thermal_zone_aggregate {
+ struct thermal_zone_aggregate_entry *entries;
+ unsigned int num_entries;
+};
+
#define TZ_STATE_FLAG_SUSPENDED BIT(0)
#define TZ_STATE_FLAG_RESUMING BIT(1)
#define TZ_STATE_FLAG_INIT BIT(2)
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 306ad17aed89..8be61b0c2684 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -30,6 +30,7 @@
#define THERMAL_TEMP_INVALID -274000
struct thermal_zone_device;
+struct thermal_zone_aggregate;
struct thermal_cooling_device;
struct thermal_instance;
struct thermal_debugfs;
@@ -192,6 +193,9 @@ struct thermal_zone_params {
* Used by thermal zone drivers (default 0).
*/
int offset;
+
+ /* Core-private aggregation data, or NULL for a non-aggregated zone. */
+ struct thermal_zone_aggregate *aggregate;
};
/* Function declarations */
--
2.43.0