From patchwork Wed Jun 12 16:25:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Stern X-Patchwork-Id: 2711001 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E372FC1459 for ; Wed, 12 Jun 2013 16:26:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BB1FD20298 for ; Wed, 12 Jun 2013 16:26:35 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6B8F620290 for ; Wed, 12 Jun 2013 16:26:34 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UmnsO-0000Td-SB; Wed, 12 Jun 2013 16:26:25 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UmnsL-0002kT-Rg; Wed, 12 Jun 2013 16:26:21 +0000 Received: from iolanthe.rowland.org ([192.131.102.54]) by merlin.infradead.org with smtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UmnsI-0002ji-I2 for linux-arm-kernel@lists.infradead.org; Wed, 12 Jun 2013 16:26:19 +0000 Received: (qmail 2825 invoked by uid 2102); 12 Jun 2013 12:25:56 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 12 Jun 2013 12:25:56 -0400 Date: Wed, 12 Jun 2013 12:25:56 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Manjunath Goudar Subject: Re: [PATCH 01/10] USB: OHCI: Properly handle ohci-at91 suspend In-Reply-To: Message-ID: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130612_122618_701252_115C19D7 X-CRM114-Status: GOOD ( 17.99 ) X-Spam-Score: -1.9 (-) Cc: linaro-dev@lists.linaro.org, Arnd Bergmann , patches@linaro.org, Greg KH , linux-usb@vger.kernel.org, arnd@linaro.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Wed, 12 Jun 2013, Alan Stern wrote: > On Wed, 12 Jun 2013, Manjunath Goudar wrote: > > > Suspend scenario in case of ohci-at91 glue was not properly > > handled as it was not suspending generic part of ohci controller. > > Calling explicitly the ohci_suspend()routine in ohci_hcd_at91_drv_suspend() > > will ensure proper handling of suspend scenario. > > > diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c > > index fb2f127..28400a7 100644 > > --- a/drivers/usb/host/ohci-at91.c > > +++ b/drivers/usb/host/ohci-at91.c > > @@ -619,8 +619,12 @@ ohci_hcd_at91_drv_suspend(struct platform_device *pdev, pm_message_t mesg) > > { > > struct usb_hcd *hcd = platform_get_drvdata(pdev); > > struct ohci_hcd *ohci = hcd_to_ohci(hcd); > > + bool do_wakeup = device_may_wakeup(&pdev->dev); > > + int ret; > > > > - if (device_may_wakeup(&pdev->dev)) > > + ret = ohci_suspend(hcd, do_wakeup); > > + > > + if (do_wakeup) > > enable_irq_wake(hcd->irq); > > > > /* > > @@ -637,7 +641,7 @@ ohci_hcd_at91_drv_suspend(struct platform_device *pdev, pm_message_t mesg) > > at91_stop_clock(); > > } > > > > - return 0; > > + return ret; > > If ohci_suspend() fails, we should return right away. Don't execute > the enable_irq_wake() and all the other stuff. Actually, the situation is more complicated. In order to handle races with remote wakeup, the logic we need is more like this: The same is true for all the other drivers. Alan Stern Index: usb-3.10/drivers/usb/host/ohci-at91.c =================================================================== --- usb-3.10.orig/drivers/usb/host/ohci-at91.c +++ usb-3.10/drivers/usb/host/ohci-at91.c @@ -674,8 +674,18 @@ ohci_hcd_at91_drv_suspend(struct platfor { struct usb_hcd *hcd = platform_get_drvdata(pdev); struct ohci_hcd *ohci = hcd_to_ohci(hcd); + bool do_wakeup = device_may_wakeup(&pdev->dev); + int ret; - if (device_may_wakeup(&pdev->dev)) + ret = ohci_suspend(hcd, do_wakeup); + if (ret == 0 && do_wakeup && HCD_WAKEUP_PENDING(hcd)) { + ohci_resume(hcd, false); + ret = -EBUSY; + } + if (ret) + return ret; + + if (do_wakeup) enable_irq_wake(hcd->irq); /* @@ -692,7 +702,7 @@ ohci_hcd_at91_drv_suspend(struct platfor at91_stop_clock(); } - return 0; + return ret; } static int ohci_hcd_at91_drv_resume(struct platform_device *pdev)