linux/drivers/media
Hans Verkuil 0e66100637 [media] vb2: fix 'UNBALANCED' warnings when calling vb2_thread_stop()
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>
2015-03-02 11:59:36 -03:00
..
common [media] btcx-risc: move to bt8xx 2014-12-23 10:13:19 -02:00
dvb-core [media] dvb_net: Convert local hex dump to print_hex_dump_debug 2015-02-03 18:24:44 -02:00
dvb-frontends [media] stb0899: use sign_extend32() for sign extension 2015-02-03 18:16:18 -02:00
firewire [media] firewire: Deletion of an unnecessary check before the function call "dvb_unregister_device" 2014-11-25 13:30:31 -02:00
i2c [media] adv7180: Add fast switch support 2015-02-02 11:51:38 -02:00
mmc [media] siano: fix Kconfig dependencies 2015-02-02 11:08:02 -02:00
pci mm: gup: use get_user_pages_unlocked 2015-02-11 17:06:05 -08:00
platform [media] media: platform: fix platform_no_drv_owner.cocci warnings 2015-02-02 13:35:49 -02:00
radio [media] radio/aimslab: use mdelay instead of udelay 2015-02-02 11:07:09 -02:00
rc [media] lirc_dev: avoid potential null-dereference 2015-02-03 17:33:42 -02:00
tuners [media] si2157: change firmware variable name and type 2015-01-29 18:50:28 -02:00
usb [media] lmedm04: add read snr, signal strength and ber call backs 2015-02-03 17:16:33 -02:00
v4l2-core [media] vb2: fix 'UNBALANCED' warnings when calling vb2_thread_stop() 2015-03-02 11:59:36 -03:00
Kconfig [media] bq/c-qcam, w9966, pms: move to staging in preparation for removal 2014-12-16 23:21:44 -02:00
Makefile [media] bq/c-qcam, w9966, pms: move to staging in preparation for removal 2014-12-16 23:21:44 -02: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: Fix a compiler warning in media_entity_pipeline_start() 2014-11-03 19:09:13 -02:00