1 From 627530c32a43283474e9dd3e954519410ffa033a Mon Sep 17 00:00:00 2001
2 From: Frank Schaefer <fschaefer.oss@googlemail.com>
3 Date: Sat, 9 Aug 2014 06:37:20 -0300
4 Subject: media: em28xx-v4l: give back all active video buffers to the vb2 core properly on streaming stop
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 From: Frank Schaefer <fschaefer.oss@googlemail.com>
11 commit 627530c32a43283474e9dd3e954519410ffa033a upstream.
13 When a new video frame is started, the driver takes the next video buffer from
14 the list of active buffers and moves it to dev->usb_ctl.vid_buf / dev->usb_ctl.vbi_buf
15 for further processing.
17 On streaming stop we currently only give back the pending buffers from the list
18 but not the ones which are currently processed.
20 This causes the following warning from the vb2 core since kernel 3.15:
23 ------------[ cut here ]------------
24 WARNING: CPU: 1 PID: 2284 at drivers/media/v4l2-core/videobuf2-core.c:2115 __vb2_queue_cancel+0xed/0x150 [videobuf2_core]()
27 [<c0769c46>] dump_stack+0x48/0x69
28 [<c0245b69>] warn_slowpath_common+0x79/0x90
29 [<f925e4ad>] ? __vb2_queue_cancel+0xed/0x150 [videobuf2_core]
30 [<f925e4ad>] ? __vb2_queue_cancel+0xed/0x150 [videobuf2_core]
31 [<c0245bfd>] warn_slowpath_null+0x1d/0x20
32 [<f925e4ad>] __vb2_queue_cancel+0xed/0x150 [videobuf2_core]
33 [<f925fa35>] vb2_internal_streamoff+0x35/0x90 [videobuf2_core]
34 [<f925fac5>] vb2_streamoff+0x35/0x60 [videobuf2_core]
35 [<f925fb27>] vb2_ioctl_streamoff+0x37/0x40 [videobuf2_core]
36 [<f8e45895>] v4l_streamoff+0x15/0x20 [videodev]
37 [<f8e4925d>] __video_do_ioctl+0x23d/0x2d0 [videodev]
38 [<f8e49020>] ? video_ioctl2+0x20/0x20 [videodev]
39 [<f8e48c63>] video_usercopy+0x203/0x5a0 [videodev]
40 [<f8e49020>] ? video_ioctl2+0x20/0x20 [videodev]
41 [<c039d0e7>] ? fsnotify+0x1e7/0x2b0
42 [<f8e49012>] video_ioctl2+0x12/0x20 [videodev]
43 [<f8e49020>] ? video_ioctl2+0x20/0x20 [videodev]
44 [<f8e4461e>] v4l2_ioctl+0xee/0x130 [videodev]
45 [<f8e44530>] ? v4l2_open+0xf0/0xf0 [videodev]
46 [<c0378de2>] do_vfs_ioctl+0x2e2/0x4d0
47 [<c0368eec>] ? vfs_write+0x13c/0x1c0
48 [<c0369a8f>] ? vfs_writev+0x2f/0x50
49 [<c0379028>] SyS_ioctl+0x58/0x80
50 [<c076fff3>] sysenter_do_call+0x12/0x12
51 ---[ end trace 5545f934409f13f4 ]---
54 Many thanks to Hans Verkuil, whose recently added check in the vb2 core unveiled
55 this long standing issue and who has investigated it further.
57 Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
58 Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
59 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
62 drivers/media/usb/em28xx/em28xx-video.c | 10 ++++++++--
63 1 file changed, 8 insertions(+), 2 deletions(-)
65 --- a/drivers/media/usb/em28xx/em28xx-video.c
66 +++ b/drivers/media/usb/em28xx/em28xx-video.c
67 @@ -696,13 +696,16 @@ static int em28xx_stop_streaming(struct
70 spin_lock_irqsave(&dev->slock, flags);
71 + if (dev->usb_ctl.vid_buf != NULL) {
72 + vb2_buffer_done(&dev->usb_ctl.vid_buf->vb, VB2_BUF_STATE_ERROR);
73 + dev->usb_ctl.vid_buf = NULL;
75 while (!list_empty(&vidq->active)) {
76 struct em28xx_buffer *buf;
77 buf = list_entry(vidq->active.next, struct em28xx_buffer, list);
79 vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR);
81 - dev->usb_ctl.vid_buf = NULL;
82 spin_unlock_irqrestore(&dev->slock, flags);
85 @@ -724,13 +727,16 @@ int em28xx_stop_vbi_streaming(struct vb2
88 spin_lock_irqsave(&dev->slock, flags);
89 + if (dev->usb_ctl.vbi_buf != NULL) {
90 + vb2_buffer_done(&dev->usb_ctl.vbi_buf->vb, VB2_BUF_STATE_ERROR);
91 + dev->usb_ctl.vbi_buf = NULL;
93 while (!list_empty(&vbiq->active)) {
94 struct em28xx_buffer *buf;
95 buf = list_entry(vbiq->active.next, struct em28xx_buffer, list);
97 vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR);
99 - dev->usb_ctl.vbi_buf = NULL;
100 spin_unlock_irqrestore(&dev->slock, flags);