USB: create new workqueue thread for USB autosuspend

This patch (as787) creates a new workqueue thread to handle delayed
USB autosuspend requests.  Previously the code used keventd.  However
it turns out that the hub driver's suspend routine calls
flush_scheduled_work(), making it a poor candidate for running in
keventd (the call immediately deadlocks).  The solution is to use a
new thread instead of keventd.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index c2aad6a..ee18d18 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -24,6 +24,7 @@
 
 #include <linux/device.h>
 #include <linux/usb.h>
+#include <linux/workqueue.h>
 #include "hcd.h"
 #include "usb.h"
 
@@ -1131,7 +1132,7 @@
 	mutex_lock_nested(&udev->pm_mutex, udev->level);
 	udev->pm_usage_cnt -= dec_usage_cnt;
 	if (udev->pm_usage_cnt <= 0)
-		schedule_delayed_work(&udev->autosuspend,
+		queue_delayed_work(ksuspend_usb_wq, &udev->autosuspend,
 				USB_AUTOSUSPEND_DELAY);
 	mutex_unlock(&udev->pm_mutex);
 	// dev_dbg(&udev->dev, "%s: cnt %d\n",
@@ -1215,10 +1216,10 @@
 	struct usb_device	*udev = interface_to_usbdev(intf);
 
 	mutex_lock_nested(&udev->pm_mutex, udev->level);
-	if (intf->condition != USB_INTERFACE_UNBOUND) {
-		if (--intf->pm_usage_cnt <= 0)
-			schedule_delayed_work(&udev->autosuspend,
-					USB_AUTOSUSPEND_DELAY);
+	if (intf->condition != USB_INTERFACE_UNBOUND &&
+			--intf->pm_usage_cnt <= 0) {
+		queue_delayed_work(ksuspend_usb_wq, &udev->autosuspend,
+				USB_AUTOSUSPEND_DELAY);
 	}
 	mutex_unlock(&udev->pm_mutex);
 	// dev_dbg(&intf->dev, "%s: cnt %d\n",