Thermal: Add thermal events tracing (ftrace)
Timo Alho [Wed, 6 Mar 2013 17:37:25 +0000 (19:37 +0200)]
Following two events in thermal framework are traced:
 - Call to handle_thermal_trip (thermal_zone_device name and temperature
   will be printed)
 - Call to thermal_cdev_update (thermal_cooling_device name and updated
   cooling state value will be printed)

Bug 1050412

Change-Id: If7e685ce26455820408d694fa720105ecae15469
Signed-off-by: Timo Alho <talho@nvidia.com>
Reviewed-on: http://git-master/r/207010
(cherry picked from commit c0e030667214f65b0ab49840081ea53d6df24d4a)
Signed-off-by: Diwakar Tundlam <dtundlam@nvidia.com>
Reviewed-on: http://git-master/r/225020
GVS: Gerrit_Virtual_Submit

drivers/thermal/thermal_sys.c
include/trace/events/thermal.h [new file with mode: 0644]

index f983feb..0466f60 100644 (file)
@@ -36,6 +36,8 @@
 #include <linux/reboot.h>
 #include <net/netlink.h>
 #include <net/genetlink.h>
+#define CREATE_TRACE_POINTS
+#include <trace/events/thermal.h>
 
 #include "thermal_core.h"
 
@@ -377,6 +379,8 @@ static void handle_thermal_trip(struct thermal_zone_device *tz, int trip)
 {
        enum thermal_trip_type type;
 
+       trace_thermal_trip(tz->type, tz->temperature/1000);
+
        tz->ops->get_trip_type(tz, trip, &type);
 
        if (type == THERMAL_TRIP_CRITICAL || type == THERMAL_TRIP_HOT)
@@ -1443,6 +1447,7 @@ void thermal_cdev_update(struct thermal_cooling_device *cdev)
        }
        mutex_unlock(&cdev->lock);
        cdev->ops->set_cur_state(cdev, target);
+       trace_cooling_device_update(cdev->type, target);
        cdev->updated = true;
 }
 EXPORT_SYMBOL(thermal_cdev_update);
diff --git a/include/trace/events/thermal.h b/include/trace/events/thermal.h
new file mode 100644 (file)
index 0000000..43a1921
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2013, NVIDIA CORPORATION.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM thermal
+
+#if !defined(_TRACE_THERMAL_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_THERMAL_H
+
+#include <linux/string.h>
+#include <linux/thermal.h>
+#include <linux/tracepoint.h>
+
+TRACE_EVENT(thermal_trip,
+
+           TP_PROTO(const char *type, int temp),
+
+           TP_ARGS(type, temp),
+
+           TP_STRUCT__entry(
+                            __array(char, type, THERMAL_NAME_LENGTH)
+                            __field(int, temp)
+                            ),
+
+           TP_fast_assign(
+                          memcpy(__entry->type, type, THERMAL_NAME_LENGTH);
+                          __entry->temp = temp;
+                          ),
+
+           TP_printk("%s = %d", __entry->type, __entry->temp)
+           );
+
+TRACE_EVENT(cooling_device_update,
+
+           TP_PROTO(const char *type, long target),
+
+           TP_ARGS(type, target),
+
+           TP_STRUCT__entry(
+                            __array(char, type, THERMAL_NAME_LENGTH)
+                            __field(long, target)
+                            ),
+
+           TP_fast_assign(
+                          memcpy(__entry->type, type, THERMAL_NAME_LENGTH);
+                          __entry->target = target;
+                          ),
+
+           TP_printk("%s -> %ld", __entry->type, __entry->target)
+           );
+
+
+#endif /* _TRACE_THERMAL_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>