aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca/zc3xx.c
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2012-05-06 08:28:22 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-05-14 08:28:39 -0400
commit254902b01d2acc6aced99ec17caa4c6cd890cdea (patch)
tree2e33317c4e142f73ddca8e24b6c9968325cbc8bc /drivers/media/video/gspca/zc3xx.c
parentcc7b6f257d42eb9829b38e3a8807943426a89a87 (diff)
[media] gspca: Fix locking issues related to suspend/resume
There are two bugs here: first the calls to stop0 (in gspca_suspend) and gspca_init_transfer (in gspca_resume) need to be called with the usb_lock held. That's true for the other places they are called and it is what subdrivers expect. Quite a few will unlock the usb_lock in stop0 while waiting for a worker thread to finish, and if usb_lock isn't held then that can cause a kernel oops. The other problem is that a worker thread needs to detect that it has to halt due to a suspend. Otherwise it will just go on looping. So add tests against gspca_dev->frozen in the worker threads that need it. Hdg, 2 minor changes: 1) The finepix device is ok with stopping reading a frame halfway through, so add frozen checks in all places where we also check if we're still streaming 2) Use gspca_dev->dev instead of gspca_dev->present to check for disconnect in all touched drivers. I plan to do this everywhere in the future, and most relevant lines in the touched drivers are already modified by this patch. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/gspca/zc3xx.c')
-rw-r--r--drivers/media/video/gspca/zc3xx.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/media/video/gspca/zc3xx.c b/drivers/media/video/gspca/zc3xx.c
index 7d9a4f1be9dc..8f21bae46ef8 100644
--- a/drivers/media/video/gspca/zc3xx.c
+++ b/drivers/media/video/gspca/zc3xx.c
@@ -6093,7 +6093,8 @@ static void transfer_update(struct work_struct *work)
6093 /* get the transfer status */ 6093 /* get the transfer status */
6094 /* the bit 0 of the bridge register 11 indicates overflow */ 6094 /* the bit 0 of the bridge register 11 indicates overflow */
6095 mutex_lock(&gspca_dev->usb_lock); 6095 mutex_lock(&gspca_dev->usb_lock);
6096 if (!gspca_dev->present || !gspca_dev->streaming) 6096 if (gspca_dev->frozen || !gspca_dev->dev ||
6097 !gspca_dev->streaming)
6097 goto err; 6098 goto err;
6098 reg11 = reg_r(gspca_dev, 0x0011); 6099 reg11 = reg_r(gspca_dev, 0x0011);
6099 if (gspca_dev->usb_err < 0 6100 if (gspca_dev->usb_err < 0
@@ -6949,7 +6950,7 @@ static void sd_stop0(struct gspca_dev *gspca_dev)
6949 mutex_lock(&gspca_dev->usb_lock); 6950 mutex_lock(&gspca_dev->usb_lock);
6950 sd->work_thread = NULL; 6951 sd->work_thread = NULL;
6951 } 6952 }
6952 if (!gspca_dev->present) 6953 if (!gspca_dev->dev)
6953 return; 6954 return;
6954 send_unknown(gspca_dev, sd->sensor); 6955 send_unknown(gspca_dev, sd->sensor);
6955} 6956}