From nobody Tue Dec 16 08:52:25 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13052C07E9D for ; Mon, 26 Sep 2022 10:52:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236734AbiIZKwC (ORCPT ); Mon, 26 Sep 2022 06:52:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236844AbiIZKtg (ORCPT ); Mon, 26 Sep 2022 06:49:36 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFC9F5809F; Mon, 26 Sep 2022 03:26:51 -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 8740E60AD6; Mon, 26 Sep 2022 10:26:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79702C433C1; Mon, 26 Sep 2022 10:26:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664188011; bh=MzkHCLYvjKv1iQXlxQ3Q59mwqhfyiQVWWuSzgPLRTKk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X6loO5J9urnczH7W0PnqPqQ4um7jcHt7yDNFyiQZ2ruh2ch0KzGOfRyyuib2r6WV/ T/KyCtoV52xtw53gRGiKo/6hjkN9ywxJA/gtcB6RnIU7pZXGxeaogYeM+PRiB7S/8q HLCtoiI/ysdiCRKHlFESOr7Wd5ul0SS2DE62044M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable , Wesley Cheng , Sasha Levin Subject: [PATCH 5.10 012/141] usb: dwc3: gadget: Avoid duplicate requests to enable Run/Stop Date: Mon, 26 Sep 2022 12:10:38 +0200 Message-Id: <20220926100755.043153929@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220926100754.639112000@linuxfoundation.org> References: <20220926100754.639112000@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Wesley Cheng [ Upstream commit 040f2dbd2010c43f33ad27249e6dac48456f4d99 ] Relocate the pullups_connected check until after it is ensured that there are no runtime PM transitions. If another context triggered the DWC3 core's runtime resume, it may have already enabled the Run/Stop. Do not re-run the entire pullup sequence again, as it may issue a core soft reset while Run/Stop is already set. This patch depends on commit 69e131d1ac4e ("usb: dwc3: gadget: Prevent repeat pullup()") Fixes: 77adb8bdf422 ("usb: dwc3: gadget: Allow runtime suspend if UDC unbin= ded") Cc: stable Signed-off-by: Wesley Cheng Link: https://lore.kernel.org/r/20220728020647.9377-1-quic_wcheng@quicinc.c= om Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/dwc3/gadget.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 818a70e56d89..41ed2f6f8a8d 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2155,9 +2155,6 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, i= nt is_on) =20 is_on =3D !!is_on; =20 - if (dwc->pullups_connected =3D=3D is_on) - return 0; - dwc->softconnect =3D is_on; /* * Per databook, when we want to stop the gadget, if a control transfer @@ -2194,6 +2191,11 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, = int is_on) return 0; } =20 + if (dwc->pullups_connected =3D=3D is_on) { + pm_runtime_put(dwc->dev); + return 0; + } + if (!is_on) { ret =3D dwc3_gadget_soft_disconnect(dwc); } else { --=20 2.35.1