[PATCH 08/11] media: Add HW run/done trace events
From: Detlev Casanova
Date: Thu Feb 12 2026 - 11:29:29 EST
The events can be fired by drivers when the hardware is run and when it
is done.
That can be used by userspace tracers to see HW performance and usage.
The hw_done event allows setting the number of clock cycles the HW needed
to do the work, to help tools evaluate performances.
Signed-off-by: Detlev Casanova <detlev.casanova@xxxxxxxxxxxxx>
---
drivers/media/v4l2-core/v4l2-trace.c | 3 +++
include/trace/events/v4l2.h | 30 ++++++++++++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git a/drivers/media/v4l2-core/v4l2-trace.c b/drivers/media/v4l2-core/v4l2-trace.c
index 9ce54c1968ef..2fbc05dde346 100644
--- a/drivers/media/v4l2-core/v4l2-trace.c
+++ b/drivers/media/v4l2-core/v4l2-trace.c
@@ -12,6 +12,9 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(vb2_v4l2_buf_queue);
EXPORT_TRACEPOINT_SYMBOL_GPL(vb2_v4l2_dqbuf);
EXPORT_TRACEPOINT_SYMBOL_GPL(vb2_v4l2_qbuf);
+EXPORT_TRACEPOINT_SYMBOL_GPL(v4l2_hw_run);
+EXPORT_TRACEPOINT_SYMBOL_GPL(v4l2_hw_done);
+
/* Export AV1 controls */
EXPORT_TRACEPOINT_SYMBOL_GPL(v4l2_ctrl_av1_sequence);
EXPORT_TRACEPOINT_SYMBOL_GPL(v4l2_ctrl_av1_frame);
diff --git a/include/trace/events/v4l2.h b/include/trace/events/v4l2.h
index bec310eaedc7..4a9dcdbea22b 100644
--- a/include/trace/events/v4l2.h
+++ b/include/trace/events/v4l2.h
@@ -290,6 +290,36 @@ DEFINE_EVENT(v4l2_stream_class, v4l2_streamoff,
TP_ARGS(tgid, fd)
);
+DEFINE_EVENT(v4l2_stream_class, v4l2_hw_run,
+ TP_PROTO(u32 tgid, u32 fd),
+ TP_ARGS(tgid, fd)
+);
+
+DECLARE_EVENT_CLASS(v4l2_hw_done_class,
+ TP_PROTO(u32 tgid, u32 fd, u32 hw_cycles),
+ TP_ARGS(tgid, fd, hw_cycles),
+
+ TP_STRUCT__entry(
+ __field(u32, tgid)
+ __field(u32, fd)
+ __field(u32, hw_cycles)
+ ),
+
+ TP_fast_assign(
+ __entry->tgid = tgid;
+ __entry->fd = fd;
+ __entry->hw_cycles = hw_cycles;
+ ),
+
+ TP_printk("tgid = %u, fd = %u, hw_cycles = %u",
+ __entry->tgid, __entry->fd, __entry->hw_cycles)
+);
+
+DEFINE_EVENT(v4l2_hw_done_class, v4l2_hw_done,
+ TP_PROTO(u32 tgid, u32 fd, u32 hw_cycles),
+ TP_ARGS(tgid, fd, hw_cycles)
+);
+
#endif /* if !defined(_TRACE_V4L2_H) || defined(TRACE_HEADER_MULTI_READ) */
/* This part must be outside protection */
--
2.53.0