thermal/drivers/netlink: Add the temperature when crossing a trip point
PATCH RESEND 1/1 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.
--- drivers/thermal/thermal_core.c | 6 ++++-- drivers/thermal/thermal_netlink.c | 11 ++++++----- drivers/thermal/thermal_netlink.h | 8 ++++---- 3 files changed, 14 insertions(+), 11 deletions(-)
drivers/thermal/thermal_core.c +4 -2
@@ -375,10 +375,12 @@ static void handle_thermal_trip(struct thermal_zone_device *tz, int trip)if (tz->last_temperature !=THERMAL_TEMP_INVALID ) {if (tz->last_temperature < trip_temp && tz->temperature >= trip_temp) -thermal_notify_tz_trip_up (tz->id, trip); +thermal_notify_tz_trip_up (tz->id, trip, + tz->temperature);if (tz->last_temperature >= trip_temp && tz->temperature < (trip_temp - hyst)) -thermal_notify_tz_trip_down (tz->id, trip); +thermal_notify_tz_trip_down (tz->id, trip, + tz->temperature); }if (type ==THERMAL_TRIP_CRITICAL || type ==THERMAL_TRIP_HOT )
drivers/thermal/thermal_netlink.c +6 -5
@@ -121,7 +121,8 @@ static int thermal_genl_event_tz(struct param *p)static int thermal_genl_event_tz_trip_up (struct param *p) {if (nla_put_u32 (p->msg,THERMAL_GENL_ATTR_TZ_ID , p->tz_id) || -nla_put_u32 (p->msg,THERMAL_GENL_ATTR_TZ_TRIP_ID , p->trip_id)) +nla_put_u32 (p->msg,THERMAL_GENL_ATTR_TZ_TRIP_ID , p->trip_id) || +nla_put_u32 (p->msg,THERMAL_GENL_ATTR_TZ_TEMP , p->temp))return -EMSGSIZE ;return 0 ;
@@ -285,16 +286,16 @@ int thermal_notify_tz_disable(int tz_id)return thermal_genl_send_event (THERMAL_GENL_EVENT_TZ_DISABLE , &p); } -int thermal_notify_tz_trip_down (int tz_id,int trip_id) +int thermal_notify_tz_trip_down (int tz_id,int trip_id,int temp) { -struct param p = { .tz_id = tz_id, .trip_id = trip_id }; +struct param p = { .tz_id = tz_id, .trip_id = trip_id, .temp = temp };return thermal_genl_send_event (THERMAL_GENL_EVENT_TZ_TRIP_DOWN , &p); } -int thermal_notify_tz_trip_up (int tz_id,int trip_id) +int thermal_notify_tz_trip_up (int tz_id,int trip_id,int temp) { -struct param p = { .tz_id = tz_id, .trip_id = trip_id }; +struct param p = { .tz_id = tz_id, .trip_id = trip_id, .temp = temp };return thermal_genl_send_event (THERMAL_GENL_EVENT_TZ_TRIP_UP , &p); }
drivers/thermal/thermal_netlink.h +4 -4
@@ -11,8 +11,8 @@ int thermal_notify_tz_create(int tz_id, const char *name);int thermal_notify_tz_delete (int tz_id);int thermal_notify_tz_enable (int tz_id);int thermal_notify_tz_disable (int tz_id); -int thermal_notify_tz_trip_down (int tz_id,int id); -int thermal_notify_tz_trip_up (int tz_id,int id); +int thermal_notify_tz_trip_down (int tz_id,int id,int temp); +int thermal_notify_tz_trip_up (int tz_id,int id,int temp);int thermal_notify_tz_trip_delete (int tz_id,int id);int thermal_notify_tz_trip_add (int tz_id,int id,int type,int temp,int hyst);
@@ -49,12 +49,12 @@ static inline int thermal_notify_tz_disable(int tz_id)return 0 ; } -static inline int thermal_notify_tz_trip_down (int tz_id,int id) +static inline int thermal_notify_tz_trip_down (int tz_id,int id,int temp) {return 0 ; } -static inline int thermal_notify_tz_trip_up (int tz_id,int id) +static inline int thermal_notify_tz_trip_up (int tz_id,int id,int temp) {return 0 ; }
Signature · 1 line
2.25.1
Rafael J. Wysocki
maintainerQuoted 5 lines · Daniel Lezcano
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.
Quoted 8 lines
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]>
This looks fine to me too.
Quoted 12 lines
--- drivers/thermal/thermal_core.c | 6 ++++-- drivers/thermal/thermal_netlink.c | 11 ++++++----- drivers/thermal/thermal_netlink.h | 8 ++++---- 3 files changed, 14 insertions(+), 11 deletions(-)drivers/thermal/thermal_core.c +0
-0@@ -375,10 +375,12 @@ static void handle_thermal_trip(struct thermal_zone_device *tz, int trip)if (tz->last_temperature !=THERMAL_TEMP_INVALID ) {
drivers/thermal/thermal_core.c static void handle_thermal_trip(struct thermal_zone_device *tz, int trip) · line 383
Quoted 10 lines
drivers/thermal/thermal_core.c +4
-2if (tz->last_temperature < trip_temp && tz->temperature >= trip_temp) -thermal_notify_tz_trip_up (tz->id, trip); +thermal_notify_tz_trip_up (tz->id, trip, + tz->temperature);if (tz->last_temperature >= trip_temp && tz->temperature < (trip_temp - hyst)) -thermal_notify_tz_trip_down (tz->id, trip); +thermal_notify_tz_trip_down (tz->id, trip, + tz->temperature);
While at it, I'm not sure if all of the additional line breaks due to the line length limit are really necessary. The code would be easier to follow without them IMV.
Quoted 71 lines
drivers/thermal/thermal_core.c +0
-0}if (type ==THERMAL_TRIP_CRITICAL || type ==THERMAL_TRIP_HOT )drivers/thermal/thermal_netlink.c +6
-5@@ -121,7 +121,8 @@ static int thermal_genl_event_tz(struct param *p)static int thermal_genl_event_tz_trip_up (struct param *p) {if (nla_put_u32 (p->msg,THERMAL_GENL_ATTR_TZ_ID , p->tz_id) || -nla_put_u32 (p->msg,THERMAL_GENL_ATTR_TZ_TRIP_ID , p->trip_id)) +nla_put_u32 (p->msg,THERMAL_GENL_ATTR_TZ_TRIP_ID , p->trip_id) || +nla_put_u32 (p->msg,THERMAL_GENL_ATTR_TZ_TEMP , p->temp))return -EMSGSIZE ;return 0 ;@@ -285,16 +286,16 @@ int thermal_notify_tz_disable(int tz_id)return thermal_genl_send_event (THERMAL_GENL_EVENT_TZ_DISABLE , &p); } -int thermal_notify_tz_trip_down (int tz_id,int trip_id) +int thermal_notify_tz_trip_down (int tz_id,int trip_id,int temp) { -struct param p = { .tz_id = tz_id, .trip_id = trip_id }; +struct param p = { .tz_id = tz_id, .trip_id = trip_id, .temp = temp };return thermal_genl_send_event (THERMAL_GENL_EVENT_TZ_TRIP_DOWN , &p); } -int thermal_notify_tz_trip_up (int tz_id,int trip_id) +int thermal_notify_tz_trip_up (int tz_id,int trip_id,int temp) { -struct param p = { .tz_id = tz_id, .trip_id = trip_id }; +struct param p = { .tz_id = tz_id, .trip_id = trip_id, .temp = temp };return thermal_genl_send_event (THERMAL_GENL_EVENT_TZ_TRIP_UP , &p); }drivers/thermal/thermal_netlink.h +4
-5@@ -11,8 +11,8 @@ int thermal_notify_tz_create(int tz_id, const char *name);int thermal_notify_tz_delete (int tz_id);int thermal_notify_tz_enable (int tz_id);int thermal_notify_tz_disable (int tz_id); -int thermal_notify_tz_trip_down (int tz_id,int id); -int thermal_notify_tz_trip_up (int tz_id,int id); +int thermal_notify_tz_trip_down (int tz_id,int id,int temp); +int thermal_notify_tz_trip_up (int tz_id,int id,int temp);int thermal_notify_tz_trip_delete (int tz_id,int id);int thermal_notify_tz_trip_add (int tz_id,int id,int type,int temp,int hyst);@@ -49,12 +49,12 @@ static inline int thermal_notify_tz_disable(int tz_id)return 0 ; } -static inline int thermal_notify_tz_trip_down (int tz_id,int id) +static inline int thermal_notify_tz_trip_down (int tz_id,int id,int temp) {return 0 ; } -static inline int thermal_notify_tz_trip_up (int tz_id,int id) +static inline int thermal_notify_tz_trip_up (int tz_id,int id,int temp) {return 0 ; } --2.25.1
Quoted 36 lines · Rafael J. Wysocki
Quoted 5 lines · Daniel Lezcano
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.
Quoted 8 lines
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]>This looks fine to me too.
Quoted 18 lines
--- drivers/thermal/thermal_core.c | 6 ++++-- drivers/thermal/thermal_netlink.c | 11 ++++++----- drivers/thermal/thermal_netlink.h | 8 ++++---- 3 files changed, 14 insertions(+), 11 deletions(-)drivers/thermal/thermal_core.c +2
-1@@ -375,10 +375,12 @@ static void handle_thermal_trip(struct thermal_zone_device *tz, int trip)if (tz->last_temperature !=THERMAL_TEMP_INVALID ) {if (tz->last_temperature < trip_temp && tz->temperature >= trip_temp) -thermal_notify_tz_trip_up (tz->id, trip); +thermal_notify_tz_trip_up (tz->id, trip, + tz->temperature); if (tz->last_temperature >= trip_temp &&
Quoted 8 lines
drivers/thermal/thermal_core.c static void handle_thermal_trip(struct thermal_zone_device *tz, int trip) · line 383
Quoted 4 lines
drivers/thermal/thermal_core.c +2
-1tz->temperature < (trip_temp - hyst)) -thermal_notify_tz_trip_down (tz->id, trip); +thermal_notify_tz_trip_down (tz->id, trip, + tz->temperature);While at it, I'm not sure if all of the additional line breaks due to the line length limit are really necessary. The code would be easier to follow without them IMV.
Ok let me write another patch to wrap those into a single function and reduce the indentation.
Quoted 71 lines
Quoted 71 lines
drivers/thermal/thermal_core.c +0
-0}if (type ==THERMAL_TRIP_CRITICAL || type ==THERMAL_TRIP_HOT )drivers/thermal/thermal_netlink.c +6
-5@@ -121,7 +121,8 @@ static int thermal_genl_event_tz(struct param *p)static int thermal_genl_event_tz_trip_up (struct param *p) {if (nla_put_u32 (p->msg,THERMAL_GENL_ATTR_TZ_ID , p->tz_id) || -nla_put_u32 (p->msg,THERMAL_GENL_ATTR_TZ_TRIP_ID , p->trip_id)) +nla_put_u32 (p->msg,THERMAL_GENL_ATTR_TZ_TRIP_ID , p->trip_id) || +nla_put_u32 (p->msg,THERMAL_GENL_ATTR_TZ_TEMP , p->temp))return -EMSGSIZE ;return 0 ;@@ -285,16 +286,16 @@ int thermal_notify_tz_disable(int tz_id)return thermal_genl_send_event (THERMAL_GENL_EVENT_TZ_DISABLE , &p); } -int thermal_notify_tz_trip_down (int tz_id,int trip_id) +int thermal_notify_tz_trip_down (int tz_id,int trip_id,int temp) { -struct param p = { .tz_id = tz_id, .trip_id = trip_id }; +struct param p = { .tz_id = tz_id, .trip_id = trip_id, .temp = temp };return thermal_genl_send_event (THERMAL_GENL_EVENT_TZ_TRIP_DOWN , &p); } -int thermal_notify_tz_trip_up (int tz_id,int trip_id) +int thermal_notify_tz_trip_up (int tz_id,int trip_id,int temp) { -struct param p = { .tz_id = tz_id, .trip_id = trip_id }; +struct param p = { .tz_id = tz_id, .trip_id = trip_id, .temp = temp };return thermal_genl_send_event (THERMAL_GENL_EVENT_TZ_TRIP_UP , &p); }drivers/thermal/thermal_netlink.h +4
-5@@ -11,8 +11,8 @@ int thermal_notify_tz_create(int tz_id, const char *name);int thermal_notify_tz_delete (int tz_id);int thermal_notify_tz_enable (int tz_id);int thermal_notify_tz_disable (int tz_id); -int thermal_notify_tz_trip_down (int tz_id,int id); -int thermal_notify_tz_trip_up (int tz_id,int id); +int thermal_notify_tz_trip_down (int tz_id,int id,int temp); +int thermal_notify_tz_trip_up (int tz_id,int id,int temp);int thermal_notify_tz_trip_delete (int tz_id,int id);int thermal_notify_tz_trip_add (int tz_id,int id,int type,int temp,int hyst);@@ -49,12 +49,12 @@ static inline int thermal_notify_tz_disable(int tz_id)return 0 ; } -static inline int thermal_notify_tz_trip_down (int tz_id,int id) +static inline int thermal_notify_tz_trip_down (int tz_id,int id,int temp) {return 0 ; } -static inline int thermal_notify_tz_trip_up (int tz_id,int id) +static inline int thermal_notify_tz_trip_up (int tz_id,int id,int temp) {return 0 ; } --2.25.1
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
The following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: fc656fa14da7865774b4251afa88ffcf22bf02d2 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//fc656fa14da7865774b4251afa88ffcf22bf02d2 Author: Daniel Lezcano <[email protected]> AuthorDate: Sat, 02 Oct 2021 00:33:23 +02:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Thu, 07 Oct 2021 15:41:38 +02:00
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.
--- drivers/thermal/thermal_core.c | 6 ++++-- drivers/thermal/thermal_netlink.c | 11 ++++++----- drivers/thermal/thermal_netlink.h | 8 ++++---- 3 files changed, 14 insertions(+), 11 deletions(-)
drivers/thermal/thermal_core.c +4 -2
@@ -375,10 +375,12 @@ static void handle_thermal_trip(struct thermal_zone_device *tz, int trip)if (tz->last_temperature !=THERMAL_TEMP_INVALID ) {if (tz->last_temperature < trip_temp && tz->temperature >= trip_temp) -thermal_notify_tz_trip_up (tz->id, trip); +thermal_notify_tz_trip_up (tz->id, trip, + tz->temperature);if (tz->last_temperature >= trip_temp && tz->temperature < (trip_temp - hyst)) -thermal_notify_tz_trip_down (tz->id, trip); +thermal_notify_tz_trip_down (tz->id, trip, + tz->temperature); }if (type ==THERMAL_TRIP_CRITICAL || type ==THERMAL_TRIP_HOT )
drivers/thermal/thermal_netlink.c +6 -5
@@ -121,7 +121,8 @@ static int thermal_genl_event_tz(struct param *p)static int thermal_genl_event_tz_trip_up (struct param *p) {if (nla_put_u32 (p->msg,THERMAL_GENL_ATTR_TZ_ID , p->tz_id) || -nla_put_u32 (p->msg,THERMAL_GENL_ATTR_TZ_TRIP_ID , p->trip_id)) +nla_put_u32 (p->msg,THERMAL_GENL_ATTR_TZ_TRIP_ID , p->trip_id) || +nla_put_u32 (p->msg,THERMAL_GENL_ATTR_TZ_TEMP , p->temp))return -EMSGSIZE ;return 0 ;
@@ -285,16 +286,16 @@ int thermal_notify_tz_disable(int tz_id)return thermal_genl_send_event (THERMAL_GENL_EVENT_TZ_DISABLE , &p); } -int thermal_notify_tz_trip_down (int tz_id,int trip_id) +int thermal_notify_tz_trip_down (int tz_id,int trip_id,int temp) { -struct param p = { .tz_id = tz_id, .trip_id = trip_id }; +struct param p = { .tz_id = tz_id, .trip_id = trip_id, .temp = temp };return thermal_genl_send_event (THERMAL_GENL_EVENT_TZ_TRIP_DOWN , &p); } -int thermal_notify_tz_trip_up (int tz_id,int trip_id) +int thermal_notify_tz_trip_up (int tz_id,int trip_id,int temp) { -struct param p = { .tz_id = tz_id, .trip_id = trip_id }; +struct param p = { .tz_id = tz_id, .trip_id = trip_id, .temp = temp };return thermal_genl_send_event (THERMAL_GENL_EVENT_TZ_TRIP_UP , &p); }
drivers/thermal/thermal_netlink.h +4 -4
@@ -11,8 +11,8 @@ int thermal_notify_tz_create(int tz_id, const char *name);int thermal_notify_tz_delete (int tz_id);int thermal_notify_tz_enable (int tz_id);int thermal_notify_tz_disable (int tz_id); -int thermal_notify_tz_trip_down (int tz_id,int id); -int thermal_notify_tz_trip_up (int tz_id,int id); +int thermal_notify_tz_trip_down (int tz_id,int id,int temp); +int thermal_notify_tz_trip_up (int tz_id,int id,int temp);int thermal_notify_tz_trip_delete (int tz_id,int id);int thermal_notify_tz_trip_add (int tz_id,int id,int type,int temp,int hyst);
@@ -49,12 +49,12 @@ static inline int thermal_notify_tz_disable(int tz_id)return 0 ; } -static inline int thermal_notify_tz_trip_down (int tz_id,int id) +static inline int thermal_notify_tz_trip_down (int tz_id,int id,int temp) {return 0 ; } -static inline int thermal_notify_tz_trip_up (int tz_id,int id) +static inline int thermal_notify_tz_trip_up (int tz_id,int id,int temp) {return 0 ; }