Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3527035pxf; Mon, 15 Mar 2021 11:32:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1/RTXhysCtaBxVtnvkApa8QW2MwBW6I8c8DYdiDPfnuie5jB/OG/BrQPfcGTmyz14xPrm X-Received: by 2002:a17:906:33d9:: with SMTP id w25mr26245947eja.413.1615833126477; Mon, 15 Mar 2021 11:32:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833126; cv=none; d=google.com; s=arc-20160816; b=mgxuYp2Bwo4Zr5MzY8N8+KDyY7SoNpfJ5wq+NxDNWyNcthA/ujPwIrt7k9Y767h73t OYEjAcc3LVo/eAx6Wlof5YH4VlVRINgFibuToniUf13CZxXYw98n6xHX1loPYMR6n0OP mzgjkCyQifBlLrtYc2qDAboeijxnAmO/9X0r5fRH4ytSfNZPzHtD8b+KxiseCX6SZF6Y k6+mCQ/2HFxBu1IHTM9Nl+hR3CmKy7NKTn4d3CRdCKJDF73etF7dFkH1ofU1LayAtT59 nNYzNKEodh1Sa+0dHyRJC+nzxft1sN/3HmWbfJwpS3ILBSPIyi+isbIs1uRuytIOU50x ZFZg== 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=/PECawXkVLW84qejtC09HcfpvpjTCrncnuns7l0WYLE=; b=UF7jwHSm3CJoFIM7sA2F1e55Jc6WfXPqjsH50itjQgt5pQfKzrWNCXgaxBE1frjAqM fLnkezuLwqKWa0Id14AeefwelQ9aKVA2xgNrNcI186r3e1+5+Xw+8EYA51gubkf8pQ0s 3kI3deeB3+Ye1mYYxrn/N8f859/qtK4HHCNbmXC9DtG6vdZHz+WOyO6kd5cyFCs7Ro+6 9KS7eXPytgNm84Wie8AgUZ6+neS13HUKjjSCUAqwmH0aSBrfiSKY72EIl2amyXo8BlNy 4LIFJxOX1AuhT4AVEAhobvexsiRzvThnnJ5/G4HVqN6EIig+9wKs+8Ojmy72cn3a6/iW qMjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uWh19LU8; 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 i13si11799074eje.417.2021.03.15.11.31.43; Mon, 15 Mar 2021 11:32:06 -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=uWh19LU8; 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 S237375AbhCOOki (ORCPT + 99 others); Mon, 15 Mar 2021 10:40:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:48920 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233643AbhCOOCP (ORCPT ); Mon, 15 Mar 2021 10:02:15 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3324864EEF; Mon, 15 Mar 2021 14:02:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816924; bh=j/cRpuSaTG/ikfUPjVyiZeucg2SiJvxu/HB5bNElkEs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uWh19LU8MTzQDcCumCBBTpxOz/3FASqwYNsI7v0a651igXsrU1VNhRYdpKes7Doqq yyal/lq+b/bQq6rroHm+mzoDVKDjBuvktqEOc6xneKhKEs99FzQYzdXMVDfnEwUhhD /uviVtyac23upq0jNrAjW+NqV9fd/CH4lB6mLMZw= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mathias Nyman Subject: [PATCH 5.11 205/306] xhci: Improve detection of device initiated wake signal. Date: Mon, 15 Mar 2021 14:54:28 +0100 Message-Id: <20210315135514.565777322@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135507.611436477@linuxfoundation.org> References: <20210315135507.611436477@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 @@ -1088,6 +1088,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; @@ -1226,13 +1227,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