Linux Power Management development
 help / color / mirror / Atom feed
* [PATCH v1] thermal: sysfs: Make trip hysteresis writable along with trip temperature
@ 2024-01-29 20:40 Rafael J. Wysocki
  2024-01-31 18:18 ` Daniel Lezcano
  0 siblings, 1 reply; 4+ messages in thread
From: Rafael J. Wysocki @ 2024-01-29 20:40 UTC (permalink / raw)
  To: Linux PM, Daniel Lezcano
  Cc: LKML, Lukasz Luba, Zhang Rui, Srinivas Pandruvada,
	Manaf Meethalavalappu Pallikunhi

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

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.

Link: https://lore.kernel.org/linux-pm/20240106191502.29126-1-quic_manafm@quicinc.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---

Notes:

 * I don't think that CONFIG_THERMAL_WRITABLE_TRIPS is very useful.
   The only thing controlled by it is whether or not the writable trip
   mask used during registration will have any effect and this is quite
   confusing.  Some drivers select it for this reason which seems a bit
   odd to me.

   Maybe it can be dropped after the patch below?

 * IMO the writable trips mask itself is quite cumbersome and it would be
   better to mark individual trips as writable in the trips table passed
   during registration.  This would be less prone to mistakes and it
   would allow the code to check whether or not the given trip should
   be writable (root can change sysfs file modes after all).  If I'm not
   mistaken, this change should not be very hard to make, although it may
   take some time to switch over all of the relevant drivers from using
   the mask.

---
 drivers/thermal/thermal_sysfs.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Index: linux-pm/drivers/thermal/thermal_sysfs.c
===================================================================
--- linux-pm.orig/drivers/thermal/thermal_sysfs.c
+++ 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(v) &&
+		    mask & (1 << indx)) {
 			tz->trip_hyst_attrs[indx].attr.attr.mode |= S_IWUSR;
 			tz->trip_hyst_attrs[indx].attr.store =
 					trip_point_hyst_store;




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-01-31 19:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-29 20:40 [PATCH v1] thermal: sysfs: Make trip hysteresis writable along with trip temperature Rafael J. Wysocki
2024-01-31 18:18 ` Daniel Lezcano
2024-01-31 18:41   ` Rafael J. Wysocki
2024-01-31 19:01     ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox