From patchwork Tue Nov 15 09:41:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 82283 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp1434926qge; Tue, 15 Nov 2016 01:41:49 -0800 (PST) X-Received: by 10.98.59.154 with SMTP id w26mr44903250pfj.112.1479202909451; Tue, 15 Nov 2016 01:41:49 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e3si25822646pgn.44.2016.11.15.01.41.49; Tue, 15 Nov 2016 01:41:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755611AbcKOJlj (ORCPT + 26 others); Tue, 15 Nov 2016 04:41:39 -0500 Received: from mail-pf0-f169.google.com ([209.85.192.169]:35111 "EHLO mail-pf0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753820AbcKOJlh (ORCPT ); Tue, 15 Nov 2016 04:41:37 -0500 Received: by mail-pf0-f169.google.com with SMTP id i88so35415145pfk.2 for ; Tue, 15 Nov 2016 01:41:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=QlruzdcuHM86cDraBT4GDWfHRdvUP/0e/z6/ZufYnRk=; b=foz/bNZux+MazBXmnJsVbEEyEJdAA8MrCxqAikJDTsZXZji6/AG0oJMcv3stJJ0cUE j2i3yn/C2UiPqhiWTWNxWras8y+yKPP5WzQBvR0bc8galSjZxAfyI3JKO4zuhIcyHedx IsfuSUfi6BNlP+nFR9HW8Fyig3H52Fx0XIFo8= 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=QlruzdcuHM86cDraBT4GDWfHRdvUP/0e/z6/ZufYnRk=; b=WaxvGASATWxSqdprDGPWqTBFXqgxEOlT4+D/M3W68TCus8tzTUSN0SsKGv0zEJMrla wjLUM3bQKPE++6EcX6HkEGEKEGSFeoPRdzfzZ/+FDlz15u3ZG8fKCRXkZHG56iYZbDh9 vCQ9z41F6SEvOnoGquLOAQsmPMdD7JZwXdzWLpcgXRgCPW+9z4aWCvnM5GE/kErop4eZ 55jMZYivYEzVUwa9Bn+z9MMtjeg3/ck6XZPWOr1TK6D0Ub5ILjjksZpzXFm0IwCJO3eW 7fYuMfeH3EWbo3my+lqLnQyDx45t7/V0ChxQgDDXXelEAhbx4B+msRCdyZWGPCJ0GPeP Vp9w== X-Gm-Message-State: ABUngvdctGWxmts/Mknf6dS74ELPOcW3w6BB60BQnQcvThEdqC/1cQmQh8StZx+M/02yE/qO X-Received: by 10.99.39.132 with SMTP id n126mr77032491pgn.85.1479202896256; Tue, 15 Nov 2016 01:41:36 -0800 (PST) Received: from baolinwangubtpc.spreadtrum.com ([175.111.195.49]) by smtp.gmail.com with ESMTPSA id ca5sm41450734pac.36.2016.11.15.01.41.34 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 15 Nov 2016 01:41:35 -0800 (PST) From: Baolin Wang To: balbi@kernel.org Cc: gregkh@linuxfoundation.org, broonie@kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, baolin.wang@linaro.org Subject: [PATCH] usb: dwc3: core: Disable USB2.0 phy suspend when dwc3 acts as host role Date: Tue, 15 Nov 2016 17:41:20 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When dwc3 controller acts as host role with attaching slow speed device (like mouse or keypad). Then if we plugged out the slow speed device, it will timeout to run the deconfiguration endpoint command to drop the endpoint's resources. Some xHCI command timeout log as below when disconnecting one slow device: [ 99.807739] c0 xhci-hcd.0.auto: Port Status Change Event for port 1 [ 99.814699] c0 xhci-hcd.0.auto: resume root hub [ 99.819992] c0 xhci-hcd.0.auto: handle_port_status: starting port polling. [ 99.827808] c0 xhci-hcd.0.auto: get port status, actual port 0 status = 0x202a0 [ 99.835903] c0 xhci-hcd.0.auto: Get port status returned 0x10100 [ 99.850052] c0 xhci-hcd.0.auto: clear port connect change, actual port 0 status = 0x2a0 [ 99.859313] c0 xhci-hcd.0.auto: Cancel URB ffffffc01ed6cd00, dev 1, ep 0x81, starting at offset 0xc406d210 [ 99.869645] c0 xhci-hcd.0.auto: // Ding dong! [ 99.874776] c0 xhci-hcd.0.auto: Stopped on Transfer TRB [ 99.880713] c0 xhci-hcd.0.auto: Removing canceled TD starting at 0xc406d210 (dma). [ 99.889012] c0 xhci-hcd.0.auto: Finding endpoint context [ 99.895069] c0 xhci-hcd.0.auto: Cycle state = 0x1 [ 99.900519] c0 xhci-hcd.0.auto: New dequeue segment = ffffffc1112f0880 (virtual) [ 99.908655] c0 xhci-hcd.0.auto: New dequeue pointer = 0xc406d220 (DMA) [ 99.915927] c0 xhci-hcd.0.auto: Set TR Deq Ptr cmd, new deq seg = ffffffc1112f0880 (0xc406d000 dma), new deq ptr = ffffff8002175220 (0xc406d220 dma), new cycle = 1 [ 99.931242] c0 xhci-hcd.0.auto: // Ding dong! [ 99.936360] c0 xhci-hcd.0.auto: Successful Set TR Deq Ptr cmd, deq = @c406d220 [ 99.944458] c0 xhci-hcd.0.auto: xhci_hub_status_data: stopping port polling. [ 100.047619] c0 xhci-hcd.0.auto: xhci_drop_endpoint called for udev ffffffc01ae08800 [ 100.057002] c0 xhci-hcd.0.auto: drop ep 0x81, slot id 1, new drop flags = 0x8, new add flags = 0x0 [ 100.067878] c0 xhci-hcd.0.auto: xhci_check_bandwidth called for udev ffffffc01ae08800 [ 100.076868] c0 xhci-hcd.0.auto: New Input Control Context: ...... [ 100.427252] c0 xhci-hcd.0.auto: // Ding dong! [ 105.430728] c0 xhci-hcd.0.auto: Command timeout [ 105.436029] c0 xhci-hcd.0.auto: Abort command ring [ 113.558223] c0 xhci-hcd.0.auto: Command completion event does not match command [ 113.569778] c0 xhci-hcd.0.auto: Timeout while waiting for configure endpoint command The reason is it will suspend USB phy to disable phy clock when disconnecting the slow USB decice, that will hang on the xHCI commands executing which depends on the phy clock. Thus we should disable USB2.0 phy suspend feature when dwc3 acts as host role. Signed-off-by: Baolin Wang --- drivers/usb/dwc3/core.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) -- 1.7.9.5 diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 9a4a5e4..0b646cf 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -565,6 +565,20 @@ static int dwc3_phy_setup(struct dwc3 *dwc) if (dwc->revision > DWC3_REVISION_194A) reg |= DWC3_GUSB2PHYCFG_SUSPHY; + /* + * When dwc3 controller acts as host role with attaching one slow speed + * device (like mouse or keypad). Then if we plugged out the slow speed + * device, it will timeout to run the deconfiguration endpoint command. + * The reason is it will suspend USB phy to disable phy clock when + * disconnecting slow speed decice, which will affect the xHCI commands + * executing. + * + * Thus we should disable USB 2.0 phy suspend feature when dwc3 acts as + * host role. + */ + if (dwc->dr_mode == USB_DR_MODE_HOST || dwc->dr_mode == USB_DR_MODE_OTG) + reg &= ~DWC3_GUSB2PHYCFG_SUSPHY; + if (dwc->dis_u2_susphy_quirk) reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;