From patchwork Wed Mar 11 04:04:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai-Heng Feng X-Patchwork-Id: 11430631 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AEDC4138D for ; Wed, 11 Mar 2020 04:05:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 98B4021D56 for ; Wed, 11 Mar 2020 04:05:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725976AbgCKEFJ (ORCPT ); Wed, 11 Mar 2020 00:05:09 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:37535 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725379AbgCKEFI (ORCPT ); Wed, 11 Mar 2020 00:05:08 -0400 Received: from 61-220-137-37.hinet-ip.hinet.net ([61.220.137.37] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jBscC-0002ym-Ui; Wed, 11 Mar 2020 04:05:05 +0000 From: Kai-Heng Feng To: mathias.nyman@intel.com Cc: gregkh@linuxfoundation.org, stern@rowland.harvard.edu, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Kai-Heng Feng Subject: [PATCH v2] xhci: Set port link to RxDetect if port is not enabled after resume Date: Wed, 11 Mar 2020 12:04:56 +0800 Message-Id: <20200311040456.25851-1-kai.heng.feng@canonical.com> X-Mailer: git-send-email 2.17.1 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org On Dell TB16, Realtek USB ethernet (r8152) connects to an SMSC hub which then connects to ASMedia xHCI's root hub: /: Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 5000M |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/7p, 5000M |__ Port 2: Dev 3, If 0, Class=Vendor Specific Class, Driver=r8152, 5000M Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 004 Device 002: ID 0424:5537 Standard Microsystems Corp. USB5537B Bus 004 Device 003: ID 0bda:8153 Realtek Semiconductor Corp. RTL8153 Gigabit Ethernet Adapter The port is disabled after resume: xhci_hcd 0000:3f:00.0: Get port status 4-1 read: 0x280, return 0x280 According to xHCI 4.19.1.2.1, we should set link to RxDetect to transit it from disabled state to disconnected state, which allows the port to be set to U0 and completes the resume process. My own test shows port can still resume when it's not enabled, as long as its link is in U states. So constrain the new logic only when link is not in any U state. Signed-off-by: Kai-Heng Feng --- drivers/usb/host/xhci-hub.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index a9c87eb8951e..263f9a9237a1 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c @@ -1776,6 +1776,14 @@ int xhci_bus_resume(struct usb_hcd *hcd) clear_bit(port_index, &bus_state->bus_suspended); continue; } + + /* 4.19.1.2.1 */ + if (!(portsc & PORT_PE) && (portsc & PORT_PLS_MASK) > XDEV_U3) { + portsc = xhci_port_state_to_neutral(portsc); + portsc &= ~PORT_PLS_MASK; + portsc |= PORT_LINK_STROBE | XDEV_RXDETECT; + } + /* resume if we suspended the link, and it is still suspended */ if (test_bit(port_index, &bus_state->bus_suspended)) switch (portsc & PORT_PLS_MASK) {