Skip to content

Commit eabd9a3

Browse files
gwendalcrbleungatchromium
authored andcommitted
platform: chrome: Split trace include file
cros_ec_trace.h defined 5 tracing events, 2 for cros_ec_proto and 3 for cros_ec_sensorhub_ring. These 2 files are in different kernel modules, the traces are defined twice in the kernel which leads to problem enabling only some traces. Move sensorhub traces from cros_ec_trace.h to cros_ec_sensorhub_trace.h and enable them only in cros_ec_sensorhub kernel module. Check we can now enable any single traces: without this patch, we can only enable all sensorhub traces or none. Fixes: d453ceb ("platform/chrome: sensorhub: Add trace events for sample") Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20220122001301.640337-1-gwendal@chromium.org Signed-off-by: Benson Leung <bleung@chromium.org>
1 parent b579f13 commit eabd9a3

File tree

4 files changed

+127
-97
lines changed

4 files changed

+127
-97
lines changed

drivers/platform/chrome/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
# tell define_trace.h where to find the cros ec trace header
44
CFLAGS_cros_ec_trace.o:= -I$(src)
5+
CFLAGS_cros_ec_sensorhub_ring.o:= -I$(src)
56

67
obj-$(CONFIG_CHROMEOS_LAPTOP) += chromeos_laptop.o
78
obj-$(CONFIG_CHROMEOS_PSTORE) += chromeos_pstore.o
@@ -20,7 +21,7 @@ obj-$(CONFIG_CROS_EC_CHARDEV) += cros_ec_chardev.o
2021
obj-$(CONFIG_CROS_EC_LIGHTBAR) += cros_ec_lightbar.o
2122
obj-$(CONFIG_CROS_EC_VBC) += cros_ec_vbc.o
2223
obj-$(CONFIG_CROS_EC_DEBUGFS) += cros_ec_debugfs.o
23-
cros-ec-sensorhub-objs := cros_ec_sensorhub.o cros_ec_sensorhub_ring.o cros_ec_trace.o
24+
cros-ec-sensorhub-objs := cros_ec_sensorhub.o cros_ec_sensorhub_ring.o
2425
obj-$(CONFIG_CROS_EC_SENSORHUB) += cros-ec-sensorhub.o
2526
obj-$(CONFIG_CROS_EC_SYSFS) += cros_ec_sysfs.o
2627
obj-$(CONFIG_CROS_USBPD_LOGGER) += cros_usbpd_logger.o

drivers/platform/chrome/cros_ec_sensorhub_ring.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
#include <linux/sort.h>
1818
#include <linux/slab.h>
1919

20-
#include "cros_ec_trace.h"
20+
#define CREATE_TRACE_POINTS
21+
#include "cros_ec_sensorhub_trace.h"
2122

