public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] USB: fix deadlock in HCD code
@ 2008-05-21 12:09 Jiri Kosina
  2008-05-21 13:21 ` Oliver Neukum
  2008-05-21 22:26 ` Peter Zijlstra
  0 siblings, 2 replies; 18+ messages in thread
From: Jiri Kosina @ 2008-05-21 12:09 UTC (permalink / raw)
  To: Greg KH, linux-usb; +Cc: Oliver Neukum, Alan Stern, lchiquitto, linux-kernel

hcd_urb_list_lock is used for synchronization between IRQ and non-IRQ 
contexts, so the non-IRQ context has to disable IRQs in order to prevent 
deadlocking with IRQ context.

Signed-off-by: Jiri Kosina <jkosina@suse.cz>

 drivers/usb/core/hcd.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index bf10e9c..19279ed 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1000,8 +1000,9 @@ EXPORT_SYMBOL_GPL(usb_calc_bus_time);
 int usb_hcd_link_urb_to_ep(struct usb_hcd *hcd, struct urb *urb)
 {
 	int		rc = 0;
+	unsigned long flags;
 
-	spin_lock(&hcd_urb_list_lock);
+	spin_lock_irqsave(&hcd_urb_list_lock, flags);
 
 	/* Check that the URB isn't being killed */
 	if (unlikely(urb->reject)) {
@@ -1034,7 +1035,7 @@ int usb_hcd_link_urb_to_ep(struct usb_hcd *hcd, struct urb *urb)
 		goto done;
 	}
  done:
-	spin_unlock(&hcd_urb_list_lock);
+	spin_unlock_irqrestore(&hcd_urb_list_lock, flags);
 	return rc;
 }
 EXPORT_SYMBOL_GPL(usb_hcd_link_urb_to_ep);
@@ -1106,10 +1107,11 @@ EXPORT_SYMBOL_GPL(usb_hcd_check_unlink_urb);
  */
 void usb_hcd_unlink_urb_from_ep(struct usb_hcd *hcd, struct urb *urb)
 {
+	unsigned long flags;
 	/* clear all state linking urb to this dev (and hcd) */
-	spin_lock(&hcd_urb_list_lock);
+	spin_lock_irqsave(&hcd_urb_list_lock, flags);
 	list_del_init(&urb->urb_list);
-	spin_unlock(&hcd_urb_list_lock);
+	spin_unlock_irqrestore(&hcd_urb_list_lock, flags);
 }
 EXPORT_SYMBOL_GPL(usb_hcd_unlink_urb_from_ep);


^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2008-05-21 22:26 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-21 12:09 [PATCH] USB: fix deadlock in HCD code Jiri Kosina
2008-05-21 13:21 ` Oliver Neukum
2008-05-21 13:27   ` Jiri Kosina
2008-05-21 13:32     ` Oliver Neukum
2008-05-21 13:36       ` Jiri Kosina
2008-05-21 13:47         ` Oliver Neukum
2008-05-21 14:13           ` Alan Stern
2008-05-21 14:22             ` Jiri Kosina
2008-05-21 14:46               ` Alan Stern
2008-05-21 19:32                 ` Leonardo Chiquitto
2008-05-21 20:03                 ` Oliver Neukum
2008-05-21 14:29             ` David Vrabel
2008-05-21 14:42               ` Alan Stern
2008-05-21 14:53                 ` David Vrabel
2008-05-21 14:58                   ` Alan Stern
2008-05-21 14:31             ` Oliver Neukum
2008-05-21 13:40     ` Oliver Neukum
2008-05-21 22:26 ` Peter Zijlstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox