From d513fa226c29a5b1ebffa062469fbc9ae7dd0327 Mon Sep 17 00:00:00 2001 From: davidchao Date: Wed, 19 Jun 2024 00:04:51 +0000 Subject: [PATCH] ANDROID: thermal: Add vendor thermal genl check Add vendor enable_thermal_genl_check logic. Filter on-die tz genl event. To avoid thermal-hal being woken up all the time by thermal genl events, only the selected thermal_zone and cooling_device can send events from kernel. Bug: 170682696 Bug: 291846209 Test: boot and thermal-hal can receive thermal genl events from kernel Change-Id: Idb3f4b07a2a2740c01d8785910878bfe6edc832d Signed-off-by: davidchao Signed-off-by: Will McVicker --- drivers/android/vendor_hooks.c | 2 ++ drivers/thermal/thermal_netlink.c | 6 ++++++ include/trace/hooks/thermal.h | 19 +++++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 include/trace/hooks/thermal.h diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 62b071ac0b2f..b35327eeb020 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -208,3 +209,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_flush_wq_wait_start); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_flush_wq_wait_finish); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_flush_work_wait_start); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_flush_work_wait_finish); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_enable_thermal_genl_check); diff --git a/drivers/thermal/thermal_netlink.c b/drivers/thermal/thermal_netlink.c index f3c58c708969..edeead69bc2f 100644 --- a/drivers/thermal/thermal_netlink.c +++ b/drivers/thermal/thermal_netlink.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "thermal_core.h" @@ -270,6 +271,11 @@ static int thermal_genl_send_event(enum thermal_genl_event event, struct sk_buff *msg; int ret = -EMSGSIZE; void *hdr; + int enable_thermal_genl = 1; + + trace_android_vh_enable_thermal_genl_check(event, p->tz_id, &enable_thermal_genl); + if (!enable_thermal_genl) + return 0; if (!thermal_group_has_listeners(THERMAL_GENL_EVENT_GROUP)) return 0; diff --git a/include/trace/hooks/thermal.h b/include/trace/hooks/thermal.h new file mode 100644 index 000000000000..2f86eab8dac9 --- /dev/null +++ b/include/trace/hooks/thermal.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM thermal + +#define TRACE_INCLUDE_PATH trace/hooks + +#if !defined(_TRACE_HOOK_THERMAL_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_HOOK_THERMAL_H + +#include + +DECLARE_HOOK(android_vh_enable_thermal_genl_check, + TP_PROTO(int event, int tz_id, int *enable_thermal_genl), + TP_ARGS(event, tz_id, enable_thermal_genl)); + +#endif /* _TRACE_HOOK_THERMAL_H */ +/* This part must be outside protection */ +#include +