From a3e8b0479685fbd2d584aaafe09ce7670d65cdc5 Mon Sep 17 00:00:00 2001 From: Manaf Meethalavalappu Pallikunhi Date: Mon, 6 Jun 2022 02:10:38 +0530 Subject: [PATCH] ANDROID: thermal: vendor hook to disable thermal cooling stats Add vendor hook to thermal to allow vendor to selectively disable thermal cooling device stats feature based on requirement. It helps vendor to optimize memory footprint due to this feature especially for low memory devices. Bug: 218825214 Change-Id: I2ec72505f03575e09229c54765584614b16a3904 Signed-off-by: Manaf Meethalavalappu Pallikunhi (cherry picked from commit f6e47fd00f24d5e814d316b03974e970dd87879e) --- drivers/android/vendor_hooks.c | 1 + drivers/thermal/thermal_sysfs.c | 22 +++++++++++++++++++++- include/trace/hooks/thermal.h | 5 +++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 9ba5ee6016cf..2f821f4b7c7e 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -401,6 +401,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_udp_recvmsg); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_tcp_recvmsg_stat); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_pci_d3_sleep); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_kmalloc_slab); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_disable_thermal_cooling_stats); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mmap_region); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_update_page_mapcount); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_add_page_to_lrulist); diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c index f52708f310e0..3251b27fc5df 100644 --- a/drivers/thermal/thermal_sysfs.c +++ b/drivers/thermal/thermal_sysfs.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "thermal_core.h" @@ -886,9 +887,22 @@ static struct attribute *cooling_device_stats_attrs[] = { NULL }; +static umode_t cooling_device_stats_is_visible(struct kobject *kobj, + struct attribute *attr, int attrno) +{ + struct thermal_cooling_device *cdev = to_cooling_device( + kobj_to_dev(kobj)); + + if (!cdev->stats) + return 0; + + return attr->mode; +} + static const struct attribute_group cooling_device_stats_attr_group = { .attrs = cooling_device_stats_attrs, - .name = "stats" + .name = "stats", + .is_visible = cooling_device_stats_is_visible, }; static void cooling_device_stats_setup(struct thermal_cooling_device *cdev) @@ -896,6 +910,12 @@ static void cooling_device_stats_setup(struct thermal_cooling_device *cdev) struct cooling_dev_stats *stats; unsigned long states; int var; + bool disable_cdev_stats = false; + + trace_android_vh_disable_thermal_cooling_stats(cdev, + &disable_cdev_stats); + if (disable_cdev_stats) + return; if (cdev->ops->get_max_state(cdev, &states)) return; diff --git a/include/trace/hooks/thermal.h b/include/trace/hooks/thermal.h index 5e61ecd38425..c438ab6ef5b6 100644 --- a/include/trace/hooks/thermal.h +++ b/include/trace/hooks/thermal.h @@ -24,6 +24,11 @@ DECLARE_HOOK(android_vh_thermal_pm_notify_suspend, TP_PROTO(struct thermal_zone_device *tz, int *irq_wakeable), TP_ARGS(tz, irq_wakeable)); +struct thermal_cooling_device; +DECLARE_HOOK(android_vh_disable_thermal_cooling_stats, + TP_PROTO(struct thermal_cooling_device *cdev, bool *disable_stats), + TP_ARGS(cdev, disable_stats)); + #endif /* _TRACE_HOOK_THERMAL_H */ /* This part must be outside protection */ #include