aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/pvrusb2/pvrusb2-context.h
diff options
context:
space:
mode:
authorMike Isely <isely@pobox.com>2008-04-22 13:45:45 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-04-24 13:07:48 -0400
commit794b16072e00d0a40a8c773dd4319fb1e460a632 (patch)
tree4ce7b55af0ae1208d72bee673c16311acf085f66 /drivers/media/video/pvrusb2/pvrusb2-context.h
parent8f59100a42576c49e2170e9dc04f8b7ac922a74d (diff)
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.h7
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 {
43 struct pvr2_hdw *hdw; 43 struct pvr2_hdw *hdw;
44 struct pvr2_context_stream video_stream; 44 struct pvr2_context_stream video_stream;
45 struct mutex mutex; 45 struct mutex mutex;
46 int notify_flag;
46 int disconnect_flag; 47 int disconnect_flag;
47 int init_flag; 48
49 wait_queue_head_t wait_data;
48 50
49 /* Called after pvr2_context initialization is complete */ 51 /* Called after pvr2_context initialization is complete */
50 void (*setup_func)(struct pvr2_context *); 52 void (*setup_func)(struct pvr2_context *);
@@ -60,9 +62,6 @@ struct pvr2_channel {
60 void (*check_func)(struct pvr2_channel *); 62 void (*check_func)(struct pvr2_channel *);
61}; 63};
62 64
63void pvr2_context_enter(struct pvr2_context *);
64void pvr2_context_exit(struct pvr2_context *);
65
66struct pvr2_context *pvr2_context_create(struct usb_interface *intf, 65struct pvr2_context *pvr2_context_create(struct usb_interface *intf,
67 const struct usb_device_id *devid, 66 const struct usb_device_id *devid,
68 void (*setup_func)(struct pvr2_context *)); 67 void (*setup_func)(struct pvr2_context *));