From ea8600cea83a77a6f512578ebf02de43bf680c1e Mon Sep 17 00:00:00 2001 From: davidchao Date: Mon, 1 Feb 2021 16:46:13 +0800 Subject: [PATCH] ANDROID: thermal: Add vendor thermal genl event function Add vendor enable_thermal_genl_check logic. 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 Test: boot and thermal-hal can receive thermal genl events from kernel Change-Id: I8f49d67963bed9d6d1f11c74bd274dc8967407c1 Signed-off-by: davidchao (cherry picked from commit 88133a5b0b63a55dfb138e2150a6fd22b81c65a2) Signed-off-by: J. Avila --- drivers/android/vendor_hooks.c | 2 ++ drivers/thermal/thermal_netlink.c | 6 ++++++ include/trace/hooks/thermal.h | 20 ++++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 include/trace/hooks/thermal.h diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 98894a573693..e68177ff431f 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -36,6 +36,7 @@ #include #include #include +#include /* * Export tracepoints that act as a bare tracehook (ie: have no trace event @@ -157,3 +158,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_pick_next_entity); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_check_preempt_wakeup); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rmqueue); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_pagecache_get_page); +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 1234dbe95895..0bfe30233afe 100644 --- a/drivers/thermal/thermal_netlink.c +++ b/drivers/thermal/thermal_netlink.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include "thermal_core.h" @@ -229,6 +230,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, &enable_thermal_genl); + if (!enable_thermal_genl) + return 0; msg = genlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); if (!msg) diff --git a/include/trace/hooks/thermal.h b/include/trace/hooks/thermal.h new file mode 100644 index 000000000000..0e47e0af9284 --- /dev/null +++ b/include/trace/hooks/thermal.h @@ -0,0 +1,20 @@ +/* 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 +#include + +DECLARE_HOOK(android_vh_enable_thermal_genl_check, + TP_PROTO(int event, int *enable_thermal_genl), + TP_ARGS(event, enable_thermal_genl)); + +#endif /* _TRACE_HOOK_THERMAL_H */ +/* This part must be outside protection */ +#include +