Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp838039pxb; Wed, 6 Apr 2022 01:22:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTxZcjZLOn53ga8Ktxe9XWyWfWZHCEbWbmTvX7BEz2uNbeEYC+PXPfWFT2R8o97eq6N4yQ X-Received: by 2002:a63:af10:0:b0:398:91:657 with SMTP id w16-20020a63af10000000b0039800910657mr6133039pge.413.1649233353556; Wed, 06 Apr 2022 01:22:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649233353; cv=none; d=google.com; s=arc-20160816; b=hxmqB2kt5sFF52ewChkeFjPzzBIBJn2awukU7PjS3IVLPfK3VAh7baVK0VbE+SzZV4 JLmPwwKJir1Om/JybSuNU5d3bA9b1UibGWYJoMoWREyBklpjWJF7yKKDB6WQxQEGmfJ3 SXYzlemG3+S5E4GiOyBHygJkt6GmsTEr+vVacpq9V6XvzEKEMAEVZT8IfSpkTK6smHf7 oFOZ96XBmFVbeJoq8yOJ4BgFJTJ10khtwDs83A8ql88AJaJPg4+7OCmW4LKiEnRwJloA 4Z/5DOmWhbl68qg5fB7im1BOdCMWnGQMQKEBIV+AsbY4a4rheT8hFb2zUMh0kMFYQFxK JeZA== 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=epObob/smthReuOmdl3UZl37AyYgBLP7a9DPMjzQ2CQ=; b=kC/XkNaNZVf4NJGVDqiP9VpBe1jtah2bh+zVTOM7SIQhz+LKlNUQrkcKtkrt3FDDp0 tc3puXmyl+j/HeLmc41XlHR5U8pQDj0l3gRaqNEaDLp8sBFyE7PNAiBQfOHC/YsYuExX YDmM8lhvmXbRwNcRDoiQKBP92ks+U8DLV0hOybbhw7MnGyK+p7lJUbIY9ND/B7HANCEH 8znTzQwrJjnc6tBA9GH5M5eUzkUFoZldAHsyTakq8+9cLOoSlK8+iB8KF/FY3RpVTv/g 6lHWKwRGMTT7zulDrSH0wWfCEZP3X/JtqRE9AnCd99MxTeUP2ZpYL2XH1WdoggBd/Z2T j2jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=05+Ya9PE; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id n126-20020a634084000000b0039aa750fe39si2041753pga.593.2022.04.06.01.22.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 01:22:33 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=05+Ya9PE; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 4DD20B6453; Wed, 6 Apr 2022 01:12:02 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347984AbiDEVXM (ORCPT + 99 others); Tue, 5 Apr 2022 17:23:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354624AbiDEKO4 (ORCPT ); Tue, 5 Apr 2022 06:14:56 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F78F6BDC9; Tue, 5 Apr 2022 03:01:36 -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 ams.source.kernel.org (Postfix) with ESMTPS id 50DF8B818F6; Tue, 5 Apr 2022 10:01:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BECE0C385A2; Tue, 5 Apr 2022 10:01:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649152894; bh=qtRo7NqPmOBJhZkP7N4XIeizdiNyvQ6+jtWSqnD7YvA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=05+Ya9PEDOYK8tpssy8uf8JkalUEe3pPI3L62kctjQ0du70JKwlcnsJJ8I+cmvIVg qxVyk/8a7zRcJY6LWwX5oXZdmPt5gNt5D2Il9T7oxz5k24aQslEN8nfX9yBq08mFbt nixfBnn2mKdNFAYsl3t7SHkmNL9QgnQf9zXfTGP0= 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.10 027/599] xhci: fix runtime PM imbalance in USB2 resume Date: Tue, 5 Apr 2022 09:25:21 +0200 Message-Id: <20220405070259.627300358@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070258.802373272@linuxfoundation.org> References: <20220405070258.802373272@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 @@ -1002,6 +1002,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)) {