Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2665515pxj; Mon, 10 May 2021 08:06:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVW/WOYsx+z82wMzSMKIkgCSXRxL4eQLKYWszuHSfPiMec/9yA+WW1ldNw3TKXPtx/Rj3a X-Received: by 2002:a92:d9c2:: with SMTP id n2mr21804688ilq.284.1620659197875; Mon, 10 May 2021 08:06:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620659197; cv=none; d=google.com; s=arc-20160816; b=x8/TO+lfIyiT85ajyWlCzWopK0ufNCTmbIt7Gwi/w1X3CaYU9BOpSRo8Nu9B93VuOL p1nJQL5P5543H4qTEKvvgfxAalb4RKAMssVIDZmtC7Fqna9qNPeFI6Avbhn85kVNHmoU +gUWJC9XTZ6+eOlHal9/HUr+K9S0Muu/pNP2oie9TSEqj+ZG97yzix+rrGVn6hsg86Lh BFHkA0MNszZxysVgvdZKem/p9/ydu0ID3SAuRKk/YPkdjKbt+ydP2fCxvh8cPFrHvatI xPXMYq/na7Aqz7KAgRtX6G35nDee5OZip1eMsEZzocUr8ll7jWPXTlkbzooj7ipWp/I5 TKJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=hTS7YCV47G4IiOxglinn/UanMeJn9ZQhrGPenwWZ3VA=; b=wKKCV/zasIXbgvR/yOXgkfQEBjbgSI62PmMcF4dDPjkced/fEj5+wdJL5OXe3ENHhg bcH5TeVyd2g+/eJhbfbVzCSO5gJdVSNuYI4yI/d3fudpIVmwj0mYeUMA0er2hwh6YVuK gSnrWC258CF76dAHy2lnx2PqwWvbpgGiBn1nNLIl+V0w+7kpMSEH3xsK/GwBSEv4HyHz r22IIHyxUQCp7TToSVMDkwl6AA9tYOHdqeFf3YCnmI1cgrosC1eJN45BbjvwrWuagKCy 6EtC8q5Q100vAiAddJVneupLtuTQFEQVkj4BVHtf2vJhJNl76gv7RS/3JO1O/az6xyvV uCUQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f20si13432241ion.8.2021.05.10.08.06.20; Mon, 10 May 2021 08:06:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240656AbhEJPGm (ORCPT + 99 others); Mon, 10 May 2021 11:06:42 -0400 Received: from netrider.rowland.org ([192.131.102.5]:38697 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S232164AbhEJPDP (ORCPT ); Mon, 10 May 2021 11:03:15 -0400 Received: (qmail 865031 invoked by uid 1000); 10 May 2021 11:02:03 -0400 Date: Mon, 10 May 2021 11:02:03 -0400 From: Alan Stern To: chris.chiu@canonical.com Cc: gregkh@linuxfoundation.org, m.v.b@runbox.com, hadess@hadess.net, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/2] USB: reset-resume the device when PORT_SUSPEND is set but timeout Message-ID: <20210510150203.GD863718@rowland.harvard.edu> References: <20210510145030.1495-1-chris.chiu@canonical.com> <20210510145030.1495-2-chris.chiu@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210510145030.1495-2-chris.chiu@canonical.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 10, 2021 at 10:50:29PM +0800, chris.chiu@canonical.com wrote: > From: Chris Chiu > > On the Realtek high-speed Hub(0bda:5487), the port which has wakeup > enabled_descendants will sometimes timeout when setting PORT_SUSPEND > feature. After checking the PORT_SUSPEND bit in wPortStatus, it is > already set. However, the hub will fail to activate because the > PORT_SUSPEND feature of that port is not cleared during resume. All > connected devices are lost after resume. > > This commit force reset-resume the device connected to the timeout > but suspended port so that the hub will have chance to clear the > PORT_SUSPEND feature during resume. Are you certain that the reset-resume is needed? What happens if you leave out the line that sets udev->reset_resume? The rest of the patch will cause the kernel to realize that the port really is suspended, so maybe the suspend feature will get cleared properly during resume. It's worthwhile to try the experiement and see what happens. Alan Stern > Signed-off-by: Chris Chiu > --- > > Changelog: > v2: > - create a new variable to keep the result of hub_port_status > when suspend timeout. > > drivers/usb/core/hub.c | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > > diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c > index b2bc4b7c4289..3c823544e425 100644 > --- a/drivers/usb/core/hub.c > +++ b/drivers/usb/core/hub.c > @@ -3385,6 +3385,21 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg) > status = 0; > } > if (status) { > + if (status == -ETIMEDOUT) { > + u16 portstatus, portchange; > + > + int ret = hub_port_status(hub, port1, &portstatus, > + &portchange); > + > + dev_dbg(&port_dev->dev, > + "suspend timeout, status %04x\n", portstatus); > + > + if (ret == 0 && port_is_suspended(hub, portstatus)) { > + udev->reset_resume = 1; > + goto err_wakeup; > + } > + } > + > dev_dbg(&port_dev->dev, "can't suspend, status %d\n", status); > > /* Try to enable USB3 LTM again */ > -- > 2.20.1 >