Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a1227f3c authored by Stanislaw Gruszka's avatar Stanislaw Gruszka Committed by Greg Kroah-Hartman
Browse files

usb: ehci: fix deadlock when threadirqs option is used



ehci_irq() and ehci_hrtimer_func() can deadlock on ehci->lock when
threadirqs option is used. To prevent the deadlock use
spin_lock_irqsave() in ehci_irq().

This change can be reverted when hrtimer callbacks become threaded.

Signed-off-by: default avatarStanislaw Gruszka <sgruszka@redhat.com>
Cc: stable <stable@vger.kernel.org>
Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 6dbd46c8
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -685,8 +685,15 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd)
	struct ehci_hcd		*ehci = hcd_to_ehci (hcd);
	u32			status, masked_status, pcd_status = 0, cmd;
	int			bh;
	unsigned long		flags;

	spin_lock (&ehci->lock);
	/*
	 * For threadirqs option we use spin_lock_irqsave() variant to prevent
	 * deadlock with ehci hrtimer callback, because hrtimer callbacks run
	 * in interrupt context even when threadirqs is specified. We can go
	 * back to spin_lock() variant when hrtimer callbacks become threaded.
	 */
	spin_lock_irqsave(&ehci->lock, flags);

	status = ehci_readl(ehci, &ehci->regs->status);

@@ -704,7 +711,7 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd)

	/* Shared IRQ? */
	if (!masked_status || unlikely(ehci->rh_state == EHCI_RH_HALTED)) {
		spin_unlock(&ehci->lock);
		spin_unlock_irqrestore(&ehci->lock, flags);
		return IRQ_NONE;
	}

@@ -815,7 +822,7 @@ dead:

	if (bh)
		ehci_work (ehci);
	spin_unlock (&ehci->lock);
	spin_unlock_irqrestore(&ehci->lock, flags);
	if (pcd_status)
		usb_hcd_poll_rh_status(hcd);
	return IRQ_HANDLED;