From patchwork Thu Oct 22 20:05:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 7467521 Return-Path: X-Original-To: patchwork-linux-rockchip@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A7DAABEEA4 for ; Thu, 22 Oct 2015 20:05:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BCAD42045A for ; Thu, 22 Oct 2015 20:05:51 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D9552203EC for ; Thu, 22 Oct 2015 20:05:50 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZpM7Q-0003Wi-9B; Thu, 22 Oct 2015 20:05:48 +0000 Received: from mail-pa0-x233.google.com ([2607:f8b0:400e:c03::233]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZpM7O-0003Jn-NM for linux-rockchip@lists.infradead.org; Thu, 22 Oct 2015 20:05:47 +0000 Received: by padhk11 with SMTP id hk11so95396670pad.1 for ; Thu, 22 Oct 2015 13:05:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=30KQHgO0SPJWbv51aPELq9d3KaNih9utIiU5AelOuvo=; b=C+xSt45+/6fIQ3pWshVLLaOaBT7hAwKeRZr76ZXXRjcGYaQ34FDrhuzTZmYAy3dQ74 u7y42uQF9gmY0z/B4Q8nia/s7IJnh25HYoAkQHu6i5+yxfpDfy1EU/PyZXSqnUZ/rocY fvuh+qk5F61V3VctbFFtT5ArHZrV912jxxvRY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=30KQHgO0SPJWbv51aPELq9d3KaNih9utIiU5AelOuvo=; b=kuv0YqImbyrbHrJ+eN/C/LeRYyPnxJkuwO1Maqv2NCMTvyCZtxlObphdDE5LnL/Iw7 pFogtzkpB3+Idcvv9u609lNn5kDELybNRpoKCqcPCgNIWoqKKXeakwwo9i/BFFiDV44t SOaAQql0hv8qJC4KxU5Wjd4/Ty5AbAzCtGxYFyPVio0eThROksXaJkHQnm6xnONJ5Iy5 28RcrNHfsOM5+8+Ti+o7AkTcGrbRYCYsXTuKbkArqMBjLOcLhzt6ftB+0Z7ef9u7Ma2M uVChtSsFHTpxudrX1tPA5Chenul0FNsTO5n405EEX4FZJgiCAX7hZ8G5ZGZ/aza9PCvm TtCQ== X-Gm-Message-State: ALoCoQl8psEKeeATuHrC4CrSpip2Hx8BipxxrKGhTICFjm9MsoK9DnNQpoeCuEOWLVA7iTgN/LtP X-Received: by 10.68.57.205 with SMTP id k13mr7227400pbq.4.1445544325495; Thu, 22 Oct 2015 13:05:25 -0700 (PDT) Received: from tictac.mtv.corp.google.com ([172.22.65.76]) by smtp.gmail.com with ESMTPSA id ha1sm15211840pbc.54.2015.10.22.13.05.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Oct 2015 13:05:24 -0700 (PDT) From: Douglas Anderson To: John Youn , balbi@ti.com Subject: [PATCH] usb: dwc2: host: Fix remote wakeup when not in DWC2_L2 Date: Thu, 22 Oct 2015 13:05:03 -0700 Message-Id: <1445544303-24202-1-git-send-email-dianders@chromium.org> X-Mailer: git-send-email 2.6.0.rc2.230.g3dd15c0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151022_130546_807434_5413C071 X-CRM114-Status: GOOD ( 13.19 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: gregory.herrero@intel.com, heiko@sntech.de, johnyoun@synopsys.com, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, r.baldyga@samsung.com, Douglas Anderson , linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, yousaf.kaukab@intel.com, lyz@rock-chips.com, Julius Werner , wulf@rock-chips.com, dinguyen@opensource.altera.com MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,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 In commit 734643dfbdde ("usb: dwc2: host: add flag to reflect bus state") we changed dwc2_port_suspend() not to set the lx_state anymore (instead it sets the new bus_suspended variable). This introduced a bug where we would fail to detect device insertions if: 1. Plug empty hub into dwc2 2. Plug USB flash drive into the empty hub. 3. Wait a few seconds 4. Unplug USB flash drive 5. Less than 2 seconds after step 4, plug the USB flash drive in again. The dwc2_hcd_rem_wakeup() function should have been changed to look at the new bus_suspended variable. Let's fix it. Since commit b46146d59fda ("usb: dwc2: host: resume root hub on remote wakeup") talks about needing the root hub resumed if the bus was suspended, we'll include it in our test. It appears that the "port_l1_change" should only be set to 1 if we were in DWC2_L1 (the driver currently never sets this), so we'll update the former "else" case based on this test. Fixes: 734643dfbdde ("usb: dwc2: host: add flag to reflect bus state") Signed-off-by: Douglas Anderson Reviewed-by: Heiko Stuebner Acked-by: John Youn Tested-by: Gregory Herrero --- drivers/usb/dwc2/hcd.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index e79baf73c234..571c21727ff9 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -324,12 +324,13 @@ void dwc2_hcd_disconnect(struct dwc2_hsotg *hsotg) */ static void dwc2_hcd_rem_wakeup(struct dwc2_hsotg *hsotg) { - if (hsotg->lx_state == DWC2_L2) { + if (hsotg->bus_suspended) { hsotg->flags.b.port_suspend_change = 1; usb_hcd_resume_root_hub(hsotg->priv); - } else { - hsotg->flags.b.port_l1_change = 1; } + + if (hsotg->lx_state == DWC2_L1) + hsotg->flags.b.port_l1_change = 1; } /** @@ -1428,8 +1429,8 @@ static void dwc2_wakeup_detected(unsigned long data) dev_dbg(hsotg->dev, "Clear Resume: HPRT0=%0x\n", dwc2_readl(hsotg->regs + HPRT0)); - hsotg->bus_suspended = 0; dwc2_hcd_rem_wakeup(hsotg); + hsotg->bus_suspended = 0; /* Change to L0 state */ hsotg->lx_state = DWC2_L0;