Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3132131rdg; Tue, 17 Oct 2023 05:49:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH3iprB3Sm6MupReq3+FilSevrhp+g6KB8PutsHbD1w4+PXKj4W2HfpEENQrp7j5Kd6upFO X-Received: by 2002:a05:6a21:47cb:b0:15d:4a2b:b513 with SMTP id as11-20020a056a2147cb00b0015d4a2bb513mr1792944pzc.36.1697546975458; Tue, 17 Oct 2023 05:49:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697546975; cv=none; d=google.com; s=arc-20160816; b=mf3tjEAm8PNzc0zYyLvscU68tdvVFzwyD4W0BZo/NEWKMbDnlOfsOM7DswNJiFdWdW y6/+/lTbS8bypN+DGFFHIYIyhZ3lq3o4foOGVFqaLSryJxzQcJ4VvH4z5pu3i2adytkC 7i+nUbDh6FTKjQqUAExCp55cDFmJQmTWHnYKL7DyyHuRI11fZ4j4DBtBP3D9h04SV/QG WbnYcTVpP01ONC+K/99ySR0KhAo36IiiwSs2bXPaOrcS7lN6b1Gz+trl83RtbGf07bMH jLP4u6dbjf+KnvQt9IBIPcJsXOfHSP+twMBMZOMfsVjsBPZgQZLH6pUxEKFTE19A8qq1 bkiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :from:references:cc:to:content-language:user-agent:mime-version:date :message-id:dkim-signature; bh=RZE/NhCzbrZpN41hmVUfLA+pI7FBLRXIo5+OiyTXi9k=; fh=bfI5pB7C9K7aoAvwxqpo1Ou2bCTe/EJXvGWYQPXsgVo=; b=yBU590gg79LppNtD+2r0kR6xMwELkezyk2AjN0E7xZBm9klE6Pa8Ru4SdZj+jLfQJX DP5+zsq8VSfkE7GZADQRTwzyunwcjfXCeRV1HOcmvfGUeHUcVXuKO6ixtQpXwHDz72LV K4u312CvqiyuCrrmNKfrsj5V4Uz+t4Sb3rfP8r5H1VDaePX4boHcS8IoKU9Hbu1LtIjQ 0cbgaU7uur5xwz/jXW3wH2X3Sbf9/nLCI5bDxrLmoOu2+jEgHN+lI4zHv7tJDKfnNnoY L8GNS5OKdCdcOfIS5LcK29BFIQkrUKLorkTJdjJ/RNbRN82yjmfwILGiK7LwJzs4V8Un 6T/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ITy8woyf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id t4-20020a170902e84400b001c77674ea97si1733986plg.423.2023.10.17.05.49.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 05:49:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ITy8woyf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 672ED80C47B9; Tue, 17 Oct 2023 05:49:32 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234544AbjJQMtY (ORCPT + 99 others); Tue, 17 Oct 2023 08:49:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233315AbjJQMtX (ORCPT ); Tue, 17 Oct 2023 08:49:23 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5ACD795; Tue, 17 Oct 2023 05:49:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697546962; x=1729082962; h=message-id:date:mime-version:to:cc:references:from: subject:in-reply-to:content-transfer-encoding; bh=Vz3NwthM2agmUBZ7iXJuVbQIzPOwBgb/lOJg8aBciBU=; b=ITy8woyfnXVsWfzhNuc1XnbiGiKNvnkIyzctALCZFgSmvovpqSA59kWo F1l8g8TV+VMmuzyCWEb7F0KFaX1ONa6K17yBoxvCak4s0Pxw0bS9mPoLh mJhulnv5nMevl2Lqaatx/oOMFFq8dl6bIGFVx4uD0GV+4FAwQSCmGUEnB m0WrAGYtfA2cgpy9ZHdXnvEaidYhm6bf8gJT3TbgYDa8n6MQA5/QALdL1 TSXgETwLkQU4qrmdNJ8iIkUCwdSTNVek9m5O95d7WN/0TINvFM+BuxdZy 6yfG72tIfG7N3PgavmVE7J/WUgTgEmtMO+AR1K/t2ETtUKYowcnlJAbc3 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="385609331" X-IronPort-AV: E=Sophos;i="6.03,232,1694761200"; d="scan'208";a="385609331" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Oct 2023 05:49:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10866"; a="872553522" X-IronPort-AV: E=Sophos;i="6.03,232,1694761200"; d="scan'208";a="872553522" Received: from mattu-haswell.fi.intel.com (HELO [10.237.72.199]) ([10.237.72.199]) by fmsmga002.fm.intel.com with ESMTP; 17 Oct 2023 05:49:20 -0700 Message-ID: Date: Tue, 17 Oct 2023 15:50:48 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0 Thunderbird/102.13.0 Content-Language: en-US To: Wesley Cheng , mathias.nyman@intel.com, gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org References: <20231011220740.32297-1-quic_wcheng@quicinc.com> From: Mathias Nyman Subject: Re: [PATCH v4] usb: host: xhci: Avoid XHCI resume delay if SSUSB device is not present In-Reply-To: <20231011220740.32297-1-quic_wcheng@quicinc.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.1 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 17 Oct 2023 05:49:32 -0700 (PDT) On 12.10.2023 1.07, Wesley Cheng wrote: > There is a 120ms delay implemented for allowing the XHCI host controller to > detect a U3 wakeup pulse. The intention is to wait for the device to retry > the wakeup event if the USB3 PORTSC doesn't reflect the RESUME link status > by the time it is checked. As per the USB3 specification: > > tU3WakeupRetryDelay ("Table 7-12. LTSSM State Transition Timeouts") > > This would allow the XHCI resume sequence to determine if the root hub > needs to be also resumed. However, in case there is no device connected, > or if there is only a HSUSB device connected, this delay would still affect > the overall resume timing. > > Since this delay is solely for detecting U3 wake events (USB3 specific) > then ignore this delay for the disconnected case and the HSUSB connected > only case. > > Signed-off-by: Wesley Cheng > --- > Depends-on: > https://lore.kernel.org/linux-usb/20230915143108.1532163-3-mathias.nyman@linux.intel.com/ > > changes in v4: > - Added change log between versions > > changes in v3: > - Modified logic to determine if a USB3.0 device is connected. Using the suspended_ports > and bus_suspended bitmasks. suspended_port is non-zero as ports are runtime suspended, > while bus_suspended is non-zero if system suspend occurs while ports are active. > > changes in v2: > - Looping across portsc to determine if there is a valid USB3 connection. > > drivers/usb/host/xhci.c | 20 +++++++++++++++++++- > 1 file changed, 19 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c > index e1b1b64a0723..1855cab1be56 100644 > --- a/drivers/usb/host/xhci.c > +++ b/drivers/usb/host/xhci.c > @@ -805,6 +805,18 @@ static void xhci_disable_hub_port_wake(struct xhci_hcd *xhci, > spin_unlock_irqrestore(&xhci->lock, flags); > } > > +/* > + * Utilize suspended_ports and bus_suspended to determine if USB3 device is > + * connected. The bus state bits are set by XHCI hub when root hub udev is > + * suspended. Used to determine if USB3 remote wakeup considerations need to > + * be accounted for during XHCI resume. > + */ > +static bool xhci_usb3_dev_connected(struct xhci_hcd *xhci) > +{ > + return !!xhci->usb3_rhub.bus_state.suspended_ports || > + !!xhci->usb3_rhub.bus_state.bus_suspended; > +} > + The function name xhci_usb3_dev_connected() is a bit misleading as it only returns true if there are _suspended_ USB 3 devices connected. I got rid of this helper and did some other minor modifications as well. Modified version is in my for-usb-next branch. https://git.kernel.org/pub/scm/linux/kernel/git/mnyman/xhci.git/log/?h=for-usb-next Let me know if these changes are ok. If yes, then I'll send it forward Thanks -Mathias