dect
/
linux-2.6
Archived
13
0
Fork 0
This repository has been archived on 2022-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
linux-2.6/drivers/media/dvb/dvb-core
Devin Heitmueller 2d1969312d [media] dvb_frontend: fix race condition in stopping/starting frontend
Attached is a patch which addresses a race condition in the DVB core
related to closing/reopening the DVB frontend device in quick
succession.  This is the reason that devices such as the HVR-1300,
HVR-3000, and HVR-4000 have been failing to scan properly under MythTV
and w_scan.

The gory details of the race are described in the patch.

Devin

There is a race condition exhibited when channel scanners such as w_scan and
MythTV quickly close and then reopen the frontend device node.

Under normal conditions, the behavior is as follows:

1.  Application closes the device node
2.  DVB frontend ioctl calls dvb_frontend_release which sets
    fepriv->release_jiffies
3.  DVB frontend thread *eventually* calls dvb_frontend_is_exiting() which
    compares fepriv->release_jiffies, and shuts down the thread if timeout has
    expired
4.  Thread goes away
5.  Application opens frontend device
6.  DVB frontend ioctl() calls ts_bus_ctrl(1)
7.  DVB frontend ioctl() creates new frontend thread, which calls
    dvb_frontend_init(), which has demod driver init() routine setup initial
    register state for demod chip.
8.  Tuning request is issued.

The race occurs when the application in step 5 performs the new open() call
before the frontend thread is shutdown.  In this case the ts_bus_ctrl() call
is made, which strobes the RESET pin on the demodulator, but the
dvb_frontend_init() function never gets called because the frontend thread
hasn't gone away yet.  As a result, the initial register config for the demod
is *never* setup, causing subsequent tuning requests to fail.

If there is time between the close and open (enough for the dvb frontend
thread to be torn down), then in that case the new frontend thread is created
and thus the dvb_frontend_init() function does get called.

The fix is to set the flag which forces reinitialization if we did in fact
call ts_bus_ctrl().

This problem has been seen on the HVR-1300, HVR-3000, and HVR-4000, and is
likely occuring on other designs as well where ts_bus_ctrl() actually strobes
the reset pin on the demodulator.

Note that this patch should supercede any patches submitted for the
1300/3000/4000 which remove the code that removes GPIO code in
cx8802_dvb_advise_acquire(), which have been circulating by users for some
time now...

Canonical tracking this issue in Launchpad 439163:

Thanks to Jon Sayers from Hauppauge and Florent Audebert from Anevia S.A. for
providing hardware to test/debug with.

Signed-off-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Cc: Jon Sayers <j.sayers@hauppauge.co.uk>
Cc: Florent Audebert <florent.audebert@anevia.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2011-07-13 19:50:12 -03:00
..
Makefile
demux.h V4L/DVB (8131): dmx_write: memcpy from user-supplied pointer 2008-07-20 07:13:27 -03:00
dmxdev.c [media] dmxdev: Fix a compilation warning due to a bad type 2010-12-29 08:17:13 -02:00
dmxdev.h include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
dvb_ca_en50221.c BKL: remove extraneous #include <smp_lock.h> 2010-11-17 08:59:32 -08:00
dvb_ca_en50221.h V4L/DVB (9054): implement proper locking in the dvb ca en50221 driver 2009-01-29 08:35:37 -02:00
dvb_demux.c [media] Speed up DVB TS stream delivery from DMA buffer into dvb-core's buffer 2011-05-20 09:28:48 -03:00
dvb_demux.h V4L/DVB (13271): TS speed check. Logging transport stream speed in Kbits per second 2009-12-05 18:41:11 -02:00
dvb_filter.c
dvb_filter.h
dvb_frontend.c [media] dvb_frontend: fix race condition in stopping/starting frontend 2011-07-13 19:50:12 -03:00
dvb_frontend.h [media] DVB: Add basic API support for DVB-T2 and bump minor version 2011-05-20 18:51:09 -03:00
dvb_math.c
dvb_math.h
dvb_net.c dvb: don't use flush_scheduled_work() 2010-12-24 16:00:17 +01:00
dvb_net.h
dvb_ringbuffer.c V4L/DVB: DVB: Export dvb_ringbuffer_flush() again 2010-02-26 15:10:54 -03:00
dvb_ringbuffer.h V4L/DVB (8130): split dvb_ringbuffer dual-use functions 2008-07-20 07:13:23 -03:00
dvbdev.c Merge branch 'llseek' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/bkl 2010-10-22 10:52:56 -07:00
dvbdev.h dvb: Push down BKL into ioctl functions 2010-05-17 05:27:04 +02:00