From patchwork Fri Jun 28 13:57:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 2799501 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 795679F3C3 for ; Fri, 28 Jun 2013 13:58:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3BFA3201CA for ; Fri, 28 Jun 2013 13:58:31 +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 DD0FB201C8 for ; Fri, 28 Jun 2013 13:58:29 +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 1UsZBx-0008HN-50; Fri, 28 Jun 2013 13:58: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 1UsZBu-00066v-Ix; Fri, 28 Jun 2013 13:58:22 +0000 Received: from arroyo.ext.ti.com ([192.94.94.40]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UsZBr-00066K-W8 for linux-arm-kernel@lists.infradead.org; Fri, 28 Jun 2013 13:58:21 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id r5SDvw0E031037; Fri, 28 Jun 2013 08:57:58 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id r5SDvwee029589; Fri, 28 Jun 2013 08:57:58 -0500 Received: from dlelxv22.itg.ti.com (172.17.1.197) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.2.342.3; Fri, 28 Jun 2013 08:57:57 -0500 Received: from [172.24.56.192] (h56-192.vpn.ti.com [172.24.56.192]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id r5SDvtTt031799; Fri, 28 Jun 2013 08:57:55 -0500 Message-ID: <51CD9663.6060806@ti.com> Date: Fri, 28 Jun 2013 16:57:55 +0300 From: Roger Quadros User-Agent: Mozilla/5.0 (X11; Linux i686; rv:16.0) Gecko/20121011 Thunderbird/16.0.1 MIME-Version: 1.0 To: Alan Stern Subject: Re: [RFC PATCH 4/6] USB: ehci-omap: Suspend the controller during bus suspend References: <51CD7FA1.3020005@ti.com> In-Reply-To: <51CD7FA1.3020005@ti.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130628_095820_134361_C0E1BCD1 X-CRM114-Status: GOOD ( 19.34 ) X-Spam-Score: -8.2 (--------) Cc: linux-usb@vger.kernel.org, tony@atomide.com, ruslan.bilovol@ti.com, linux-kernel@vger.kernel.org, balbi@ti.com, linux-omap@vger.kernel.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=-5.5 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 06/28/2013 03:20 PM, Roger Quadros wrote: > On 06/27/2013 06:40 PM, Alan Stern wrote: >> On Wed, 26 Jun 2013, Roger Quadros wrote: >> >>> I updated the ehci-omap.c driver to call ehci_suspend/resume during runtime_suspend/resume. >>> After that, it stopped detecting the port status change event when a device was plugged >>> to an external HUB. The wakeup irq was coming and the root hub/controller were being resumed, >>> but after that, no hub_irq. >> >> Wait a minute. I'm not clear on what happened. You're starting out >> with the controller, the root hub, and the external hub all suspended, >> right? Then you plugged a new device into the external hub. This > > This is right. > >> caused the controller and the root hub to wake up, but not the external >> hub? >> > Right. It seems the external hub has signaled remote wakeup but the kernel doesn't > resume the root hub's port it is connected to. > > By observing the detailed logs below you can see that the root hub does not generate > an INTerrupt transaction to notify the port status change event. I've captured the pstatus > and GetPortStatus info as well. > > Failing case > ------------ > > [ 16.108032] usb usb1: usb auto-resume > [ 16.108062] ehci-omap 48064800.ehci: resume root hub > [ 16.108154] hub 1-0:1.0: hub_resume > [ 16.108398] ehci_hub_control GetPortStatus, port 1 temp = 0x1000 > [ 16.108459] ehci_hub_control GetPortStatus, port 2 temp = 0x14c5 > [ 16.108551] hub 1-0:1.0: port 2: status 0507 change 0000 > [ 16.108612] ehci_hub_control GetPortStatus, port 3 temp = 0x1000 > [ 16.108642] hub 1-0:1.0: hub_activate submitting urb > [ 16.109222] ehci_irq port 3 pstatus 0x1000 > [ 16.109222] ehci_irq port 2 pstatus 0x14c5 > [ 16.109252] ehci_irq port 1 pstatus 0x1000 > [ 16.109374] hub 1-0:1.0: state 7 ports 3 chg 0000 evt 0000 > > Passing case > ------------ > > / # [ 19.704589] usb usb1: usb wakeup-resume > [ 19.709075] ehci-omap 48064800.ehci: omap_ehci_runtime_resume > [ 19.715423] usb usb1: usb auto-resume > [ 19.719299] ehci-omap 48064800.ehci: resume root hub > [ 19.724670] hub 1-0:1.0: hub_resume > [ 19.728424] ehci_hub_control GetPortStatus, port 1 temp = 0x1000 > [ 19.734863] ehci_hub_control GetPortStatus, port 2 temp = 0x14c5 > [ 19.741271] hub 1-0:1.0: port 2: status 0507 change 0000 > [ 19.746948] ehci_hub_control GetPortStatus, port 3 temp = 0x1000 > [ 19.753448] hub 1-0:1.0: hub_activate submitting urb > [ 19.759216] ehci_irq port 3 pstatus 0x1000 > [ 19.763519] ehci_irq port 2 pstatus 0x14c5 > [ 19.767822] ehci_irq port 1 pstatus 0x1000 > [ 19.772155] hub 1-0:1.0: hub_irq > > <---This is the Port Status change hub INT which is missing in the failing case---> > > [ 19.775604] hub 1-0:1.0: hub_irq submitting urb > [ 19.780548] hub 1-0:1.0: state 7 ports 3 chg 0000 evt 0004 > [ 19.786407] hub 1-0:1.0: hub_irq > [ 19.789916] hub 1-0:1.0: hub_irq submitting urb > [ 19.794799] ehci_hub_control GetPortStatus, port 2 temp = 0x14c5 > [ 19.801147] ehci-omap 48064800.ehci: GetStatus port:2 status 001005 0 ACK POWER sig=se0 PE CONNECT > [ 19.822937] usb 1-2: usb wakeup-resume > [ 19.826995] ehci_hub_control GetPortStatus, port 2 temp = 0x1005 > [ 19.833404] usb 1-2: finish resume > [ 19.837738] hub 1-2:1.0: hub_resume > [ 19.841613] hub 1-2:1.0: port 1: status 0507 change 0000 > [ 19.848358] hub 1-2:1.0: port 4: status 0101 change 0001 > [ 19.962890] hub 1-2:1.0: hub_activate submitting urb > [ 19.968139] ehci-omap 48064800.ehci: reused qh dd450200 schedule > [ 19.974456] usb 1-2: link qh256-0001/dd450200 start 1 [1/0 us] > [ 19.980743] hub 1-0:1.0: resume on port 2, status 0 > [ 19.985961] hub 1-0:1.0: state 7 ports 3 chg 0000 evt 0000 > [ 19.991760] hub 1-2:1.0: state 7 ports 5 chg 0010 evt 0000 > [ 19.997741] hub 1-2:1.0: port 4, status 0101, change 0000, 12 Mb/s > [ 20.083129] usb 1-2.4: new high-speed USB device number 4 using ehci-omap > > > One more thing is that the delay didn't help if I reduce printk verbosity to 7. > So the debug prints are also adding some delays around the place which is affecting > the behaviour. Just found the problem. It seems that enabling the ehci_irq _after_ the root hub is resumed is the root cause of the problem. Doing so will miss events from the root hub. The following modification worked for me without any delays. cheers, -roger diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 72df4eb..b3af1aa 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -2136,11 +2136,6 @@ static void hcd_resume_work(struct work_struct *work) usb_lock_device(udev); usb_remote_wakeup(udev); usb_unlock_device(udev); - if (HCD_IRQ_DISABLED(hcd)) { - /* Interrupt was disabled */ - clear_bit(HCD_FLAG_IRQ_DISABLED, &hcd->flags); - enable_irq(hcd->irq); - } } /** diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 593d28d..f2a1a46 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -1110,6 +1110,12 @@ int ehci_resume(struct usb_hcd *hcd, bool hibernated) { struct ehci_hcd *ehci = hcd_to_ehci(hcd); + if (HCD_IRQ_DISABLED(hcd)) { + /* Interrupt was disabled */ + clear_bit(HCD_FLAG_IRQ_DISABLED, &hcd->flags); + enable_irq(hcd->irq); + } + if (time_before(jiffies, ehci->next_statechange)) msleep(100);