Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3312025pxf; Mon, 15 Mar 2021 06:56:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9Z6ONMw3QdAmGUgYuGydzGb9tEuRRItLnZngT+r9N/l+CE5qWQ+rY1k+lT96jWEYa6pga X-Received: by 2002:a05:6402:31e9:: with SMTP id dy9mr11941020edb.186.1615816617227; Mon, 15 Mar 2021 06:56:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615816617; cv=none; d=google.com; s=arc-20160816; b=Ah2cpYYGrEpF6W5/gfkQ6Ms6Qh2eFAPXS5hmXizk49uZYAe5c6Kp2x4Dza1OXk4/eG git5sQilpsNFagOiWvzw4qYf/zOTqigY0jRH+eAZvTO/xm+hMjS1Bio5QiVhVR11ndJi 1Gpa9pwo3hIdWKgQ/7HoDlho6KQkaRywnnEalOd9SZcrQWps8orRVZ/cIUpCm1b1IckL 74b7xU2Zr5iyBqg+WUDgQUTjiKpRGRYA92BalW1vC32HUrxjfBxsnmGzUZ5Udx65VxsU kGu/T4KeMOPJcjl41n5dx19u2bNPCFykFVm5a15UnuD/+7bfdOPlZV8FYWSY86KlSo5E tagQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=tYN1Krs5Y0KALpD2LMRraHUjPMyFMitAotCGN0lKmvc=; b=Q/yXd2u8lfiwYWp2wHl9E3r6oH4CNiTo79qz1eW8NrrzdpEiP1QIomzjYb0iZLV1qb CK4UG7vghoxpOdsDyOX6pHkD4ty37XRE4VXiRJao65fJkKLbwXGavQUsXsw1LIqey9Uq jQSlCOGUwtv9klDEBVZI5ONs9ZaQXB0rhfHaC/stYad/oSbPGQhxStZ4PJu1MqIRfczO ncREa2ANn6F7z8iPnGNnupRPjJ4TpuMzR50m2YzYCsgmTY0j9ymhrqiRvhjeWdoNvyTg MXZyecGv8J3NSJ54hZ9pKL1OZKK6SVuNZjlRDx07JFU++peVKh6zuwW7OS8uX3YokYAD Wfag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wGij01Mz; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y1si8248717eds.133.2021.03.15.06.56.34; Mon, 15 Mar 2021 06:56:57 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wGij01Mz; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229928AbhCONzh (ORCPT + 99 others); Mon, 15 Mar 2021 09:55:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:56750 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230458AbhCONxn (ORCPT ); Mon, 15 Mar 2021 09:53:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id EF9B064EF0; Mon, 15 Mar 2021 13:53:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816423; bh=kSqBe/A4bqMgkGYMNTqU0l0cCvmalAM90/thRxHwqzU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wGij01MzqGcQjuZao30fsMpysypIeZWpXU/xq+AncM/nexjczHhuOWf9vbVxNem4O 0PWSPVr3nEWdEcU5Qe9vP6cYLIf/vH9PCKMOCCAQzksJON5qxW3uHET7xGt31k3LV/ 8OxvCt28NruRI4Nt+8RiaGifNSK0BsQU6IpSuJX0= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mathias Nyman Subject: [PATCH 4.4 35/75] xhci: Improve detection of device initiated wake signal. Date: Mon, 15 Mar 2021 14:51:49 +0100 Message-Id: <20210315135209.395589774@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135208.252034256@linuxfoundation.org> References: <20210315135208.252034256@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Mathias Nyman commit 253f588c70f66184b1f3a9bbb428b49bbda73e80 upstream. A xHC USB 3 port might miss the first wake signal from a USB 3 device if the port LFPS reveiver isn't enabled fast enough after xHC resume. xHC host will anyway be resumed by a PME# signal, but will go back to suspend if no port activity is seen. The device resends the U3 LFPS wake signal after a 100ms delay, but by then host is already suspended, starting all over from the beginning of this issue. USB 3 specs say U3 wake LFPS signal is sent for max 10ms, then device needs to delay 100ms before resending the wake. Don't suspend immediately if port activity isn't detected in resume. Instead add a retry. If there is no port activity then delay for 120ms, and re-check for port activity. Cc: Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20210311115353.2137560-3-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -1018,6 +1018,7 @@ int xhci_resume(struct xhci_hcd *xhci, b struct usb_hcd *secondary_hcd; int retval = 0; bool comp_timer_running = false; + bool pending_portevent = false; if (!hcd->state) return 0; @@ -1151,13 +1152,22 @@ int xhci_resume(struct xhci_hcd *xhci, b done: if (retval == 0) { - /* Resume root hubs only when have pending events. */ - if (xhci_pending_portevent(xhci)) { + /* + * Resume roothubs only if there are pending events. + * USB 3 devices resend U3 LFPS wake after a 100ms delay if + * the first wake signalling failed, give it that chance. + */ + pending_portevent = xhci_pending_portevent(xhci); + if (!pending_portevent) { + msleep(120); + pending_portevent = xhci_pending_portevent(xhci); + } + + if (pending_portevent) { usb_hcd_resume_root_hub(xhci->shared_hcd); usb_hcd_resume_root_hub(hcd); } } - /* * If system is subject to the Quirk, Compliance Mode Timer needs to * be re-initialized Always after a system resume. Ports are subject