Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp129700ybh; Tue, 10 Mar 2020 21:05:58 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsfqUZZ16YUlakg161j8cYEKOl1LvPMuJm6zi9Y9K/flFozlW4q1dfiIgxazHK/qutP4Wg1 X-Received: by 2002:a9d:19c8:: with SMTP id k66mr772550otk.43.1583899557928; Tue, 10 Mar 2020 21:05:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583899557; cv=none; d=google.com; s=arc-20160816; b=w8+Rl8gRCoeYxQ/TxGASRJpFyM5zpzvPPE4MLoEgpTWc6nVdEhktXbP2yo6LwjV9Zs TOOHrTmw5tfR1oQ+y4Zcirx7jEyHk5/FGuvozU+ZjdjwPS1me4jMIotaqYj/M99XyFiW ujBYkmoeY2jVj+j3DBY+oCDCbZoLd+9E2S/F45YnmmdxL/6Bdb0qB35aFf/WQEksNxbC PC6PoruL0IYWt08tmG9BB9p6tWcAddsPdDK/pl9bAeq+yHw/sxP619GizKyDZcDT1b0K fUWFaGtqmraoyENn6BLKTvyODmUBLZxDr3n4A8qPurYdkVhatRvnPQA91nlT+MyGVQPt oSiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=aWYsbvDWBDg6falqR+tR2Fi9msKz4ipwyOguP4XsZsE=; b=OF5abeSvOy5KbAoqA4USy3XfnrVquwC/Vj8iXDcHHollVDK4ugWbwMXKaEjH3/gfmk 5f/llEw8L1lQfG3Tn1A7dO0SBngjycguWBYn8I2AEicB7ROLSCprle0mdeyhlzDBpJ9Z gXdxYXtn/O2aa/DBWuOzfhnlJ4E8BFPURRUjh3/7Y9fPnILBqpWAbsN6xSiwUtlHJfuh CrSXOcT2zBeapEzhKKOz9LIFrSY5NOAlsPiOR9DQG6WEzUjCrZWlbVOHXOdxX9wFYBpr clWOHOQ+goqYy/s04QMu8r4fnGh6aphRSc0/kh26e/Ef/Uvx+MV7lujfHVvDlDXBmBmq v1WQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z107si415007otb.292.2020.03.10.21.05.45; Tue, 10 Mar 2020 21:05:57 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726554AbgCKEFJ (ORCPT + 99 others); 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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) { -- 2.17.1