Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2992893pxm; Mon, 28 Feb 2022 09:54:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJyiMvbQF/oseMLIZGLoKfzhj3aBrRhS/ExaqDHNBsTAY/gBlTZB+/YWDQQZiKiMzTf1po5C X-Received: by 2002:a63:515c:0:b0:376:8fe1:36e0 with SMTP id r28-20020a63515c000000b003768fe136e0mr14948811pgl.235.1646070887189; Mon, 28 Feb 2022 09:54:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646070887; cv=none; d=google.com; s=arc-20160816; b=KAVZ3OaTmuaSgW2ywClr8bfJtInpQ4cAHjSMUqQAIhnmu2Dyo980BqgDZG4I+tcsaC VFMBPJMi1fgFl7h3y1KDKOwidIbGVu3nUXJzLctBk/94xdUkNkXQwk/sbsHKp9S7PSdd TibZpSMwdb43sKfPAU1FUP/i/9kD/6Nl11tQKUjJj3BBRBXfJJiskbrenR0w4NS+K+pV XOBrN3x421r+tCjDg/yXGbFuvddz+Cchlsq2RI2LgzOjl9/ScLb5QNhEgZNCBTdNg2ZF 4pO9J89itX3sWKKdneiyzSVdTrH+ZlpzHta2ogGIs0ktoe92kw0P7FBIIrGjTFRU+4AE chnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:subject:from :references:cc:to:dkim-signature; bh=7G0DPnRQy7bTxS/BS42a2E9dUaFx6oZgz/Pm1iK84FE=; b=DI7omNSs77DTXIlZ+fmfqACArwOdvM7yh4HFi+wP2cjwwfuv83AP4XN+n2G5ynvEyk 5gZhy8Q80SIp9eK3+VBwu67LTYsz6FQpL13mL5TKZLsHJj2TwurJwRuWzzbFWpVO0sOv +5fobphpGHLE3DAHKspAte6wBGHK9Ejr5dJfxTA6AwrKwlOE8Dc47lCicXPFR2OAVLHv loKZ0LBht9pYBuMIrgDB5OgAnD8vjNTitjkGFRwO1DnOK3ldf3tzbEPZipbjkXnK4Gcb ZmmUnOtgwFpiPC3lMSadP6nPFLCRhtRl5xoFggEXlkyzNDztMgnr1DH5RgJdnqzaHstZ bU5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nICViPDr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nd7-20020a17090b4cc700b001b9f59a8519si45704pjb.174.2022.02.28.09.54.31; Mon, 28 Feb 2022 09:54:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nICViPDr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235370AbiB1K6m (ORCPT + 99 others); Mon, 28 Feb 2022 05:58:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235349AbiB1K6e (ORCPT ); Mon, 28 Feb 2022 05:58:34 -0500 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AFF2723C2; Mon, 28 Feb 2022 02:55:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646045707; x=1677581707; h=to:cc:references:from:subject:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=nTPJQ5QTBlr7AzpXXeV/4UbsOZe72fsxzA/yIzwnKdM=; b=nICViPDrsuq4Rm7zfrJMyGGPj3l8Xbj9ZUQyQVEbwZrD2g05afmMub0F 5+7iIpTrLPmIADfvWXYqJ5UH2MJWjr0YneURPTHeaMElHuDIj+bJ/HhRt 2ziWkQfmMNhovaDSASeL76rZMvzeVXFjObftgnZivAng0/UU2MmmMeVQY TXayxsp34t46Rpuvaw1NKZEXRVKxTheeow/PAnQIcK6WHkKYi7rC456yi ySZQqzQAEijtBLcTqy0UEsYK2MJJ+z7xVf/NX7UKGRHa+XuO1zErUz+k+ Z1HAFc0CaHlW31dlgIM5QQ/0G6KUDdlA2LNi8Y38+3pI77vhthi85avpM A==; X-IronPort-AV: E=McAfee;i="6200,9189,10271"; a="316072124" X-IronPort-AV: E=Sophos;i="5.90,142,1643702400"; d="scan'208";a="316072124" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2022 02:54:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,142,1643702400"; d="scan'208";a="575278658" Received: from mattu-haswell.fi.intel.com (HELO [10.237.72.199]) ([10.237.72.199]) by orsmga001.jf.intel.com with ESMTP; 28 Feb 2022 02:54:57 -0800 To: Henry Lin , gregkh@linuxfoundation.org Cc: Mathias Nyman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org References: <20220225055311.92447-1-henryl@nvidia.com> <20220225071506.22012-1-henryl@nvidia.com> From: Mathias Nyman Subject: Re: [PATCH v2] xhci: fix runtime PM imbalance in USB2 resume Message-ID: <2ef7da52-d8ad-05ca-bcb6-06bd6bb6f9d3@linux.intel.com> Date: Mon, 28 Feb 2022 12:56:39 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <20220225071506.22012-1-henryl@nvidia.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 25.2.2022 9.15, Henry Lin wrote: > USB2 resume starts with usb_hcd_start_port_resume() in port status > change handling for RESUME link state. usb_hcd_end_port_resume() call is > needed to keep runtime PM balance. For normal usb2 port resume the usb_hcd_end_port_resume() is called when resume has been signaled for long enough in xhci_handle_usb2_port_link_resume(). This is also where driver directs the port to go from Resume state to U0. Port can't do this without driver directing it. If there's a failure during resume signaling (disconnect, reset, error) then stale resume variables are detected in xhci_get_port_status() and usb_hcd_end_port_resume() is called. I do now see a231ec41e6f6 ("xhci: refactor U0 link state handling in get_port_status") does change order of checking and clearing stale resume variables, but this should only happen if the first port state we read is a fully enabled functional U0 state after a failed resume. Could you expand a bit how this was detected? > > Fixes: a231ec41e6f6 ("xhci: refactor U0 link state handling in get_port_status") > Signed-off-by: Henry Lin > --- > drivers/usb/host/xhci-hub.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c > index df3522dab31b..4a8b07b8ee01 100644 > --- a/drivers/usb/host/xhci-hub.c > +++ b/drivers/usb/host/xhci-hub.c > @@ -1090,6 +1090,8 @@ static void xhci_get_usb2_port_status(struct xhci_port *port, u32 *status, > if (link_state == XDEV_U0) { > bus_state->resume_done[portnum] = 0; > clear_bit(portnum, &bus_state->resuming_ports); > + usb_hcd_end_port_resume(&port->rhub->hcd->self, > + portnum); This will call usb_hcd_end_port_resume() every time port is in normal enabled U0 state even if resume was never signaled, or port suspended. -Mathias