diff options
author | Mike Isely <isely@pobox.com> | 2008-04-22 21:45:45 +0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-04-24 21:07:48 +0400 |
commit | 794b16072e00d0a40a8c773dd4319fb1e460a632 (patch) | |
tree | 4ce7b55af0ae1208d72bee673c16311acf085f66 /drivers/media/video/pvrusb2/pvrusb2-context.h | |
parent | 8f59100a42576c49e2170e9dc04f8b7ac922a74d (diff) | |
download | linux-794b16072e00d0a40a8c773dd4319fb1e460a632.tar.xz |
V4L/DVB (7321): pvrusb2: Rework context handling and initialization
This change significantly rearranges pvr2_context level initialization
and operation:
1. A new kernel thread is set up for management of the context.
2. Destruction of the pvr2_context instance is moved into the kernel
thread. No other context is able to remove the instance; doing
this simplifies lock handling.
3. The callback into pvrusb2-main, which is used to trigger
initialization of each interface, is now issued from this kernel
thread. Previously it had been indirectly issued out of the work
queue thread in pvr2_hdw, which led to deadlock issues if the
interface needed to change a control setting (which in turn
requires dispatch of another work queue entry).
4. Callbacks into the interfaces (via the pvr2_channel structure) are
now issued strictly from this thread. The net result of this is
that such callback functions can now also safely operate driver
controls without deadlocking the work queue. (At the moment this
is not actually a problem, but I'm anticipating issues with this in
the future).
5. There is no longer any need for anyone to enter / exit the
pvr2_context structure. Implementation of the kernel thread here
allows this all to be internal now, simplifying other logic.
6. A very very longstanding issue involving a mutex deadlock between
the pvrusb2 driver and v4l should now be solved. The deadlock
involved the pvr2_context mutex and a globals-protecting mutex in
v4l. During initialization the driver would take the pvr2_context
mutex first then the v4l2 interface would register with v4l and
implicitly take the v4l mutex. Later when v4l would call back into
the driver, the two mutexes could possibly be taken in the opposite
order, a situation that can lead to deadlock. In practice this
really wasn't an issue unless a v4l app tried to start VERY early
after the driver appeared. However it still needed to be solved,
and with the use of the kernel thread relieving need for
pvr2_context mutex, the problem should be finally solved.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/pvrusb2/pvrusb2-context.h')
-rw-r--r-- | drivers/media/video/pvrusb2/pvrusb2-context.h | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-context.h b/drivers/media/video/pvrusb2/pvrusb2-context.h index 96b255f02381..127ec53e0913 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-context.h +++ b/drivers/media/video/pvrusb2/pvrusb2-context.h @@ -43,8 +43,10 @@ struct pvr2_context { struct pvr2_hdw *hdw; struct pvr2_context_stream video_stream; struct mutex mutex; + int notify_flag; int disconnect_flag; - int init_flag; + + wait_queue_head_t wait_data; /* Called after pvr2_context initialization is complete */ void (*setup_func)(struct pvr2_context *); @@ -60,9 +62,6 @@ struct pvr2_channel { void (*check_func)(struct pvr2_channel *); }; -void pvr2_context_enter(struct pvr2_context *); -void pvr2_context_exit(struct pvr2_context *); - struct pvr2_context *pvr2_context_create(struct usb_interface *intf, const struct usb_device_id *devid, void (*setup_func)(struct pvr2_context *)); |