linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Revert "usb: core: remove local_irq_save() around ->complete() handler"
@ 2019-05-31 21:53 Soeren Moch
  2019-05-31 22:05 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 11+ messages in thread
From: Soeren Moch @ 2019-05-31 21:53 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Soeren Moch, Sebastian Andrzej Siewior, Alan Stern, linux-usb,
	linux-kernel, stable

This reverts commit ed194d1367698a0872a2b75bbe06b3932ce9df3a.

In contrast to the original patch description, apparently not all handlers
were audited properly. E.g. my RT5370 based USB WIFI adapter (driver in
drivers/net/wireless/ralink/rt2x00) hangs after a while under heavy load.
This revert fixes this.

Also revert the follow-up patch d6142b91e9cc249b3aa22c90fade67e2e2d52cdb
("usb: core: remove flags variable in __usb_hcd_giveback_urb()"), since now
we need the flags variable again.

Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org # 4.20+
Signed-off-by: Soeren Moch <smoch@web.de>
---
 drivers/usb/core/hcd.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 94d22551fc1b..08d25fcf8b8e 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1739,6 +1739,7 @@ static void __usb_hcd_giveback_urb(struct urb *urb)
 	struct usb_hcd *hcd = bus_to_hcd(urb->dev->bus);
 	struct usb_anchor *anchor = urb->anchor;
 	int status = urb->unlinked;
+	unsigned long flags;

 	urb->hcpriv = NULL;
 	if (unlikely((urb->transfer_flags & URB_SHORT_NOT_OK) &&
@@ -1755,7 +1756,20 @@ static void __usb_hcd_giveback_urb(struct urb *urb)

 	/* pass ownership to the completion handler */
 	urb->status = status;
+
+	/*
+	 * We disable local IRQs here avoid possible deadlock because
+	 * drivers may call spin_lock() to hold lock which might be
+	 * acquired in one hard interrupt handler.
+	 *
+	 * The local_irq_save()/local_irq_restore() around complete()
+	 * will be removed if current USB drivers have been cleaned up
+	 * and no one may trigger the above deadlock situation when
+	 * running complete() in tasklet.
+	 */
+	local_irq_save(flags);
 	urb->complete(urb);
+	local_irq_restore(flags);

 	usb_anchor_resume_wakeups(anchor);
 	atomic_dec(&urb->use_count);
--
2.17.1


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

end of thread, other threads:[~2019-06-17 10:12 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-31 21:53 [PATCH] Revert "usb: core: remove local_irq_save() around ->complete() handler" Soeren Moch
2019-05-31 22:05 ` Greg Kroah-Hartman
2019-05-31 23:02   ` Soeren Moch
2019-06-01 10:50     ` Sebastian Andrzej Siewior
2019-06-01 11:02       ` Sebastian Andrzej Siewior
2019-06-03 12:50         ` Sören Moch
2019-06-12 10:38         ` Soeren Moch
2019-06-12 14:38           ` Alan Stern
2019-06-12 14:47             ` Sebastian Andrzej Siewior
2019-06-17 10:12               ` Soeren Moch
2019-06-03 12:47       ` Sören Moch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).