2223
/* Precision of fixed point for the m values from the filter */
2324
#define M_PRECISION BIT(23)
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* Trace events for the ChromeOS Sensorhub kernel module
4+
*
5+
* Copyright 2021 Google LLC.
6+
*/
7+
8+
#undef TRACE_SYSTEM
9+
#define TRACE_SYSTEM cros_ec
10+
11+
#if !defined(_CROS_EC_SENSORHUB_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
12+
#define _CROS_EC_SENSORHUB_TRACE_H_
13+
14+
#include <linux/types.h>
15+
#include <linux/platform_data/cros_ec_sensorhub.h>
16+
17+
#include <linux/tracepoint.h>
18+
19+
TRACE_EVENT(cros_ec_sensorhub_timestamp,
20+
TP_PROTO(u32 ec_sample_timestamp, u32 ec_fifo_timestamp, s64 fifo_timestamp,
21+
s64 current_timestamp, s64 current_time),
22+
TP_ARGS(ec_sample_timestamp, ec_fifo_timestamp, fifo_timestamp, current_timestamp,
23+
current_time),
24+
TP_STRUCT__entry(
25+
__field(u32, ec_sample_timestamp)
26+
__field(u32, ec_fifo_timestamp)
27+
__field(s64, fifo_timestamp)
28+
__field(s64, current_timestamp)
29+
__field(s64, current_time)
30+
__field(s64, delta)
31+
),
32+
TP_fast_assign(
33+
__entry->ec_sample_timestamp = ec_sample_timestamp;
34+
__entry->ec_fifo_timestamp = ec_fifo_timestamp;
35+
__entry->fifo_timestamp = fifo_timestamp;
36+
__entry->current_timestamp = current_timestamp;
37+
__entry->current_time = current_time;
38+
__entry->delta = current_timestamp - current_time;
39+
),
40+
TP_printk("ec_ts: %9u, ec_fifo_ts: %9u, fifo_ts: %12lld, curr_ts: %12lld, curr_time: %12lld, delta %12lld",
41+
__entry->ec_sample_timestamp,
42+
__entry->ec_fifo_timestamp,
43+
__entry->fifo_timestamp,
44+
__entry->current_timestamp,
45+
__entry->current_time,
46+
__entry->delta
47+
)
48+
);
49+
50+
TRACE_EVENT(cros_ec_sensorhub_data,
51+
TP_PROTO(u32 ec_sensor_num, u32 ec_fifo_timestamp, s64 fifo_timestamp,
52+
s64 current_timestamp, s64 current_time),
53+
TP_ARGS(ec_sensor_num, ec_fifo_timestamp, fifo_timestamp, current_timestamp, current_time),
54+
TP_STRUCT__entry(
55+
__field(u32, ec_sensor_num)
56+
__field(u32, ec_fifo_timestamp)
57+
__field(s64, fifo_timestamp)
58+
__field(s64, current_timestamp)
59+
__field(s64, current_time)
60+
__field(s64, delta)
61+
),
62+
TP_fast_assign(
63+
__entry->ec_sensor_num = ec_sensor_num;
64+
__entry->ec_fifo_timestamp = ec_fifo_timestamp;
65+
__entry->fifo_timestamp = fifo_timestamp;
66+
__entry->current_timestamp = current_timestamp;
67+
__entry->current_time = current_time;
68+
__entry->delta = current_timestamp - current_time;
69+
),
70+
TP_printk("ec_num: %4u, ec_fifo_ts: %9u, fifo_ts: %12lld, curr_ts: %12lld, curr_time: %12lld, delta %12lld",
71+
__entry->ec_sensor_num,
72+
__entry->ec_fifo_timestamp,
73+
__entry->fifo_timestamp,
74+
__entry->current_timestamp,
75+
__entry->current_time,
76+
__entry->delta
77+
)
78+
);
79+
80+
TRACE_EVENT(cros_ec_sensorhub_filter,
81+
TP_PROTO(struct cros_ec_sensors_ts_filter_state *state, s64 dx, s64 dy),
82+
TP_ARGS(state, dx, dy),
83+
TP_STRUCT__entry(
84+
__field(s64, dx)
85+
__field(s64, dy)
86+
__field(s64, median_m)
87+
__field(s64, median_error)
88+
__field(s64, history_len)
89+
__field(s64, x)
90+
__field(s64, y)
91+
),
92+
TP_fast_assign(
93+
__entry->dx = dx;
94+
__entry->dy = dy;
95+
__entry->median_m = state->median_m;
96+
__entry->median_error = state->median_error;
97+
__entry->history_len = state->history_len;
98+
__entry->x = state->x_offset;
99+
__entry->y = state->y_offset;
100+
),
101+
TP_printk("dx: %12lld. dy: %12lld median_m: %12lld median_error: %12lld len: %lld x: %12lld y: %12lld",
102+
__entry->dx,
103+
__entry->dy,
104+
__entry->median_m,
105+
__entry->median_error,
106+
__entry->history_len,
107+
__entry->x,
108+
__entry->y
109+
)
110+
);
111+
112+
113+
#endif /* _CROS_EC_SENSORHUB_TRACE_H_ */
114+
115+
/* this part must be outside header guard */
116+
117+
#undef TRACE_INCLUDE_PATH
118+
#define TRACE_INCLUDE_PATH .
119+
120+
#undef TRACE_INCLUDE_FILE
121+
#define TRACE_INCLUDE_FILE cros_ec_sensorhub_trace
122+
123+
#include <trace/define_trace.h>

drivers/platform/chrome/cros_ec_trace.h

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include <linux/types.h>
1616
#include <linux/platform_data/cros_ec_commands.h>
1717
#include <linux/platform_data/cros_ec_proto.h>
18-
#include <linux/platform_data/cros_ec_sensorhub.h>
1918

2019
#include <linux/tracepoint.h>
2120

@@ -71,100 +70,6 @@ TRACE_EVENT(cros_ec_request_done,
7170
__entry->retval)
7271
);
7372

