upstream: [media] v4l2: move tracepoints to video_usercopy
authorHans Verkuil <hverkuil@xs4all.nl>
Mon, 16 Dec 2013 08:45:37 +0000 (05:45 -0300)
committerChanho Park <chanho61.park@samsung.com>
Tue, 18 Nov 2014 02:55:33 +0000 (11:55 +0900)
The (d)qbuf ioctls were traced in the low-level v4l2 ioctl function. The
trace was outside the serialization lock, so that can affect the usefulness
of the timing. In addition, the __user pointer was expected instead of a
proper kernel pointer.

By moving the tracepoints to video_usercopy we ensure that the trace calls
use the correct kernel pointer, and that it happens right after the ioctl
call to the driver, so certainly inside the serialization lock.

In addition, we only trace if the call was successful.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Wade Farnsworth <wade_farnsworth@mentor.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
drivers/media/v4l2-core/v4l2-dev.c
drivers/media/v4l2-core/v4l2-ioctl.c

index 57e7051..5ece887 100644 (file)
 #include <media/v4l2-device.h>
 #include <media/v4l2-ioctl.h>
 
-
-#define CREATE_TRACE_POINTS
-#include <trace/events/v4l2.h>
-
 #define VIDEO_NUM_DEVICES      256
 #define VIDEO_NAME              "video4linux"
 
@@ -391,11 +387,6 @@ static long v4l2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
        } else
                ret = -ENOTTY;
 
-       if (cmd == VIDIOC_DQBUF)
-               trace_v4l2_dqbuf(vdev->minor, (struct v4l2_buffer *)arg);
-       else if (cmd == VIDIOC_QBUF)
-               trace_v4l2_qbuf(vdev->minor, (struct v4l2_buffer *)arg);
-
        return ret;
 }
 
index 26346a4..8f2b799 100644 (file)
@@ -29,6 +29,9 @@
 #include <media/v4l2-chip-ident.h>
 #include <media/videobuf2-core.h>
 
+#define CREATE_TRACE_POINTS
+#include <trace/events/v4l2.h>
+
 /* Zero out the end of the struct pointed to by p.  Everything after, but
  * not including, the specified field is cleared. */
 #define CLEAR_AFTER_FIELD(p, field) \
@@ -2377,6 +2380,12 @@ video_usercopy(struct file *file, unsigned int cmd, unsigned long arg,
        err = func(file, cmd, parg);
        if (err == -ENOIOCTLCMD)
                err = -ENOTTY;
+       if (err == 0) {
+               if (cmd == VIDIOC_DQBUF)
+                       trace_v4l2_dqbuf(video_devdata(file)->minor, parg);
+               else if (cmd == VIDIOC_QBUF)
+                       trace_v4l2_qbuf(video_devdata(file)->minor, parg);
+       }
 
        if (has_array_args) {
                *kernel_ptr = (void __force *)user_ptr;