Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2656331pxj; Mon, 10 May 2021 07:55:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwe6T0V+SatvsX9Ae2swwHttYfEIcvvXMrwtK9owbPzVRkw6GgJDO8EKS0lzO2ZGGe3uJpD X-Received: by 2002:a17:906:ce5a:: with SMTP id se26mr26553026ejb.332.1620658540873; Mon, 10 May 2021 07:55:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620658540; cv=none; d=google.com; s=arc-20160816; b=O70kg3cmGB6fVWhh3TIbG1ZlJvMRCQeJQMAi1Z3MCtpb9xzCt+tRhxBhyulAjXTdYo FbgJfGuoOX8NFogxXLHDFwtkP7QGopsN2IalzxA6A1qg8rdg8lH1hm5bk55nZvdrBIDz u1/fJnv2LU3jNvCI001gc2aLk2s3iB/KvHR58EbJPg0RRCplFAvzrIqcoI34q/h1e7bH BcJDgaSLYYG9ZLRb3GUQij43syWFhxhD//0dTIL5wACvhUX599VCEW1umEJBXo80jxzH KIeChgJokGiaDVh51976UGZryK5B3LOd7+qX+qGGOthKXaMV9pVdgIoMi4UYNcBk7b2P yoxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=vZb/bG864VaGyxzMwwxn2dzyJlgvCtRCP/j24JY5Xp8=; b=BxVNR46FKfYPiSmoJZVW5litGMeqtev1aAw8Q6obJo0gJyv6FFBVSeBvZ2+i8owjzT /605MOQJowYcTzgNXG4KdZHA6OBCc7txQ59esTB2Z67CVZVsehbGWA2qmLcoCTBc1220 +SNvfuVWjz1hrxxZH64+4fhfVSCpp2DLscMN3ExLt8k+5sB6StP0YQyJnLeN3jV2YX6b tnG3l7cxm3TM2+NIjoDtdDOjB74Zlk3TMkvjy5zxoJbia9ZaSq3VZRE3vTwyr1Atv7Ot Q+2sxKJDSwwIrCdsvFLc0vYi/g6NzPuctTof7XsXEyop0e4hd6OzawmR1KUqtDUOqpMv Ht+Q== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d8si14547793ejp.14.2021.05.10.07.55.16; Mon, 10 May 2021 07:55:40 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240356AbhEJOyF (ORCPT + 99 others); Mon, 10 May 2021 10:54:05 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:47593 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239389AbhEJOwB (ORCPT ); Mon, 10 May 2021 10:52:01 -0400 Received: from 111-240-141-101.dynamic-ip.hinet.net ([111.240.141.101] helo=localhost.localdomain) by youngberry.canonical.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lg7FG-0007Dv-Q3; Mon, 10 May 2021 14:50:55 +0000 From: chris.chiu@canonical.com To: stern@rowland.harvard.edu, gregkh@linuxfoundation.org, m.v.b@runbox.com, hadess@hadess.net Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Chris Chiu Subject: [PATCH v2 1/2] USB: reset-resume the device when PORT_SUSPEND is set but timeout Date: Mon, 10 May 2021 22:50:29 +0800 Message-Id: <20210510145030.1495-2-chris.chiu@canonical.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20210510145030.1495-1-chris.chiu@canonical.com> References: <20210510145030.1495-1-chris.chiu@canonical.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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