Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp746036pxb; Tue, 5 Apr 2022 21:29:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzL2yHC2o+yZuO3NQpjuYRbB/sQQPHtXOt68sCJx4zOIJmTsHknvj+9kkBH+M4gbl3YLMst X-Received: by 2002:a17:902:7682:b0:156:ca91:877e with SMTP id m2-20020a170902768200b00156ca91877emr6751915pll.163.1649219394653; Tue, 05 Apr 2022 21:29:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649219394; cv=none; d=google.com; s=arc-20160816; b=rnrIRlTpWuSk905HdUItH8B7zaBz9megSsXubqFd6lFG2voDpsdfZ4A2mtHd0l+htu g1avIKYvkeSTEaR2EZCmCvTiXAWdXYJAPRxzbyqg9X3pIxsmmujASYOsXrUrRZVtsxer sRAse7XziobYy8HzhQDnrmYPHT8uLJkgru+GBVrIvrqRqUp8U45tOVjepUO+P+jNMP9x s7aHnvSLduMgT7t+JytImzDC0+mtysphyNt6SRxtSCda+Xi2v2ePI1GJB8ZSZ1eSy3JD h5RW28LUKpPm4srRZm0SlXFh+CgxXJeEHkx7MbRUER2NEBH8fzjWMbkhb9zoDF7xvbHk EPqQ== 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=brcJudrnRhkUbz1tpTleGiNQ6HBx5mh4+JHW5C9LoBE=; b=gv70BMLMBVyx1JyZyvzhfpCsJDXpSEbwtyXP3/sbSjlf0u08pa2wD25hL15NYcLN45 Jnz/yxLOud9nkcSN+lLRJbvs2wFhLq8SZtltO6XQqLjAr+6U0Pwr9KrG7US4jhrrRyoS 7JhFYDPk6i4BXe/FrId2DaCTlwUboBNqAwxQyoVr6lelc5BPe9wF0rdiGAJaAm2ef0eG H96XiSkGUmqg6iNK35R6vhdhKrdIIKB/O8bVhQrbtMyjh4iOvjfbocpHlS91rSGq8i2v +LSu6OCQJ1lWIrz7oMTUC4AnFL5loWQQYgzXCya9GhhJQ13/G+uM4tBuoEYBpBCM2rL8 MhVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pw0G5ZSx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id ls5-20020a17090b350500b001bf9e1d1e3fsi4391586pjb.138.2022.04.05.21.29.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 21:29:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pw0G5ZSx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D54BA180204; Tue, 5 Apr 2022 19:52:38 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231862AbiDEHpv (ORCPT + 99 others); Tue, 5 Apr 2022 03:45:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232077AbiDEHoZ (ORCPT ); Tue, 5 Apr 2022 03:44:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25AE9972B8; Tue, 5 Apr 2022 00:41:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 889C66150D; Tue, 5 Apr 2022 07:41:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9669AC340EE; Tue, 5 Apr 2022 07:41:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649144462; bh=tv6arKi6rzEnPZRRIbINOvlsb8nTYzIr7Tyyr02e010=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pw0G5ZSx1k8gxj2BovGt/je5NLZE1KlcNSysJeZl59cGCAHgbiLhtUwyWK47zeDQQ LhkBADeBUWuoVE9p4BiTjGK/gPfXiW2vxLrEBx6gGvkcheWdH7MDdup/elsyNhyLB8 df8gyfV3fTPCwE6GG3Mbz626Tt6bG53OMnpYmKTA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Henry Lin , Mathias Nyman Subject: [PATCH 5.17 0016/1126] xhci: fix runtime PM imbalance in USB2 resume Date: Tue, 5 Apr 2022 09:12:43 +0200 Message-Id: <20220405070408.018352716@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070407.513532867@linuxfoundation.org> References: <20220405070407.513532867@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 From: Henry Lin commit 70c05e4cf63054cd755ca66c1819327b22cb085f upstream. A race between system resume and device-initiated resume may result in runtime PM imbalance on USB2 root hub. If a device-initiated resume starts and system resume xhci_bus_resume() directs U0 before hub driver sees the resuming device in RESUME state, device-initiated resume will not be finished in xhci_handle_usb2_port_link_resume(). In this case, usb_hcd_end_port_resume() call is missing. This changes calls usb_hcd_end_port_resume() if resuming device reaches U0 to keep runtime PM balance. Fixes: a231ec41e6f6 ("xhci: refactor U0 link state handling in get_port_status") Cc: stable@vger.kernel.org Signed-off-by: Henry Lin Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20220303110903.1662404-5-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-hub.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c @@ -1088,6 +1088,9 @@ static void xhci_get_usb2_port_status(st if (link_state == XDEV_U2) *status |= USB_PORT_STAT_L1; if (link_state == XDEV_U0) { + if (bus_state->resume_done[portnum]) + usb_hcd_end_port_resume(&port->rhub->hcd->self, + portnum); bus_state->resume_done[portnum] = 0; clear_bit(portnum, &bus_state->resuming_ports); if (bus_state->suspended_ports & (1 << portnum)) {