Skip to content

Commit fc656fa

Browse files
committed
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 <[email protected]> Acked-by: Srinivas Pandruvada <[email protected]> Acked-by: Rafael J. Wysocki <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 69c560d commit fc656fa

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

drivers/thermal/thermal_core.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,10 +375,12 @@ static void handle_thermal_trip(struct thermal_zone_device *tz, int trip)
375375
if (tz->last_temperature != THERMAL_TEMP_INVALID) {
376376
if (tz->last_temperature < trip_temp &&
377377
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);
379380
if (tz->last_temperature >= trip_temp &&
380381
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);
382384
}
383385

384386
if (type == THERMAL_TRIP_CRITICAL || type == THERMAL_TRIP_HOT)

drivers/thermal/thermal_netlink.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ static int thermal_genl_event_tz(struct param *p)
121121
static int thermal_genl_event_tz_trip_up(struct param *p)
122122
{
123123
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))
125126
return -EMSGSIZE;
126127

127128
return 0;
@@ -285,16 +286,16 @@ int thermal_notify_tz_disable(int tz_id)
285286
return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_DISABLE, &p);
286287
}
287288

288-
int thermal_notify_tz_trip_down(int tz_id, int trip_id)
289+
int thermal_notify_tz_trip_down(int tz_id, int trip_id, int temp)
289290
{
290-
struct param p = { .tz_id = tz_id, .trip_id = trip_id };
291+
struct param p = { .tz_id = tz_id, .trip_id = trip_id, .temp = temp };
291292

292293
return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_TRIP_DOWN, &p);
293294
}
294295

295-
int thermal_notify_tz_trip_up(int tz_id, int trip_id)
296+
int thermal_notify_tz_trip_up(int tz_id, int trip_id, int temp)
296297
{
297-
struct param p = { .tz_id = tz_id, .trip_id = trip_id };
298+
struct param p = { .tz_id = tz_id, .trip_id = trip_id, .temp = temp };
298299

299300
return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_TRIP_UP, &p);
300301
}

drivers/thermal/thermal_netlink.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ int thermal_notify_tz_create(int tz_id, const char *name);
1111
int thermal_notify_tz_delete(int tz_id);
1212
int thermal_notify_tz_enable(int tz_id);
1313
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);
1616
int thermal_notify_tz_trip_delete(int tz_id, int id);
1717
int thermal_notify_tz_trip_add(int tz_id, int id, int type,
1818
int temp, int hyst);
@@ -49,12 +49,12 @@ static inline int thermal_notify_tz_disable(int tz_id)
4949
return 0;
5050
}
5151

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)
5353
{
5454
return 0;
5555
}
5656

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)
5858
{
5959
return 0;
6060
}

0 commit comments

Comments
 (0)