diff mbox series

[4/5] media: v4l2-mem2mem: add v4l2_m2m_buf_done trace point

Message ID 20210517183801.1255496-5-emil.l.velikov@gmail.com (mailing list archive)
State New, archived
Headers show
Series [1/5] media: v4l2: print the fh, during qbuf/dqbuf tracing | expand

Commit Message

Emil Velikov May 17, 2021, 6:38 p.m. UTC
From: Emil Velikov <emil.velikov@collabora.com>

Move the function out of the header, as required by the trace API and
add a tracepoint.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
---
 drivers/media/v4l2-core/v4l2-mem2mem.c |  9 ++++++
 drivers/media/v4l2-core/v4l2-trace.c   |  1 +
 include/media/v4l2-mem2mem.h           | 10 +++----
 include/trace/events/v4l2.h            | 41 ++++++++++++++++++++++++++
 4 files changed, 56 insertions(+), 5 deletions(-)

Comments

Ezequiel Garcia June 3, 2021, 6:21 p.m. UTC | #1
Hi Emil,

On Mon, 2021-05-17 at 19:38 +0100, Emil Velikov wrote:
> From: Emil Velikov <emil.velikov@collabora.com>
> 
> Move the function out of the header, as required by the trace API and
> add a tracepoint.
> 

Same thing here, about too short commit descriptions.
 
> Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
> ---
>  drivers/media/v4l2-core/v4l2-mem2mem.c |  9 ++++++
>  drivers/media/v4l2-core/v4l2-trace.c   |  1 +
>  include/media/v4l2-mem2mem.h           | 10 +++----
>  include/trace/events/v4l2.h            | 41 ++++++++++++++++++++++++++
>  4 files changed, 56 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c
> index bf83d1fae701..a83d3e4e7a85 100644
> --- a/drivers/media/v4l2-core/v4l2-mem2mem.c
> +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c
> @@ -555,6 +555,15 @@ void v4l2_m2m_buf_done_and_job_finish(struct v4l2_m2m_dev *m2m_dev,
>  }
>  EXPORT_SYMBOL(v4l2_m2m_buf_done_and_job_finish);
>  
> +void
> +v4l2_m2m_buf_done(struct vb2_v4l2_buffer *buf, enum vb2_buffer_state state)
> +{
> +       // TODO: Emil move the trace after done?
> +       trace_v4l2_m2m_buf_done(&buf->vb2_buf, state);

There's a trace already in vb2_buffer_done, is that one not enough,
or not useful?

> +       vb2_buffer_done(&buf->vb2_buf, state);
> +}
> +EXPORT_SYMBOL(v4l2_m2m_buf_done);
> +
>  void v4l2_m2m_suspend(struct v4l2_m2m_dev *m2m_dev)
>  {
>         unsigned long flags;
> diff --git a/drivers/media/v4l2-core/v4l2-trace.c b/drivers/media/v4l2-core/v4l2-trace.c
> index cde408d06fdc..b70208101f3c 100644
> --- a/drivers/media/v4l2-core/v4l2-trace.c
> +++ b/drivers/media/v4l2-core/v4l2-trace.c
> @@ -11,6 +11,7 @@ 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_ioctl_s_fmt);
> +EXPORT_TRACEPOINT_SYMBOL_GPL(v4l2_m2m_buf_done);
>  EXPORT_TRACEPOINT_SYMBOL_GPL(v4l2_m2m_schedule);
>  EXPORT_TRACEPOINT_SYMBOL_GPL(v4l2_m2m_schedule_failed);
>  EXPORT_TRACEPOINT_SYMBOL_GPL(v4l2_m2m_queue_job);
> diff --git a/include/media/v4l2-mem2mem.h b/include/media/v4l2-mem2mem.h
> index 82bf54254bd8..013fd355ff82 100644
> --- a/include/media/v4l2-mem2mem.h
> +++ b/include/media/v4l2-mem2mem.h
> @@ -229,11 +229,11 @@ void v4l2_m2m_buf_done_and_job_finish(struct v4l2_m2m_dev *m2m_dev,
>                                       struct v4l2_m2m_ctx *m2m_ctx,
>                                       enum vb2_buffer_state state);
>  
> -static inline void
> -v4l2_m2m_buf_done(struct vb2_v4l2_buffer *buf, enum vb2_buffer_state state)
> -{
> -       vb2_buffer_done(&buf->vb2_buf, state);
> -}
> +/**
> + * Something something

Something needs documented :)

Thanks,
Ezequiel
diff mbox series

Patch

diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c
index bf83d1fae701..a83d3e4e7a85 100644
--- a/drivers/media/v4l2-core/v4l2-mem2mem.c
+++ b/drivers/media/v4l2-core/v4l2-mem2mem.c
@@ -555,6 +555,15 @@  void v4l2_m2m_buf_done_and_job_finish(struct v4l2_m2m_dev *m2m_dev,
 }
 EXPORT_SYMBOL(v4l2_m2m_buf_done_and_job_finish);
 
+void
+v4l2_m2m_buf_done(struct vb2_v4l2_buffer *buf, enum vb2_buffer_state state)
+{
+	// TODO: Emil move the trace after done?
+	trace_v4l2_m2m_buf_done(&buf->vb2_buf, state);
+	vb2_buffer_done(&buf->vb2_buf, state);
+}
+EXPORT_SYMBOL(v4l2_m2m_buf_done);
+
 void v4l2_m2m_suspend(struct v4l2_m2m_dev *m2m_dev)
 {
 	unsigned long flags;
diff --git a/drivers/media/v4l2-core/v4l2-trace.c b/drivers/media/v4l2-core/v4l2-trace.c
index cde408d06fdc..b70208101f3c 100644
--- a/drivers/media/v4l2-core/v4l2-trace.c
+++ b/drivers/media/v4l2-core/v4l2-trace.c
@@ -11,6 +11,7 @@  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_ioctl_s_fmt);
+EXPORT_TRACEPOINT_SYMBOL_GPL(v4l2_m2m_buf_done);
 EXPORT_TRACEPOINT_SYMBOL_GPL(v4l2_m2m_schedule);
 EXPORT_TRACEPOINT_SYMBOL_GPL(v4l2_m2m_schedule_failed);
 EXPORT_TRACEPOINT_SYMBOL_GPL(v4l2_m2m_queue_job);
diff --git a/include/media/v4l2-mem2mem.h b/include/media/v4l2-mem2mem.h
index 82bf54254bd8..013fd355ff82 100644
--- a/include/media/v4l2-mem2mem.h
+++ b/include/media/v4l2-mem2mem.h
@@ -229,11 +229,11 @@  void v4l2_m2m_buf_done_and_job_finish(struct v4l2_m2m_dev *m2m_dev,
 				      struct v4l2_m2m_ctx *m2m_ctx,
 				      enum vb2_buffer_state state);
 
-static inline void
-v4l2_m2m_buf_done(struct vb2_v4l2_buffer *buf, enum vb2_buffer_state state)
-{
-	vb2_buffer_done(&buf->vb2_buf, state);
-}
+/**
+ * Something something
+ */
+void
+v4l2_m2m_buf_done(struct vb2_v4l2_buffer *buf, enum vb2_buffer_state state);
 
 /**
  * v4l2_m2m_clear_state() - clear encoding/decoding state
diff --git a/include/trace/events/v4l2.h b/include/trace/events/v4l2.h
index 8e382bad5f8e..a545f6a13d0a 100644
--- a/include/trace/events/v4l2.h
+++ b/include/trace/events/v4l2.h
@@ -56,6 +56,20 @@  SHOW_TYPE
 
 SHOW_FIELD
 
+#define show_state(state)						\
+	__print_symbolic(state, SHOW_STATE)
+
+#define SHOW_STATE							\
+	EM( VB2_BUF_STATE_DEQUEUED,	"DEQUEUED" )			\
+	EM( VB2_BUF_STATE_IN_REQUEST,	"IN_REQUEST" )			\
+	EM( VB2_BUF_STATE_PREPARING,	"PREPARING" )			\
+	EM( VB2_BUF_STATE_QUEUED,	"QUEUED" )			\
+	EM( VB2_BUF_STATE_ACTIVE,	"ACTIVE" )			\
+	EM( VB2_BUF_STATE_DONE,		"DONE" )			\
+	EMe(VB2_BUF_STATE_ERROR,	"ERROR" )
+
+SHOW_STATE
+
 #define show_reason(state)						\
 	__print_symbolic(state, SHOW_REASON)
 
@@ -282,6 +296,33 @@  DEFINE_EVENT(vb2_v4l2_event_class, vb2_v4l2_qbuf,
 	TP_ARGS(q, vb)
 );
 
+TRACE_EVENT(v4l2_m2m_buf_done,
+	TP_PROTO(struct vb2_buffer *vb, enum vb2_buffer_state state),
+	TP_ARGS(vb, state),
+
+	TP_STRUCT__entry(
+		__field(int, minor)
+		__field(struct v4l2_fh *, fh)
+		__field(s32, index)
+		__field(u32, type)
+		__field(enum vb2_buffer_state, state)
+	),
+
+	TP_fast_assign(
+		struct v4l2_fh *owner = vb->vb2_queue->owner;
+
+		__entry->minor = owner ? owner->vdev->minor : -1;
+		__entry->fh = owner;
+		__entry->index = vb->index;
+		__entry->type = vb->type;
+		__entry->state = state;
+	),
+
+	TP_printk("minor = %d, fh = %p, index = %u, type = %s, state = %s",
+		__entry->minor, __entry->fh, __entry->index,
+		show_type(__entry->type), show_state(__entry->state))
+);
+
 /*
  * v4l_m2m job tracing
  * expected order of events: