Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1167422ybi; Fri, 2 Aug 2019 10:24:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqxze6WUAwS2PpR741OSffbp53omhI49R0uBgI/hlxur4/p9Kp+5OG0JWapLRNSr74uhFyd7 X-Received: by 2002:a17:90b:f0f:: with SMTP id br15mr5383546pjb.101.1564766681343; Fri, 02 Aug 2019 10:24:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564766681; cv=none; d=google.com; s=arc-20160816; b=GqLEobInnhZszbz5lTO6d7ilT1/edLfUhHmCf9bw1rX66sZy9TVbeItakIeoLyu7yi r5pguj3oNTlZ7RzkC5OBlwFDzIfqgP5zErfA2MVA4T7K5P8e0UfD0vQxG0HNcKxe9b0O SBLn/2b8yonnYmoeqxr+nXv8hQOsRzIox7TKzB7xCjEsWStw3yG5LaECmQdTArPWX3Ux 56lDl0nR6Y4t7ucSbm/BYRslQjL40oTbhoo56lx76OmvueN9U+va7CUIsAddyYePTRkM UdOaDSLAMTvjFbbb0argr57u27EY4FgHUxP2AN1IEE/GP7NeDFlEfY2FrrgaFp5hKh9/ +upg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=IY/fLcUJtmGcamwHESn8qO5h4FMxeIcFpl7koLhBgbE=; b=GA9ELQfq1NtLFD0slbzJqSaxWpXAqqs+aDdPk4AeQPDlVI4KkxTVMz7j+9XX61bjeK Alidp4PJzdiBxT5kU7hZC7tjy+wBBFtzJguCbq98BiWa7jbuMECT3nQdFdxMoScik8Jn iKPypTffNjVx47bTfzFzyMkQqV8jntWO2d3L0Y797CWza2vigtevAfLl95OHQWGfSzQL lnwBKdFlAc8QqSC/NvwwrJs9mQPR7ftjIC1oL4fzHRc3+L2bVBwLU+auXZ64CyZAPAUE nrkndgNjptnNO43a6cj7wcZoPeCuAYiPq3SRxGzK7eo9fBtdTFXm/Ss2y3wa+3kB544X dI7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1FRVMptV; 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 9si1568892pgo.283.2019.08.02.10.24.26; Fri, 02 Aug 2019 10:24:41 -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=1FRVMptV; 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 S2405648AbfHBJrN (ORCPT + 99 others); Fri, 2 Aug 2019 05:47:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:51874 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405639AbfHBJrK (ORCPT ); Fri, 2 Aug 2019 05:47:10 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B397E206A2; Fri, 2 Aug 2019 09:47:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564739229; bh=k1DdW9q4s8i60smQGx86EQOHfoeowZDWDTC7zIaE1fw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1FRVMptV33tSBJMERmbxeJmlZxtWDmsSJ+ALggpVv4TLJ4/u4Um+4qGitbjw6UplF SckDleV86oSdfsb30VJG6iXWqwJhAum1w7mWJfr7jScyD8aWxMuYqO1WebTvCM7SYI EpPeV/tYuMAMO0Nh4yOceh5yhzkskJLAdg5jllr8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thinh Nguyen , Sasha Levin Subject: [PATCH 4.9 160/223] usb: core: hub: Disable hub-initiated U1/U2 Date: Fri, 2 Aug 2019 11:36:25 +0200 Message-Id: <20190802092248.588783817@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802092238.692035242@linuxfoundation.org> References: <20190802092238.692035242@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ 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 9f132fac7b2c..63646dc3ca27 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -3879,6 +3879,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. @@ -3933,23 +3936,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