linux/drivers/media
Hans Verkuil c6aa7146f1 [media] vb2: fix 'UNBALANCED' warnings when calling vb2_thread_stop()
[ Upstream commit 0e66100637 ]

Stopping the vb2 thread (as used by several DVB devices) can result
in an 'UNBALANCED' warning such as this:

vb2: counters for queue ffff880407ee9828: UNBALANCED!
vb2:     setup: 1 start_streaming: 1 stop_streaming: 1
vb2:     wait_prepare: 249333 wait_finish: 249334

This is due to a race condition between stopping the thread and
calling vb2_internal_streamoff(). While I have not been able to deduce
the exact mechanism how this race condition can produce this warning,
I can see that the way the stream is stopped is likely to lead to a
race somewhere.

This patch simplifies how this is done by first ensuring that the
thread is completely stopped before cleaning up the vb2 queue. It
does that by setting threadio->stop to true, followed by a call to
vb2_queue_error() which will wake up the thread. The thread sees that
'stop' is true and it will exit.

The call to kthread_stop() waits until the thread has exited, and only
then is the queue cleaned up by calling __vb2_cleanup_fileio().

This is a much cleaner sequence and the warning has now disappeared.

Reported-by: Jurgen Kramer <gtmkramer@xs4all.nl>
Tested-by: Jurgen Kramer <gtmkramer@xs4all.nl>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Cc: <stable@vger.kernel.org>      # for v3.18 and up
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
History 2015-04-24 17:14:09 -04:00
..
common [media] saa7146: Create a device name before it's used 2014-10-21 08:51:44 -02:00
dvb-core [media] dvb-core: set default properties of ISDB-S 2014-11-03 16:40:09 -02:00
dvb-frontends si2168: define symbol rate limits 2015-03-06 14:52:49 -08:00
firewire [media] firewire: firedtv-avc: fix more potential buffer overflow 2014-09-23 16:13:39 -03:00
i2c smiapp: Take mutex during PLL update in sensor initialisation 2015-01-27 08:29:39 -08:00
mmc [media] siano: get rid of CammelCase from smscoreapi.h 2013-03-21 10:03:16 -03:00
parport [media] pms: Fix a bad usage of the stack 2014-09-26 06:47:55 -03:00
pci cx23885: Split Hauppauge WinTV Starburst from HVR4400 card entry 2015-01-29 17:40:44 -08:00
platform [media] soc-camera: Fix devm_kfree() in soc_of_bind() 2015-04-24 17:14:09 -04:00
radio [media] wl128x: fix fmdbg compiler warning 2014-10-24 09:27:34 -02:00
rc rc-main: Re-apply filter for no-op protocol change 2015-03-06 14:52:51 -08:00
tuners [media] xc5000: use after free in release() 2014-10-24 09:29:28 -02:00
usb em28xx-audio: fix missing newlines, again 2015-03-06 14:52:52 -08:00
v4l2-core [media] vb2: fix 'UNBALANCED' warnings when calling vb2_thread_stop() 2015-04-24 17:14:09 -04:00
Kconfig [media] Kconfig: do not select SPI bus on sub-driver auto-select 2014-09-04 12:18:49 -03:00
Makefile [media] move i2c files into drivers/media/i2c 2012-09-06 18:42:54 -03:00
media-device.c [media] media: Use strlcpy instead of custom code 2014-09-21 20:27:08 -03:00
media-devnode.c [media] media-devnode: just return 0 instead of using a var 2014-09-03 17:59:28 -03:00
media-entity.c [media] media: Check for active links on pads with MEDIA_PAD_FL_MUST_CONNECT flag 2013-12-04 15:03:45 -02:00