Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp669452ybl; Wed, 11 Dec 2019 05:46:36 -0800 (PST) X-Google-Smtp-Source: APXvYqyVbXknGUTacG74WA9f17g3HIhJBbCTUN7RnmMcjvcjoYDMCvNWH888bOdy1a9Ee9Pc7/D6 X-Received: by 2002:a05:6830:10d7:: with SMTP id z23mr2323792oto.114.1576071995990; Wed, 11 Dec 2019 05:46:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576071995; cv=none; d=google.com; s=arc-20160816; b=XZsMYTOIWoo2KX3rqAqx/WfVcuT8QpUjX6EXxmkabnN5OwPHxDXGChr1TkppG1TMMq XBKCKaqMwwYEaXVYSWIv5EXStT338crSmQ5r6E3tdzJZQhjaL2GTvLJlrR4I5DNXIZ+D nnloxfSipLB3nBDcBX8hNKtFIuqKjy2ljhX9i4tlbPQr4MyUvR2IKLoLbnE/m7vejpBp BNsN1woQEcLCIxrMTGHGBHozxlFdRnAK3LJwqqmecnkCJr+VItSTxj1s76VV16tY974j nRWD6rNYe3xmx0o1a2dkt2MUqfGZhA2qL5Na70OGhlwnRzNrI/y0LbqupGycOaGpZF29 s1BA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=H1+OGF6ey3bYfJsgI6snycRKkh0M980IQY8EfK1zMe8=; b=BDn7b/mKlFvctYTZDybVUIS+7TwI8TDexqu2fPfL3DsbKQnP/notHRXflOgYWHKceE QcALSahCV/VBkmHXrfY14ynSQ2CD9MHSgf5eRXlPlgbVJ/XZcWIjylqHOst0ElQxO3nB BesomNXwOSCsvWgf2iaDj24KyHtD+n0m15FqlAym/uilrfQwwRckxCNHh0MbF+gU88Z6 Om6NyHSoLi9qD5SsFv9wXjHyua4zcUoUaEVB5LW0Xa5PXNyGUA+TJcInGymIv6WYbQRr 9qDGmWN3RdYfpjp6R3xxJ9oOiG0nFEnQE/uG9xZI7/jnizN0XXqJx1+9N5t5tMeOXReO /d0A== 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 a205si1210634oii.95.2019.12.11.05.46.23; Wed, 11 Dec 2019 05:46: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 S1729675AbfLKNpi convert rfc822-to-8bit (ORCPT + 99 others); Wed, 11 Dec 2019 08:45:38 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:41608 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729540AbfLKNpf (ORCPT ); Wed, 11 Dec 2019 08:45:35 -0500 Received: from mail-pg1-f198.google.com ([209.85.215.198]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1if2J2-0008Qx-4P for linux-kernel@vger.kernel.org; Wed, 11 Dec 2019 13:45:32 +0000 Received: by mail-pg1-f198.google.com with SMTP id t12so9055082pgs.13 for ; Wed, 11 Dec 2019 05:45:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=kq+q9UoCbJWekUGal6VdA3tM3gj9G0YEqra+olhLR4k=; b=o8makLJPwvICu4CuG8KxlKDTVSwBvk9aXtqgIu86xpMMbWczJPEYXeUPNLnJ/X/I+R cA74DRtRUxPP0cZwKXQMhqx4DfyYdh/sIdvNNnN9N4PGftYGdC82PDjnWmdqCjn/TTrw kf4sLGWD8tyvlVAB0On+9o+B7+bc8hlW2ck8n+PbBMWxA+eUgEFTKFeqsoPrYt5FuwAX V+qySBWbENy9O+swxfGUHQJAXLliVs1BpGcbJ8OWN+VYIdW5mv1aVXaaMPRQTa2XPI9+ lyHW7DddPMLAuu01Zm57JOKUklMoBpMqsAjoanCKVsCHiT6zdnI6eWIZ6U6ChDGpMsPQ wGOw== X-Gm-Message-State: APjAAAVEX5ALm9ZWhnw5+XeoVgHKDy4XLH3dCYaK+pzqTeC7xLkjnaP5 6Dppskp4svbLtlyy5YX7/Mmz+zVSzjfqryvk5zI2DJkLuBd5Ixr0eIW9Ezv/ojhq9PCRuGXcx2g K1koLZJQ605t/tmJjOpdnasblZ3a+XgV0yGOzdl9pfQ== X-Received: by 2002:a17:902:6bca:: with SMTP id m10mr3367182plt.212.1576071930529; Wed, 11 Dec 2019 05:45:30 -0800 (PST) X-Received: by 2002:a17:902:6bca:: with SMTP id m10mr3367151plt.212.1576071930098; Wed, 11 Dec 2019 05:45:30 -0800 (PST) Received: from 2001-b011-380f-3c42-bdac-6ba6-1bf8-ef7f.dynamic-ip6.hinet.net (2001-b011-380f-3c42-bdac-6ba6-1bf8-ef7f.dynamic-ip6.hinet.net. [2001:b011:380f:3c42:bdac:6ba6:1bf8:ef7f]) by smtp.gmail.com with ESMTPSA id k101sm2824765pjb.5.2019.12.11.05.45.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Dec 2019 05:45:29 -0800 (PST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3601.0.10\)) Subject: Re: [PATCH v2 2/2] USB: core: Attempt power cycle port when it's in eSS.Disabled state From: Kai-Heng Feng In-Reply-To: <20191129174115.31683-2-kai.heng.feng@canonical.com> Date: Wed, 11 Dec 2019 21:45:26 +0800 Cc: stern@rowland.harvard.edu, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <62C4527A-5231-4A69-BE7C-9844E2123A90@canonical.com> References: <20191129174115.31683-1-kai.heng.feng@canonical.com> <20191129174115.31683-2-kai.heng.feng@canonical.com> To: Greg KH X-Mailer: Apple Mail (2.3601.0.10) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Nov 30, 2019, at 01:41, Kai-Heng Feng wrote: > > 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. If there's no objection, can this fix be reviewed and merged? Kai-Heng > > 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 >