Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp829410imu; Tue, 11 Dec 2018 08:12:15 -0800 (PST) X-Google-Smtp-Source: AFSGD/V0mixyqnrVRHehmpYMTRh5Pjip9Kdd0RTnBgADRq8fj+0qAoFzRYoUdnkxRrTL3YnuMK7+ X-Received: by 2002:a17:902:2867:: with SMTP id e94mr16754176plb.264.1544544735450; Tue, 11 Dec 2018 08:12:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544544735; cv=none; d=google.com; s=arc-20160816; b=cD+wh+BITC4cKdKSrZrJYiaRlOkDntE6+Bgi1xZRzjb1XRl4t3rCmh+bgJZWSgqO5I 6JN4i7G262NwVYrqshBqdqNhhH4KAKaeqF0G1v0v8aM+qoBPm4hhY14v77BGm2vh0R56 TRGV/soaYos59vo2FhxYUdSicqCm1fq0hkJXohH9NOVJFVL5gM0FHU4DmIT7kdWI/YJ3 cNy3kfzUygrqu/NBcnDXqNMeCLZZmVuA11S/Soja46G8T1/ktx7WxYb5xrAjccl3M2A4 FbZbfeJWaIByoAqPABFQPpzgjR6JWw9Ga2X6f3vKR4KSO2QSVNPC6f7rprnIPYasmBGW xj4g== 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=kif+hpDrJvOST7gw5+c44P21jtL8wtw1Vefzpqs6pjo=; b=EzhVXUpLmk0AXQrIMmZqvXTI7uLmxuDjqJjRGUF0nH6k+IwM5+9A88DIagjRFmOSU4 K/eraO1Ky+X/e2u74RgdcmzR8yRu++wbRHQGouUsRJ9P3eYQKwZmhRMHOwcKUWv7stJd dhvgj5ajOtGY5Eo+nrS8ABPf2+ynkdTtvSnr4y5iHTPvSmsJwyOyWYOCNTkjcIWkNINP 5deSs0jjQq1S2bOeCNVYKC0HvAKyQFVABF2IksjJ/ppStsOTt3o7N3QN3uq/U4WGBi5M SZ+Xnvm4c8cMI3+VdJiqeTe2TnUGiYjMeez0ZPQa+bCSBKhmHrmmMkNSZ+xt25UzV3CE mEGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vF8MSQT5; 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 q7si13543962pfa.99.2018.12.11.08.12.00; Tue, 11 Dec 2018 08:12:15 -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; dkim=pass header.i=@kernel.org header.s=default header.b=vF8MSQT5; 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 S1730229AbeLKQIu (ORCPT + 99 others); Tue, 11 Dec 2018 11:08:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:41484 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729794AbeLKPws (ORCPT ); Tue, 11 Dec 2018 10:52:48 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 682FB2145D; Tue, 11 Dec 2018 15:52:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544543567; bh=Mx+5D8LjUjhgz2+xFNhHEdMrpu5I8nK8PpKqb4cPkXM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vF8MSQT5Bx/vNCqdvT/+lQHKCtHLQoUtAuHJHXa630XKf/K7HgXOc0TUemmo7vFex RNJUOsDCyuIWwCb4BcUT9qTLD4uXKc3X4s2efV/Tq43OHQthMt7aqoxzS7o1y+rLFl R81930ZXN4SlEYqMYDvM+XnbpJC9EogO0QatlbMA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mathias Nyman Subject: [PATCH 4.14 48/67] xhci: Prevent U1/U2 link pm states if exit latency is too long Date: Tue, 11 Dec 2018 16:41:48 +0100 Message-Id: <20181211151632.818689898@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181211151630.378216233@linuxfoundation.org> References: <20181211151630.378216233@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mathias Nyman commit 0472bf06c6fd33c1a18aaead4c8f91e5a03d8d7b upstream. Don't allow USB3 U1 or U2 if the latency to wake up from the U-state reaches the service interval for a periodic endpoint. This is according to xhci 1.1 specification section 4.23.5.2 extra note: "Software shall ensure that a device is prevented from entering a U-state where its worst case exit latency approaches the ESIT." Allowing too long exit latencies for periodic endpoint confuses xHC internal scheduling, and new devices may fail to enumerate with a "Not enough bandwidth for new device state" error from the host. Cc: Signed-off-by: Mathias Nyman Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -4381,6 +4381,14 @@ static u16 xhci_calculate_u1_timeout(str { unsigned long long timeout_ns; + /* Prevent U1 if service interval is shorter than U1 exit latency */ + if (usb_endpoint_xfer_int(desc) || usb_endpoint_xfer_isoc(desc)) { + if (xhci_service_interval_to_ns(desc) <= udev->u1_params.mel) { + dev_dbg(&udev->dev, "Disable U1, ESIT shorter than exit latency\n"); + return USB3_LPM_DISABLED; + } + } + if (xhci->quirks & XHCI_INTEL_HOST) timeout_ns = xhci_calculate_intel_u1_timeout(udev, desc); else @@ -4437,6 +4445,14 @@ static u16 xhci_calculate_u2_timeout(str { unsigned long long timeout_ns; + /* Prevent U2 if service interval is shorter than U2 exit latency */ + if (usb_endpoint_xfer_int(desc) || usb_endpoint_xfer_isoc(desc)) { + if (xhci_service_interval_to_ns(desc) <= udev->u2_params.mel) { + dev_dbg(&udev->dev, "Disable U2, ESIT shorter than exit latency\n"); + return USB3_LPM_DISABLED; + } + } + if (xhci->quirks & XHCI_INTEL_HOST) timeout_ns = xhci_calculate_intel_u2_timeout(udev, desc); else