Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3096867ybi; Thu, 18 Jul 2019 20:58:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqy1SWYbijIcOqETa//vlSqaYsXe3nQKPyWk2a8sItdFF0AkgX51c/cmVt3fHlsrklshOowb X-Received: by 2002:a17:902:42a5:: with SMTP id h34mr56038112pld.16.1563508715982; Thu, 18 Jul 2019 20:58:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563508715; cv=none; d=google.com; s=arc-20160816; b=nSapLaK2LKJjUFYCJ8vh0KqIxfcS4WKT+iI2OU+nW3L3ba8w9n0LE9nCafS2yEu78e 5sceCVFpAJ/RQeCOZUdBBZd/cmX6k777uWNhSYcx7sRBLRCENbH9D17g4CrIGXsPWzvm JgU+mFOFBB3B5bVqyUpgtgYYnZh7ZW3GRp3FnfrI8R9eshUXVePUv6Qe3zBV1+I2634D X9DrG7QXiEVfqO71Zh+RL57dQcZNp7Ayl8y3eHdDZzRElbkopkhLj5RJEpJD3PZftYye u331cHTSgvILkVaMDt3/2DBR9Iam8wzur5AwqKyiWxUGgrd9SsXgL07rz/7bh7NY9Cqt x5hA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=OgRFujEtnfYfa7ZhK3Tzx1Mx70QMVboejCuFLepv43g=; b=JL+81krQFM3f2+ey7t/CAPJZfrVTD4z5DTp2w/nMr+EZ9FqV8E5Daxcls9D3oYO5d2 H5nflFr8v5CJTE17zzEtIS2hbz+xnMogv00ZB6pucaswiqSALplcrAhAs4xJlU5/edx3 Z90GcIoFs3ibgHdJriEWtHDvvNsGXAWNl0i61NRsx81FHY0ErJ+w0I7en+SrlfJT751v NiqRGBB94fpv9wm/KtqyPul/tJfdHajN7YgEgsMv2bbVE67rCQ9sYpAxzRVv4dkJfplq epKjn1Bh61E73ycnN1J/bodM3dQZjYH7hICzv05deIe1C/5qMLr+UVOBs2FhWRLrWiUa R4kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UuyOqfCt; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n187si2109674pga.165.2019.07.18.20.58.20; Thu, 18 Jul 2019 20:58:35 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=UuyOqfCt; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727083AbfGSD5L (ORCPT + 99 others); Thu, 18 Jul 2019 23:57:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:56456 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727035AbfGSD5J (ORCPT ); Thu, 18 Jul 2019 23:57:09 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D6FB72082E; Fri, 19 Jul 2019 03:57:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563508628; bh=5nlIZ57dU3SdNGPEIFlIlrt5lL6UPSybcNW76JuMcZM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UuyOqfCtfJIQA/mmmDP8AmQkKRhVJ/MGH5597KuSGL1wSbg8W7mwUJdYMGJXKYV31 x0PJY+4JQILvVoEDlFkcE4+OHpCME33LFEcgIeOcfBdQZThkYy5/kfHoMyEOql9YK0 CZLnxTvrtdAQV+ISHOX1zaJ6WiT/SedGAtDps0Ts= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Thinh Nguyen , Thinh Nguyen , Greg Kroah-Hartman , Sasha Levin , linux-usb@vger.kernel.org Subject: [PATCH AUTOSEL 5.2 010/171] usb: core: hub: Disable hub-initiated U1/U2 Date: Thu, 18 Jul 2019 23:54:01 -0400 Message-Id: <20190719035643.14300-10-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190719035643.14300-1-sashal@kernel.org> References: <20190719035643.14300-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thinh Nguyen [ Upstream commit 561759292774707b71ee61aecc07724905bb7ef1 ] If the device rejects the control transfer to enable device-initiated U1/U2 entry, then the device will not initiate U1/U2 transition. To improve the performance, the downstream port should not initate transition to U1/U2 to avoid the delay from the device link command response (no packet can be transmitted while waiting for a response from the device). If the device has some quirks and does not implement U1/U2, it may reject all the link state change requests, and the downstream port may resend and flood the bus with more requests. This will affect the device performance even further. This patch disables the hub-initated U1/U2 if the device-initiated U1/U2 entry fails. Reference: USB 3.2 spec 7.2.4.2.3 Signed-off-by: Thinh Nguyen Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/core/hub.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 2f94568ba385..79a9f0302ff6 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -3999,6 +3999,9 @@ static int usb_set_lpm_timeout(struct usb_device *udev, * control transfers to set the hub timeout or enable device-initiated U1/U2 * will be successful. * + * If the control transfer to enable device-initiated U1/U2 entry fails, then + * hub-initiated U1/U2 will be disabled. + * * If we cannot set the parent hub U1/U2 timeout, we attempt to let the xHCI * driver know about it. If that call fails, it should be harmless, and just * take up more slightly more bus bandwidth for unnecessary U1/U2 exit latency. @@ -4053,23 +4056,24 @@ static void usb_enable_link_state(struct usb_hcd *hcd, struct usb_device *udev, * host know that this link state won't be enabled. */ hcd->driver->disable_usb3_lpm_timeout(hcd, udev, state); - } else { - /* Only a configured device will accept the Set Feature - * U1/U2_ENABLE - */ - if (udev->actconfig) - usb_set_device_initiated_lpm(udev, state, true); + return; + } - /* As soon as usb_set_lpm_timeout(timeout) returns 0, the - * hub-initiated LPM is enabled. Thus, LPM is enabled no - * matter the result of usb_set_device_initiated_lpm(). - * The only difference is whether device is able to initiate - * LPM. - */ + /* Only a configured device will accept the Set Feature + * U1/U2_ENABLE + */ + if (udev->actconfig && + usb_set_device_initiated_lpm(udev, state, true) == 0) { if (state == USB3_LPM_U1) udev->usb3_lpm_u1_enabled = 1; else if (state == USB3_LPM_U2) udev->usb3_lpm_u2_enabled = 1; + } else { + /* Don't request U1/U2 entry if the device + * cannot transition to U1/U2. + */ + usb_set_lpm_timeout(udev, state, 0); + hcd->driver->disable_usb3_lpm_timeout(hcd, udev, state); } } -- 2.20.1