From nobody Fri Dec 19 17:36:21 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 237C7C07E9D for ; Mon, 26 Sep 2022 11:13:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235133AbiIZLN1 (ORCPT ); Mon, 26 Sep 2022 07:13:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237591AbiIZLMS (ORCPT ); Mon, 26 Sep 2022 07:12:18 -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 C7D9A606B3; Mon, 26 Sep 2022 03:35:42 -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 34C3E60A55; Mon, 26 Sep 2022 10:34:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44D3EC433D6; Mon, 26 Sep 2022 10:34:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664188444; bh=i2VbnV8TJquhT5lBOblusidEuH6MomI3WvJqLd6uHBo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UcHFIuWqjic2VrFNB4in5lyaFjo6HxfG/Syarbu6bdWr1BvVFafo8GhDN+gPvEyE7 mJnT1ixbSOoQwYQuzTzFCifuOmh/Ta1rxYsMguojrd8BYRmPryp1EJgRx+2mCvjX9O gRR0sXAmGfv9zYwRup0nbRq69hgduG1KLDFRaMVM= 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.15 010/148] usb: dwc3: gadget: Avoid duplicate requests to enable Run/Stop Date: Mon, 26 Sep 2022 12:10:44 +0200 Message-Id: <20220926100756.425721224@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220926100756.074519146@linuxfoundation.org> References: <20220926100756.074519146@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 484b5e1d921a..14dcdb923f40 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2470,9 +2470,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 @@ -2509,6 +2506,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