74-
TRACE_EVENT(cros_ec_sensorhub_timestamp,
75-
TP_PROTO(u32 ec_sample_timestamp, u32 ec_fifo_timestamp, s64 fifo_timestamp,
76-
s64 current_timestamp, s64 current_time),
77-
TP_ARGS(ec_sample_timestamp, ec_fifo_timestamp, fifo_timestamp, current_timestamp,
78-
current_time),
79-
TP_STRUCT__entry(
80-
__field(u32, ec_sample_timestamp)
81-
__field(u32, ec_fifo_timestamp)
82-
__field(s64, fifo_timestamp)
83-
__field(s64, current_timestamp)
84-
__field(s64, current_time)
85-
__field(s64, delta)
86-
),
87-
TP_fast_assign(
88-
__entry->ec_sample_timestamp = ec_sample_timestamp;
89-
__entry->ec_fifo_timestamp = ec_fifo_timestamp;
90-
__entry->fifo_timestamp = fifo_timestamp;
91-
__entry->current_timestamp = current_timestamp;
92-
__entry->current_time = current_time;
93-
__entry->delta = current_timestamp - current_time;
94-
),
95-
TP_printk("ec_ts: %9u, ec_fifo_ts: %9u, fifo_ts: %12lld, curr_ts: %12lld, curr_time: %12lld, delta %12lld",
96-
__entry->ec_sample_timestamp,
97-
__entry->ec_fifo_timestamp,
98-
__entry->fifo_timestamp,
99-
__entry->current_timestamp,
100-
__entry->current_time,
101-
__entry->delta
102-
)
103-
);
104-
105-
TRACE_EVENT(cros_ec_sensorhub_data,
106-
TP_PROTO(u32 ec_sensor_num, u32 ec_fifo_timestamp, s64 fifo_timestamp,
107-
s64 current_timestamp, s64 current_time),
108-
TP_ARGS(ec_sensor_num, ec_fifo_timestamp, fifo_timestamp, current_timestamp, current_time),
109-
TP_STRUCT__entry(
110-
__field(u32, ec_sensor_num)
111-
__field(u32, ec_fifo_timestamp)
112-
__field(s64, fifo_timestamp)
113-
__field(s64, current_timestamp)
114-
__field(s64, current_time)
115-
__field(s64, delta)
116-
),
117-
TP_fast_assign(
118-
__entry->ec_sensor_num = ec_sensor_num;
119-
__entry->ec_fifo_timestamp = ec_fifo_timestamp;
120-
__entry->fifo_timestamp = fifo_timestamp;
121-
__entry->current_timestamp = current_timestamp;
122-
__entry->current_time = current_time;
123-
__entry->delta = current_timestamp - current_time;
124-
),
125-
TP_printk("ec_num: %4u, ec_fifo_ts: %9u, fifo_ts: %12lld, curr_ts: %12lld, curr_time: %12lld, delta %12lld",
126-
__entry->ec_sensor_num,
127-
__entry->ec_fifo_timestamp,
128-
__entry->fifo_timestamp,
129-
__entry->current_timestamp,
130-
__entry->current_time,
131-
__entry->delta
132-
)
133-
);
134-
135-
TRACE_EVENT(cros_ec_sensorhub_filter,
136-
TP_PROTO(struct cros_ec_sensors_ts_filter_state *state, s64 dx, s64 dy),
137-
TP_ARGS(state, dx, dy),
138-
TP_STRUCT__entry(
139-
__field(s64, dx)
140-
__field(s64, dy)
141-
__field(s64, median_m)
142-
__field(s64, median_error)
143-
__field(s64, history_len)
144-
__field(s64, x)
145-
__field(s64, y)
146-
),
147-
TP_fast_assign(
148-
__entry->dx = dx;
149-
__entry->dy = dy;
150-
__entry->median_m = state->median_m;
151-
__entry->median_error = state->median_error;
152-
__entry->history_len = state->history_len;
153-
__entry->x = state->x_offset;
154-
__entry->y = state->y_offset;
155-
),
156-
TP_printk("dx: %12lld. dy: %12lld median_m: %12lld median_error: %12lld len: %lld x: %12lld y: %12lld",
157-
__entry->dx,
158-
__entry->dy,
159-
__entry->median_m,
160-
__entry->median_error,
161-
__entry->history_len,
162-
__entry->x,
163-
__entry->y
164-
)
165-
);
166-
167-
16873
#endif /* _CROS_EC_TRACE_H_ */
16974

17075
/* this part must be outside header guard */

0 commit comments

Comments
 (0)