Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp6000276ybf; Thu, 5 Mar 2020 11:05:05 -0800 (PST) X-Google-Smtp-Source: ADFU+vu8uSOpxwarBRS9Ut88HXUuVrgFADqy5Ibxm3BhTU2bznwQJj/5IlrMPDMkWbDLj/BjoR/Q X-Received: by 2002:aca:5f09:: with SMTP id t9mr405307oib.5.1583435104915; Thu, 05 Mar 2020 11:05:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583435104; cv=none; d=google.com; s=arc-20160816; b=AMlrj0+eQigntyPkBjujtgHEi1kBJ8umjBfj/EYy7fP6ULu4AbCA1bGc8i2S2CKGln tZvT+FCcfhh1LQtTFmgQY4I7PFC8ev4kAjM36vDdf5orZ/8cdrsvyG3MdmhtNVI5uosc EGZj7BT24Xz6C8F/LNRwk240D9W1LOwxKZafne0wHWsadyIj9e28gD3qmHWje07IwZNT LKZMFfD/boawBYI5CZazuRFbKsNAoED7n+YzIUw6fTp6I4J0ucwPuXw6FerzSqfaHL7q +pNsNOro6jtf2VYFEMoG2d4K/uadDKDsycPhseTdim4W0q22Ov62e+a/RRAJ8hLQ0L6v /9wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to :subject:cc:to:from:date; bh=+P7zwV86dtXaPt3+CYiVNung4kQVnQUgQYOR0oLkRsg=; b=qK7ev8pHBY1JUZGxIiZrY/MG5xy9+jqDWPgWvfTE8hMM1EO0DtssWRpaukbDxaUJ0/ tUZcaWzqpejtaI0CK7yDpmg+BL+haYaWuhm0lCiQtJTM8R+pacFEoQT051xrbG4a+rKW TOY2SvJCt5TzixJo/B8Bibtz01YbimCmKQD1jLETLlNULaIAu4hs/GHDG6mZxMvrp6BD q83ZK/SalzkVwZIiTL7hCdT9uYO0r4KC4Jm7C1o2bJdIJLWmurfxVz9sF493sCvqPtFg C64ChDyo1dut4ry0LE3n716c76IeTisiNKLoEdpmFPK7aYV5oypS5mwYfYHus+62Ofnz f01g== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m19si3620382otq.4.2020.03.05.11.04.52; Thu, 05 Mar 2020 11:05:04 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726233AbgCETCS (ORCPT + 99 others); Thu, 5 Mar 2020 14:02:18 -0500 Received: from iolanthe.rowland.org ([192.131.102.54]:44424 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1726173AbgCETCS (ORCPT ); Thu, 5 Mar 2020 14:02:18 -0500 Received: (qmail 3927 invoked by uid 2102); 5 Mar 2020 14:02:16 -0500 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 5 Mar 2020 14:02:16 -0500 Date: Thu, 5 Mar 2020 14:02:16 -0500 (EST) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Kai-Heng Feng cc: gregkh@linuxfoundation.org, , , Subject: Re: [PATCH] usb: core: Set port link to RxDetect if port is not enabled after resume In-Reply-To: <20200305072826.23231-1-kai.heng.feng@canonical.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 5 Mar 2020, 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 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. > > Signed-off-by: Kai-Heng Feng > --- > > P.S. This is and differnt (and should be more correct) approach to solve > https://lore.kernel.org/lkml/20191129174115.31683-1-kai.heng.feng@canonical.com/ > > drivers/usb/core/hub.c | 14 +++++++++++++- > 1 file changed, 13 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c > index 54cd8ef795ec..352e33c84d6a 100644 > --- a/drivers/usb/core/hub.c > +++ b/drivers/usb/core/hub.c > @@ -3537,12 +3537,24 @@ int usb_port_resume(struct usb_device *udev, pm_message_t msg) > > /* Skip the initial Clear-Suspend step for a remote wakeup */ > status = hub_port_status(hub, port1, &portstatus, &portchange); > - if (status == 0 && !port_is_suspended(hub, portstatus)) { > + if (status == 0 && !port_is_suspended(hub, portstatus) > + && (portstatus & USB_PORT_STAT_ENABLE)) { This doesn't look right. We want to skip the step the clears the port's suspend feature whenever the feature is already clear, regardless of whether the port is enabled. Besides, isn't this new test racy? Suppose the port was enabled when we called hub_port_status above, but it got disabled in the nanoseconds since then? > if (portchange & USB_PORT_STAT_C_SUSPEND) > pm_wakeup_event(&udev->dev, 0); > goto SuspendCleared; > } > > + /* xHCI 4.19.1.2.1 */ > + if (hub_is_superspeed(hub->hdev)) { > + if (!(portstatus & USB_PORT_STAT_ENABLE)) > + status = hub_set_port_link_state(hub, port1, > + USB_SS_PORT_LS_RX_DETECT); > + > + if (status) > + dev_dbg(&port_dev->dev, > + "can't set to RxDetect, status %d\n", status); > + } > + So maybe this part belongs later in the routine. Or maybe it shouldn't be in the hub driver at all -- since it is xHCI-specific, shouldn't it go into the xhci-hcd driver? Alan Stern > /* see 7.1.7.7; affects power usage, but not budgeting */ > if (hub_is_superspeed(hub->hdev)) > status = hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_U0);