From nobody Thu Dec 18 04:13:58 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 B9B93C6FA86 for ; Mon, 26 Sep 2022 10:55:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234197AbiIZKzQ (ORCPT ); Mon, 26 Sep 2022 06:55:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236817AbiIZKwu (ORCPT ); Mon, 26 Sep 2022 06:52:50 -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 B482659242; Mon, 26 Sep 2022 03:27:43 -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 7DF3A60A5C; Mon, 26 Sep 2022 10:27:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73F21C433C1; Mon, 26 Sep 2022 10:27:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664188056; bh=bAejmkdqoHosDc3YHaPfWNc3qHziVr3PAY1JEvQNEss=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WJ0ng9vwtLaunzOpog/+tjUHc9TXUwdSgj1CWE6ANJ1mL0GwN8Ys3sVmpwQY1leNg rp4G9FVN85jFuKCIZ0ZrmJgpXjGNHghPixFR0WOUvC3O3hC/UotW7li8IUB9XXwFZS G6wTKPb0qbl41Jk6EutXLltePCO5yt1Vw3zUbu8c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thinh Nguyen , Sasha Levin Subject: [PATCH 5.10 009/141] usb: dwc3: gadget: Prevent repeat pullup() Date: Mon, 26 Sep 2022 12:10:35 +0200 Message-Id: <20220926100754.949381755@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: Thinh Nguyen [ Upstream commit 69e131d1ac4e52a59ec181ab4f8aa8c48cd8fb64 ] Don't do soft-disconnect if it's previously done. Likewise, don't do soft-connect if the device is currently connected and running. It would break normal operation. Currently the caller of pullup() (udc's sysfs soft_connect) only checks if it had initiated disconnect to prevent repeating soft-disconnect. It doesn't check for soft-connect. To be safe, let's keep the check here regardless whether the udc core is fixed. Signed-off-by: Thinh Nguyen Link: https://lore.kernel.org/r/1c1345bd66c97a9d32f77d63aaadd04b7b037143.16= 50593829.git.Thinh.Nguyen@synopsys.com Signed-off-by: Greg Kroah-Hartman Stable-dep-of: 040f2dbd2010 ("usb: dwc3: gadget: Avoid duplicate requests t= o enable Run/Stop") Signed-off-by: Sasha Levin --- drivers/usb/dwc3/gadget.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index e7ede868ffb3..3820dff0387a 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2127,6 +2127,10 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, = int is_on) int ret; =20 is_on =3D !!is_on; + + 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 --=20 2.35.1