Skip to contentSkip to conversation

thermal: sysfs: Make trip hysteresis writable along with trip temperature

PATCH In review Rafael J. Wysocki 3 participants 3 messages Jan 31, 2024 – Feb 8, 2024 Thermal

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 thermal: sysfs: Make trip hysteresis writable along with trip temperature

From: Rafael J. Wysocki <[email protected]>

Trip point temperature can be modified via sysfs if CONFIG_THERMAL_WRITABLE_TRIPS is enabled and the thermal zone creator requested that the given trip be writable in the writable trips mask passed to the registration function.

However, trip point hysteresis is treated differently - it is only writable if the thermal zone has a .set_trip_hyst() operation defined and neither CONFIG_THERMAL_WRITABLE_TRIPS, nor the writable trips mask supplied by the zone creator has any bearing on this. That is inconsistent and confusing, and it generally does not meet user expectations.

For this reason, modify create_trip_attrs() to handle trip point hysteresis in the same way as trip point temperature, so they both are writable at the same time regardless of what trip point operations are defined for the thermal zone.

---

v1 -> v2: Fix patch corruption (Daniel).

---
 drivers/thermal/thermal_sysfs.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/thermal/thermal_sysfs.c +2 -1
Index: linux-pm/drivers/thermal/thermal_sysfs.c
===================================================================
@@ -474,7 +474,8 @@ static int create_trip_attrs(struct ther
 					tz->trip_hyst_attrs[indx].name;
 		tz->trip_hyst_attrs[indx].attr.attr.mode = S_IRUGO;
 		tz->trip_hyst_attrs[indx].attr.show = trip_point_hyst_show;
-		if (tz->ops->set_trip_hyst) {
+		if (IS_ENABLED(CONFIG_THERMAL_WRITABLE_TRIPS) &&
+		    mask & (1 << indx)) {
 			tz->trip_hyst_attrs[indx].attr.attr.mode |= S_IWUSR;
 			tz->trip_hyst_attrs[indx].attr.store =
 					trip_point_hyst_store;
Acked-by on v2 1/1
#1 lore raw
Quoted 15 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

Trip point temperature can be modified via sysfs if CONFIG_THERMAL_WRITABLE_TRIPS is enabled and the thermal zone creator requested that the given trip be writable in the writable trips mask passed to the registration function.

However, trip point hysteresis is treated differently - it is only writable if the thermal zone has a .set_trip_hyst() operation defined and neither CONFIG_THERMAL_WRITABLE_TRIPS, nor the writable trips mask supplied by the zone creator has any bearing on this. That is inconsistent and confusing, and it generally does not meet user expectations.

Quoted 8 lines

For this reason, modify create_trip_attrs() to handle trip point hysteresis in the same way as trip point temperature, so they both are writable at the same time regardless of what trip point operations are defined for the thermal zone.

---

Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
#2 lore raw
Quoted 22 lines · Daniel Lezcano
Quoted 20 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

Trip point temperature can be modified via sysfs if CONFIG_THERMAL_WRITABLE_TRIPS is enabled and the thermal zone creator requested that the given trip be writable in the writable trips mask passed to the registration function.

However, trip point hysteresis is treated differently - it is only writable if the thermal zone has a .set_trip_hyst() operation defined and neither CONFIG_THERMAL_WRITABLE_TRIPS, nor the writable trips mask supplied by the zone creator has any bearing on this. That is inconsistent and confusing, and it generally does not meet user expectations.

For this reason, modify create_trip_attrs() to handle trip point hysteresis in the same way as trip point temperature, so they both are writable at the same time regardless of what trip point operations are defined for the thermal zone.

Quoted 5 lines
Quoted 3 lines

---

Thanks, but I need to withdraw this one, because there are drivers that actively don't want their trip points' hysteresis to be adjusted via sysfs, so I'm now working on a patch series that will tackle this in a more systematic way.