Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp8390877ybc; Fri, 29 Nov 2019 09:45:35 -0800 (PST) X-Google-Smtp-Source: APXvYqxFDgOnEhh5vShj7/WDRLMhdZxm+X1MBJM41xOURoPjZgDNuOtp9x54yhp66nh82nHEnPJH X-Received: by 2002:a17:906:7251:: with SMTP id n17mr11350681ejk.329.1575049535208; Fri, 29 Nov 2019 09:45:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575049535; cv=none; d=google.com; s=arc-20160816; b=RfZZJtuZXtO8P36P87KDHYuQeMlKjwvWcQrDqphaE09cWS/2JgHX6WJSXehjY5dtcT FB1Ug4lprEpMcSKUWlzd375CdvDjMuDsV//FqyG/JZTqYaNe6ll+VenfxaTBieLzL0eI lsKBZNFY0Crde0e1N0SGjyePSUrEMyS1Yw1ELq/eeGtqBVpzHMBT6IWh0Bo9m1HKeQVK GHTYfQZSfcqPxKWoCfp23KxMZRXMe7AY1Eq2kwFhGjH8GUrJ1SfLvMQyouwLltT/XGzo RF6rRjHreKwijChmqKDPeoR2WGz1VtsDw3jVfgcZZFtBPnOAOtvgQAQbc616wpMvCZ/c WRIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=f6Kc7OnbEDzvbeQbFDa+HUV5cYpLWRPtxL+hQ3cseEM=; b=pH81lWAYX6HmPlMPoHixA6Q1EYSKYTbuBJ/h1BXoQMtxxrJcWwqhzmd0u7X97OL46F i5MUWs1sZNrRLZuFnjfqsun1jXde2OoXUIPVAad44RoRmosQIw7XaHy+7WVkeW6WoNas 6fFYaoDm8pSqFkK62TbYn68/xd+L3hdsKKAaMyREtaKRVlf+MHVj6h3FO/YkhKTfiiTQ 64AZZVoRIIcnRRbSxq+lcD4z2oj8ptlrZOhzXj5JoH+Tyy3b7jNqawNsNNAgLrMm2XVz apEbgH0j51uMRj26vzT1kA1HPgb0dPH+MWw0uVMLyAGbutWq5G4snmmTDvksDyPSi9c1 HFCw== 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 sd13si14727662ejb.206.2019.11.29.09.45.10; Fri, 29 Nov 2019 09:45:35 -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; 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 S1727097AbfK2Rl2 (ORCPT + 99 others); Fri, 29 Nov 2019 12:41:28 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:52169 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726970AbfK2Rl1 (ORCPT ); Fri, 29 Nov 2019 12:41:27 -0500 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 1iakGi-0005XR-JC; Fri, 29 Nov 2019 17:41:25 +0000 From: Kai-Heng Feng To: gregkh@linuxfoundation.org Cc: stern@rowland.harvard.edu, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Kai-Heng Feng Subject: [PATCH v2 2/2] USB: core: Attempt power cycle port when it's in eSS.Disabled state Date: Sat, 30 Nov 2019 01:41:15 +0800 Message-Id: <20191129174115.31683-2-kai.heng.feng@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191129174115.31683-1-kai.heng.feng@canonical.com> References: <20191129174115.31683-1-kai.heng.feng@canonical.com> 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 SMSC hub may disconnect after system resume from suspend. When this happens, the reset resume attempt fails, and the last resort to disable the port and see something comes up later, also fails. When the issue occurs, the link state stays in eSS.Disabled state despite the warm reset attempts. Accoding to spec this can be caused by invalid VBus, after some expiremets, the SMSC hub can be brought back after a powercycle. So let's power cycle the port at the end of reset resume attempt, if it's in eSS.Disabled state. Signed-off-by: Kai-Heng Feng --- v2: - Lower dev_info() to dev_dbg(). drivers/usb/core/hub.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 6b6cd76ac5e6..a2e6001046f5 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -2739,6 +2739,18 @@ static bool hub_port_warm_reset_required(struct usb_hub *hub, int port1, || link_state == USB_SS_PORT_LS_COMP_MOD; } +static bool hub_port_power_cycle_required(struct usb_hub *hub, int port1, + u16 portstatus) +{ + u16 link_state; + + if (!hub_is_superspeed(hub->hdev)) + return false; + + link_state = portstatus & USB_PORT_STAT_LINK_STATE; + return link_state == USB_SS_PORT_LS_SS_DISABLED; +} + static void hub_port_power_cycle(struct usb_hub *hub, int port1) { struct usb_port *port_dev = hub->ports[port1 - 1]; @@ -3601,6 +3613,10 @@ int usb_port_resume(struct usb_device *udev, pm_message_t msg) if (status < 0) { dev_dbg(&udev->dev, "can't resume, status %d\n", status); hub_port_logical_disconnect(hub, port1); + if (hub_port_power_cycle_required(hub, port1, portstatus)) { + dev_dbg(&udev->dev, "device in disabled state, attempt power cycle\n"); + hub_port_power_cycle(hub, port1); + } } else { /* Try to enable USB2 hardware LPM */ usb_enable_usb2_hardware_lpm(udev); -- 2.17.1