Re: [PATCH] USB: EHCI: fix scheduling while atomic during suspend

From: Alan Stern
Date: Thu Jan 27 2011 - 10:36:20 EST


On Thu, 27 Jan 2011, Yin Kangkai wrote:

> There is a msleep with spin lock held during ehci pci suspend, which will
> cause kernel BUG: scheduling while atomic. Fix that.

> diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
> index 86f0815..a16c94a 100644
> --- a/drivers/usb/host/ehci-hub.c
> +++ b/drivers/usb/host/ehci-hub.c
> @@ -111,14 +111,19 @@ static void ehci_adjust_port_wakeup_flags(struct ehci_hcd *ehci,
> {
> int port;
> u32 temp;
> + unsigned long flags;
> +
> + spin_lock_irqsave(&ehci->lock, flags);
>
> /* If remote wakeup is enabled for the root hub but disabled
> * for the controller, we must adjust all the port wakeup flags
> * when the controller is suspended or resumed. In all other
> * cases they don't need to be changed.
> */
> - if (!ehci_to_hcd(ehci)->self.root_hub->do_remote_wakeup || do_wakeup)
> + if (!ehci_to_hcd(ehci)->self.root_hub->do_remote_wakeup || do_wakeup) {
> + spin_unlock_irqrestore(&ehci->lock, flags);
> return;
> + }

You should move the spin_lock_irqsave() down to here. Then the
spin_unlock_irqrestore() above won't be needed.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/