]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/3.4.21/bas_gigaset-fix-pre_reset-handling.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.4.21 / bas_gigaset-fix-pre_reset-handling.patch
CommitLineData
c274b5d4
GKH
1From c6fdd8e5d0c65bb8821dc6da26ee1a2ddd58b3cc Mon Sep 17 00:00:00 2001
2From: Tilman Schmidt <tilman@imap.cc>
3Date: Wed, 24 Oct 2012 08:44:32 +0000
4Subject: bas_gigaset: fix pre_reset handling
5
6From: Tilman Schmidt <tilman@imap.cc>
7
8commit c6fdd8e5d0c65bb8821dc6da26ee1a2ddd58b3cc upstream.
9
10The delayed work function int_in_work() may call usb_reset_device()
11and thus, indirectly, the driver's pre_reset method. Trying to
12cancel the work synchronously in that situation would deadlock.
13Fix by avoiding cancel_work_sync() in the pre_reset method.
14
15If the reset was NOT initiated by int_in_work() this might cause
16int_in_work() to run after the post_reset method, with urb_int_in
17already resubmitted, so handle that case gracefully.
18
19Signed-off-by: Tilman Schmidt <tilman@imap.cc>
20Signed-off-by: David S. Miller <davem@davemloft.net>
21Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
22
23---
24 drivers/isdn/gigaset/bas-gigaset.c | 19 ++++++++++++++++---
25 1 file changed, 16 insertions(+), 3 deletions(-)
26
27--- a/drivers/isdn/gigaset/bas-gigaset.c
28+++ b/drivers/isdn/gigaset/bas-gigaset.c
29@@ -616,7 +616,13 @@ static void int_in_work(struct work_stru
30 if (rc == 0)
31 /* success, resubmit interrupt read URB */
32 rc = usb_submit_urb(urb, GFP_ATOMIC);
33- if (rc != 0 && rc != -ENODEV) {
34+
35+ switch (rc) {
36+ case 0: /* success */
37+ case -ENODEV: /* device gone */
38+ case -EINVAL: /* URB already resubmitted, or terminal badness */
39+ break;
40+ default: /* failure: try to recover by resetting the device */
41 dev_err(cs->dev, "clear halt failed: %s\n", get_usb_rcmsg(rc));
42 rc = usb_lock_device_for_reset(ucs->udev, ucs->interface);
43 if (rc == 0) {
44@@ -2437,7 +2443,9 @@ static void gigaset_disconnect(struct us
45 }
46
47 /* gigaset_suspend
48- * This function is called before the USB connection is suspended.
49+ * This function is called before the USB connection is suspended
50+ * or before the USB device is reset.
51+ * In the latter case, message == PMSG_ON.
52 */
53 static int gigaset_suspend(struct usb_interface *intf, pm_message_t message)
54 {
55@@ -2493,7 +2501,12 @@ static int gigaset_suspend(struct usb_in
56 del_timer_sync(&ucs->timer_atrdy);
57 del_timer_sync(&ucs->timer_cmd_in);
58 del_timer_sync(&ucs->timer_int_in);
59- cancel_work_sync(&ucs->int_in_wq);
60+
61+ /* don't try to cancel int_in_wq from within reset as it
62+ * might be the one requesting the reset
63+ */
64+ if (message.event != PM_EVENT_ON)
65+ cancel_work_sync(&ucs->int_in_wq);
66
67 gig_dbg(DEBUG_SUSPEND, "suspend complete");
68 return 0;