aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwtracing/stm
diff options
context:
space:
mode:
authorChunyan Zhang <zhang.chunyan@linaro.org>2016-11-21 02:57:19 -0500
committerSteven Rostedt <rostedt@goodmis.org>2016-11-22 17:47:48 -0500
commit262e1f6e39143c2a0f559e2fb4a835069a7693a9 (patch)
tree933c82966d0aa045689eb1f9e0005b0fc6a9ac7c /drivers/hwtracing/stm
parent478409dd683db76cbcfe7bf8332a37f01deb0a2d (diff)
stm class: ftrace: Add ftrace-export-over-stm driver
This patch adds a driver that models itself as an stm_source called stm_ftrace. Once the stm device and stm_ftrace have been linked via sysfs, the driver registers itself as a trace_export and everything passed to the interface from Ftrace subsystem will end up in the STM trace engine. Link: http://lkml.kernel.org/r/1479715043-6534-3-git-send-email-zhang.chunyan@linaro.org Signed-off-by: Chunyan Zhang <zhang.chunyan@linaro.org> Acked-by: Alexander Shishkin <alexander.shishkin@linux.intel.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'drivers/hwtracing/stm')
-rw-r--r--drivers/hwtracing/stm/Kconfig11
-rw-r--r--drivers/hwtracing/stm/Makefile2
-rw-r--r--drivers/hwtracing/stm/ftrace.c87
3 files changed, 100 insertions, 0 deletions
diff --git a/drivers/hwtracing/stm/Kconfig b/drivers/hwtracing/stm/Kconfig
index 847a39b35307..723e2d90083d 100644
--- a/drivers/hwtracing/stm/Kconfig
+++ b/drivers/hwtracing/stm/Kconfig
@@ -39,4 +39,15 @@ config STM_SOURCE_HEARTBEAT
39 If you want to send heartbeat messages over STM devices, 39 If you want to send heartbeat messages over STM devices,
40 say Y. 40 say Y.
41 41
42config STM_SOURCE_FTRACE
43 tristate "Copy the output from kernel Ftrace to STM engine"
44 depends on FUNCTION_TRACER
45 help
46 This option can be used to copy the output from kernel Ftrace
47 to STM engine. Enabling this option will introduce a slight
48 timing effect.
49
50 If you want to send kernel Ftrace messages over STM devices,
51 say Y.
52
42endif 53endif
diff --git a/drivers/hwtracing/stm/Makefile b/drivers/hwtracing/stm/Makefile
index a9ce3d487e57..3abd84ce13d4 100644
--- a/drivers/hwtracing/stm/Makefile
+++ b/drivers/hwtracing/stm/Makefile
@@ -6,6 +6,8 @@ obj-$(CONFIG_STM_DUMMY) += dummy_stm.o
6 6
7obj-$(CONFIG_STM_SOURCE_CONSOLE) += stm_console.o 7obj-$(CONFIG_STM_SOURCE_CONSOLE) += stm_console.o
8obj-$(CONFIG_STM_SOURCE_HEARTBEAT) += stm_heartbeat.o 8obj-$(CONFIG_STM_SOURCE_HEARTBEAT) += stm_heartbeat.o
9obj-$(CONFIG_STM_SOURCE_FTRACE) += stm_ftrace.o
9 10
10stm_console-y := console.o 11stm_console-y := console.o
11stm_heartbeat-y := heartbeat.o 12stm_heartbeat-y := heartbeat.o
13stm_ftrace-y := ftrace.o
diff --git a/drivers/hwtracing/stm/ftrace.c b/drivers/hwtracing/stm/ftrace.c
new file mode 100644
index 000000000000..bd126a7c6da2
--- /dev/null
+++ b/drivers/hwtracing/stm/ftrace.c
@@ -0,0 +1,87 @@
1/*
2 * Simple kernel driver to link kernel Ftrace and an STM device
3 * Copyright (c) 2016, Linaro Ltd.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * STM Ftrace will be registered as a trace_export.
15 */
16
17#include <linux/module.h>
18#include <linux/stm.h>
19#include <linux/trace.h>
20
21#define STM_FTRACE_NR_CHANNELS 1
22#define STM_FTRACE_CHAN 0
23
24static int stm_ftrace_link(struct stm_source_data *data);
25static void stm_ftrace_unlink(struct stm_source_data *data);
26
27static struct stm_ftrace {
28 struct stm_source_data data;
29 struct trace_export ftrace;
30} stm_ftrace = {
31 .data = {
32 .name = "ftrace",
33 .nr_chans = STM_FTRACE_NR_CHANNELS,
34 .link = stm_ftrace_link,
35 .unlink = stm_ftrace_unlink,
36 },
37};
38
39/**
40 * stm_ftrace_write() - write data to STM via 'stm_ftrace' source
41 * @buf: buffer containing the data packet
42 * @len: length of the data packet
43 */
44static void notrace
45stm_ftrace_write(const void *buf, unsigned int len)
46{
47 stm_source_write(&stm_ftrace.data, STM_FTRACE_CHAN, buf, len);
48}
49
50static int stm_ftrace_link(struct stm_source_data *data)
51{
52 struct stm_ftrace *sf = container_of(data, struct stm_ftrace, data);
53
54 sf->ftrace.write = stm_ftrace_write;
55
56 return register_ftrace_export(&sf->ftrace);
57}
58
59static void stm_ftrace_unlink(struct stm_source_data *data)
60{
61 struct stm_ftrace *sf = container_of(data, struct stm_ftrace, data);
62
63 unregister_ftrace_export(&sf->ftrace);
64}
65
66static int __init stm_ftrace_init(void)
67{
68 int ret;
69
70 ret = stm_source_register_device(NULL, &stm_ftrace.data);
71 if (ret)
72 pr_err("Failed to register stm_source - ftrace.\n");
73
74 return ret;
75}
76
77static void __exit stm_ftrace_exit(void)
78{
79 stm_source_unregister_device(&stm_ftrace.data);
80}
81
82module_init(stm_ftrace_init);
83module_exit(stm_ftrace_exit);
84
85MODULE_LICENSE("GPL v2");
86MODULE_DESCRIPTION("stm_ftrace driver");
87MODULE_AUTHOR("Chunyan Zhang <zhang.chunyan@linaro.org>");