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>
This commit is contained in:
Alan Stern
2006-09-19 10:14:07 -04:00
committed by Greg Kroah-Hartman
parent 6a9fb06039
commit bd859281c0
3 changed files with 46 additions and 8 deletions

View File

@@ -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 @@ void usb_autosuspend_device(struct usb_device *udev, int dec_usage_cnt)
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 @@ void usb_autopm_put_interface(struct usb_interface *intf)
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",