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: 17856 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f200.google.com (mail-ve0-f200.google.com [209.85.128.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id EDF3125E1A for ; Wed, 12 Jun 2013 16:25:59 +0000 (UTC) Received: by mail-ve0-f200.google.com with SMTP id m1sf10208962ves.3 for ; Wed, 12 Jun 2013 09:25:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-beenthere:x-forwarded-to:x-forwarded-for:delivered-to:date:from :x-x-sender:to:cc:subject:in-reply-to:message-id:mime-version :x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe :content-type; bh=znJu9wMa+F2N6x88exwqAmf8sTJN6GGTx7zLE6kfCQg=; b=BzoGTSElrKBvX1QccxjH2BbegSeUnHcqgZZ6M21tqZ6TYlUkcl1Sia3nSTOA3SbPyj JEtCI+NmCNOD+TeZzawv2PkEu8cYvxtSH0TaXqxpezwkVB0hzFNgAZCdcm+vRLOCEG/9 tGmtcKc03zrMoGZVketQNf2HGGVHFtsHYgVPo/uenAslKrMWt/+EocxSqH9I91miF26F HWZ6uVR5cpJ+JMPNItl21EGkXq37b6+Bg9RYplS18UESAQ4+VDcqf1hJqzUkYNo+t//4 sFnlb49wSqzmry6aeVOCXQs0wIy5VI/JHtcb0Dz73zaZ+a4DZAMKfi4CvVD87fMYt9k8 rKjQ== X-Received: by 10.236.193.196 with SMTP id k44mr11359578yhn.40.1371054359078; Wed, 12 Jun 2013 09:25:59 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.60.200 with SMTP id j8ls602988qer.42.gmail; Wed, 12 Jun 2013 09:25:58 -0700 (PDT) X-Received: by 10.58.187.4 with SMTP id fo4mr86325vec.55.1371054358678; Wed, 12 Jun 2013 09:25:58 -0700 (PDT) Received: from mail-vb0-x22d.google.com (mail-vb0-x22d.google.com [2607:f8b0:400c:c02::22d]) by mx.google.com with ESMTPS id i3si8889643vdw.74.2013.06.12.09.25.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 12 Jun 2013 09:25:58 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c02::22d is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c02::22d; Received: by mail-vb0-f45.google.com with SMTP id p14so4029410vbm.18 for ; Wed, 12 Jun 2013 09:25:58 -0700 (PDT) X-Received: by 10.58.22.74 with SMTP id b10mr9973557vef.47.1371054358533; Wed, 12 Jun 2013 09:25:58 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.58.191.99 with SMTP id gx3csp150691vec; Wed, 12 Jun 2013 09:25:58 -0700 (PDT) X-Received: by 10.224.208.68 with SMTP id gb4mr24440088qab.25.1371054357978; Wed, 12 Jun 2013 09:25:57 -0700 (PDT) Received: from iolanthe.rowland.org (iolanthe.rowland.org. [192.131.102.54]) by mx.google.com with SMTP id w8si22031375qag.58.2013.06.12.09.25.57 for ; Wed, 12 Jun 2013 09:25:57 -0700 (PDT) Received-SPF: neutral (google.com: 192.131.102.54 is neither permitted nor denied by best guess record for domain of stern+51bd9fa6@rowland.harvard.edu) client-ip=192.131.102.54; 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 cc: linux-usb@vger.kernel.org, , , , , Arnd Bergmann , Greg KH Subject: Re: [PATCH 01/10] USB: OHCI: Properly handle ohci-at91 suspend In-Reply-To: Message-ID: MIME-Version: 1.0 X-Gm-Message-State: ALoCoQnivNj0Hxw9uieJHXAOhxrCkQv3JlREDmNhvXsRrRtAfgkdTEt4BQHXjrU2K3kEG8htKjEh X-Original-Sender: stern@rowland.harvard.edu X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c02::22d is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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)