From: Emil Velikov <emil.velikov@xxxxxxxxxxxxx> To correlate the buffer handling with specific jobs, we need to provide the file handle (pointer) used. Signed-off-by: Emil Velikov <emil.velikov@xxxxxxxxxxxxx> --- drivers/media/v4l2-core/v4l2-ioctl.c | 10 ++++++++-- include/trace/events/v4l2.h | 22 ++++++++++++---------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index 31d1342e61e8..4b56493a1bae 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -3343,10 +3343,16 @@ video_usercopy(struct file *file, unsigned int orig_cmd, unsigned long arg, } if (err == 0) { + struct video_device *vdev = video_devdata(file); + struct v4l2_fh *fh = NULL; + + if (test_bit(V4L2_FL_USES_V4L2_FH, &vdev->flags)) + fh = file->private_data; + if (cmd == VIDIOC_DQBUF) - trace_v4l2_dqbuf(video_devdata(file)->minor, parg); + trace_v4l2_dqbuf(fh, parg); else if (cmd == VIDIOC_QBUF) - trace_v4l2_qbuf(video_devdata(file)->minor, parg); + trace_v4l2_qbuf(fh, parg); } if (has_array_args) { diff --git a/include/trace/events/v4l2.h b/include/trace/events/v4l2.h index 248bc09bfc99..e07311cfe5ca 100644 --- a/include/trace/events/v4l2.h +++ b/include/trace/events/v4l2.h @@ -7,6 +7,7 @@ #include <linux/tracepoint.h> #include <media/videobuf2-v4l2.h> +#include <media/v4l2-device.h> /* Enums require being exported to userspace, for user tool parsing */ #undef EM @@ -98,12 +99,12 @@ SHOW_FIELD { V4L2_TC_USERBITS_8BITCHARS, "USERBITS_8BITCHARS" }) DECLARE_EVENT_CLASS(v4l2_event_class, - TP_PROTO(int minor, struct v4l2_buffer *buf), - - TP_ARGS(minor, buf), + TP_PROTO(struct v4l2_fh *fh, struct v4l2_buffer *buf), + TP_ARGS(fh, buf), TP_STRUCT__entry( __field(int, minor) + __field(struct v4l2_fh *, fh) __field(u32, index) __field(u32, type) __field(u32, bytesused) @@ -124,7 +125,8 @@ DECLARE_EVENT_CLASS(v4l2_event_class, ), TP_fast_assign( - __entry->minor = minor; + __entry->minor = fh ? fh->vdev->minor : -1; + __entry->fh = fh; __entry->index = buf->index; __entry->type = buf->type; __entry->bytesused = buf->bytesused; @@ -144,12 +146,12 @@ DECLARE_EVENT_CLASS(v4l2_event_class, __entry->sequence = buf->sequence; ), - TP_printk("minor = %d, index = %u, type = %s, bytesused = %u, " + TP_printk("minor = %d, fh = %p, index = %u, type = %s, bytesused = %u, " "flags = %s, field = %s, timestamp = %llu, " "timecode = { type = %s, flags = %s, frames = %u, " "seconds = %u, minutes = %u, hours = %u, " "userbits = { %u %u %u %u } }, sequence = %u", __entry->minor, - __entry->index, show_type(__entry->type), + __entry->fh, __entry->index, show_type(__entry->type), __entry->bytesused, show_flags(__entry->flags), show_field(__entry->field), @@ -169,13 +171,13 @@ DECLARE_EVENT_CLASS(v4l2_event_class, ) DEFINE_EVENT(v4l2_event_class, v4l2_dqbuf, - TP_PROTO(int minor, struct v4l2_buffer *buf), - TP_ARGS(minor, buf) + TP_PROTO(struct v4l2_fh *fh, struct v4l2_buffer *buf), + TP_ARGS(fh, buf) ); DEFINE_EVENT(v4l2_event_class, v4l2_qbuf, - TP_PROTO(int minor, struct v4l2_buffer *buf), - TP_ARGS(minor, buf) + TP_PROTO(struct v4l2_fh *fh, struct v4l2_buffer *buf), + TP_ARGS(fh, buf) ); DECLARE_EVENT_CLASS(vb2_v4l2_event_class, -- 2.31.1