From: Mark Lord <lkml@rtr.ca>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Andrew Morton <akpm@linux-foundation.org>,
Greg KH <gregkh@suse.de>,
Linux Kernel <linux-kernel@vger.kernel.org>,
USB development list <linux-usb-devel@lists.sourceforge.net>
Subject: Re: [PATCH] USB: replace flush_workqueue with cancel_sync_work
Date: Tue, 29 May 2007 17:19:50 -0400 [thread overview]
Message-ID: <465C98F6.10806@rtr.ca> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0705291628230.2974-100000@iolanthe.rowland.org>
Thanks again, Alan!
From: Alan Stern <stern@rowland.harvard.edu>
>
>This patch (as912) replaces a couple of calls to flush_workqueue()
>with cancel_sync_work() and cancel_rearming_delayed_work(). Using a
>more directed approach allows us to avoid some nasty deadlocks. The
>prime example occurs when a first-level device (the parent is a root
>hub) is removed while at the same time the root hub gets a remote
>wakeup request. khubd would try to flush the autosuspend workqueue
>while holding the root-hub's lock, and the remote-wakeup workqueue
>routine would be waiting to lock the root hub.
>
>The patch also reorganizes the power management portion of
>usb_disconnect(), separating it out into its own routine. The
>autosuspend workqueue entry is cancelled immediately instead of
>waiting for the device's release routine. In addition,
>synchronization with the autosuspend thread is carried out even for
>root hubs (an oversight in the original code).
>
>Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Acked-by: Mark Lord <mlord@pobox.com>
---
Index: 2.6.22-rc3/drivers/usb/core/hub.c
===================================================================
--- 2.6.22-rc3.orig/drivers/usb/core/hub.c
+++ 2.6.22-rc3/drivers/usb/core/hub.c
@@ -1158,6 +1158,30 @@ static void release_address(struct usb_d
}
}
+#ifdef CONFIG_USB_SUSPEND
+
+static void usb_stop_pm(struct usb_device *udev)
+{
+ /* Synchronize with the ksuspend thread to prevent any more
+ * autosuspend requests from being submitted, and decrement
+ * the parent's count of unsuspended children.
+ */
+ usb_pm_lock(udev);
+ if (udev->parent && !udev->discon_suspended)
+ usb_autosuspend_device(udev->parent);
+ usb_pm_unlock(udev);
+
+ /* Stop any autosuspend requests already submitted */
+ cancel_rearming_delayed_work(&udev->autosuspend);
+}
+
+#else
+
+static inline void usb_stop_pm(struct usb_device *udev)
+{ }
+
+#endif
+
/**
* usb_disconnect - disconnect a device (usbcore-internal)
* @pdev: pointer to device being disconnected
@@ -1224,13 +1248,7 @@ void usb_disconnect(struct usb_device **
*pdev = NULL;
spin_unlock_irq(&device_state_lock);
- /* Decrement the parent's count of unsuspended children */
- if (udev->parent) {
- usb_pm_lock(udev);
- if (!udev->discon_suspended)
- usb_autosuspend_device(udev->parent);
- usb_pm_unlock(udev);
- }
+ usb_stop_pm(udev);
put_device(&udev->dev);
}
Index: 2.6.22-rc3/drivers/usb/core/usb.c
===================================================================
--- 2.6.22-rc3.orig/drivers/usb/core/usb.c
+++ 2.6.22-rc3/drivers/usb/core/usb.c
@@ -184,10 +184,6 @@ static void usb_release_dev(struct devic
udev = to_usb_device(dev);
-#ifdef CONFIG_USB_SUSPEND
- cancel_delayed_work(&udev->autosuspend);
- flush_workqueue(ksuspend_usb_wq);
-#endif
usb_destroy_configuration(udev);
usb_put_hcd(bus_to_hcd(udev->bus));
kfree(udev->product);
Index: 2.6.22-rc3/drivers/usb/core/hcd.c
===================================================================
--- 2.6.22-rc3.orig/drivers/usb/core/hcd.c
+++ 2.6.22-rc3/drivers/usb/core/hcd.c
@@ -1681,7 +1681,7 @@ void usb_remove_hcd(struct usb_hcd *hcd)
spin_unlock_irq (&hcd_root_hub_lock);
#ifdef CONFIG_PM
- flush_workqueue(ksuspend_usb_wq);
+ cancel_work_sync(&hcd->wakeup_work);
#endif
mutex_lock(&usb_bus_list_lock);
-
next prev parent reply other threads:[~2007-05-29 21:20 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-29 16:35 Regression: USB is nfg after suspend/resume(RAM) cycle on Intel chipset Mark Lord
2007-05-29 16:46 ` Linus Torvalds
2007-05-29 17:00 ` Mark Lord
2007-05-29 17:04 ` Mark Lord
2007-05-29 17:07 ` Nish Aravamudan
2007-05-30 7:02 ` Regression: USB is nfg after suspend/resume(RAM) cycle onIntel chipset Romano Giannetti
2007-05-29 17:06 ` Regression: USB is nfg after suspend/resume(RAM) cycle on Intel chipset Nish Aravamudan
2007-05-29 17:47 ` Linus Torvalds
2007-05-29 19:32 ` J. Bruce Fields
2007-05-29 17:42 ` Linus Torvalds
2007-05-29 17:19 ` Mark Lord
2007-05-29 17:37 ` Mark Lord
2007-05-29 17:54 ` Linus Torvalds
2007-05-29 18:19 ` Mark Lord
2007-05-29 18:28 ` Mark Lord
2007-05-29 18:41 ` Alan Stern
2007-05-29 19:11 ` Mark Lord
2007-05-29 19:22 ` Linus Torvalds
2007-05-29 20:34 ` [PATCH] USB: replace flush_workqueue with cancel_sync_work Alan Stern
2007-05-29 21:19 ` Mark Lord [this message]
2007-05-29 20:12 ` Regression: USB is nfg after suspend/resume(RAM) cycle on Intel chipset Alan Stern
2007-05-29 17:03 ` Nish Aravamudan
2007-05-29 17:06 ` Mark Lord
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=465C98F6.10806@rtr.ca \
--to=lkml@rtr.ca \
--cc=akpm@linux-foundation.org \
--cc=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb-devel@lists.sourceforge.net \
--cc=stern@rowland.harvard.edu \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox