Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

thermal/drivers/netlink: Add the temperature when crossing a trip point

The slope of the temperature increase or decrease can be high and when
the temperature crosses the trip point, there could be a significant
difference between the trip temperature and the measured temperatures.

That forces the userspace to read the temperature back right after
receiving a trip violation notification.

In order to be efficient, give the temperature which resulted in the
trip violation.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Acked-by: Rafael J. Wysocki <rafael@kernel.org>
Link: https://lore.kernel.org/r/20211001223323.1836640-1-daniel.lezcano@linaro.org

+14 -11
+4 -2
drivers/thermal/thermal_core.c
··· 375 375 if (tz->last_temperature != THERMAL_TEMP_INVALID) { 376 376 if (tz->last_temperature < trip_temp && 377 377 tz->temperature >= trip_temp) 378 - thermal_notify_tz_trip_up(tz->id, trip); 378 + thermal_notify_tz_trip_up(tz->id, trip, 379 + tz->temperature); 379 380 if (tz->last_temperature >= trip_temp && 380 381 tz->temperature < (trip_temp - hyst)) 381 - thermal_notify_tz_trip_down(tz->id, trip); 382 + thermal_notify_tz_trip_down(tz->id, trip, 383 + tz->temperature); 382 384 } 383 385 384 386 if (type == THERMAL_TRIP_CRITICAL || type == THERMAL_TRIP_HOT)
+6 -5
drivers/thermal/thermal_netlink.c
··· 121 121 static int thermal_genl_event_tz_trip_up(struct param *p) 122 122 { 123 123 if (nla_put_u32(p->msg, THERMAL_GENL_ATTR_TZ_ID, p->tz_id) || 124 - nla_put_u32(p->msg, THERMAL_GENL_ATTR_TZ_TRIP_ID, p->trip_id)) 124 + nla_put_u32(p->msg, THERMAL_GENL_ATTR_TZ_TRIP_ID, p->trip_id) || 125 + nla_put_u32(p->msg, THERMAL_GENL_ATTR_TZ_TEMP, p->temp)) 125 126 return -EMSGSIZE; 126 127 127 128 return 0; ··· 286 285 return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_DISABLE, &p); 287 286 } 288 287 289 - int thermal_notify_tz_trip_down(int tz_id, int trip_id) 288 + int thermal_notify_tz_trip_down(int tz_id, int trip_id, int temp) 290 289 { 291 - struct param p = { .tz_id = tz_id, .trip_id = trip_id }; 290 + struct param p = { .tz_id = tz_id, .trip_id = trip_id, .temp = temp }; 292 291 293 292 return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_TRIP_DOWN, &p); 294 293 } 295 294 296 - int thermal_notify_tz_trip_up(int tz_id, int trip_id) 295 + int thermal_notify_tz_trip_up(int tz_id, int trip_id, int temp) 297 296 { 298 - struct param p = { .tz_id = tz_id, .trip_id = trip_id }; 297 + struct param p = { .tz_id = tz_id, .trip_id = trip_id, .temp = temp }; 299 298 300 299 return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_TRIP_UP, &p); 301 300 }
+4 -4
drivers/thermal/thermal_netlink.h
··· 11 11 int thermal_notify_tz_delete(int tz_id); 12 12 int thermal_notify_tz_enable(int tz_id); 13 13 int thermal_notify_tz_disable(int tz_id); 14 - int thermal_notify_tz_trip_down(int tz_id, int id); 15 - int thermal_notify_tz_trip_up(int tz_id, int id); 14 + int thermal_notify_tz_trip_down(int tz_id, int id, int temp); 15 + int thermal_notify_tz_trip_up(int tz_id, int id, int temp); 16 16 int thermal_notify_tz_trip_delete(int tz_id, int id); 17 17 int thermal_notify_tz_trip_add(int tz_id, int id, int type, 18 18 int temp, int hyst); ··· 49 49 return 0; 50 50 } 51 51 52 - static inline int thermal_notify_tz_trip_down(int tz_id, int id) 52 + static inline int thermal_notify_tz_trip_down(int tz_id, int id, int temp) 53 53 { 54 54 return 0; 55 55 } 56 56 57 - static inline int thermal_notify_tz_trip_up(int tz_id, int id) 57 + static inline int thermal_notify_tz_trip_up(int tz_id, int id, int temp) 58 58 { 59 59 return 0; 60 60 }