Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4471248rwb; Tue, 6 Sep 2022 08:01:42 -0700 (PDT) X-Google-Smtp-Source: AA6agR55Ux5dztDFuhTMUWS8yJUtmV0VWJnVxonRNH08+Ub26ADlBRIL4JYk9UjFhuR9h+ZVdTMI X-Received: by 2002:a17:906:b2d4:b0:731:4594:8ba1 with SMTP id cf20-20020a170906b2d400b0073145948ba1mr39178985ejb.288.1662476502520; Tue, 06 Sep 2022 08:01:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662476502; cv=none; d=google.com; s=arc-20160816; b=JSH/U5w8JJnQcfHfPCol//PTwiDKjBuB36PtmMP1pAD+fXqps1gc3ufM4Q9M9RE6TO 4iyilx44yhDXaoAGnmbRMIq+UAz/MWcV1H30w0Fjnxvtgl4JioIBwWu58tc/Ajvx0pXt VKghnv44UZXPPR0n/JRi75UfXUHqT1e0zhvao8sZkd91XI1V0fNmiuncDGqkmSazK3bX AUv6XtWEAFouHwnYsOihpI8lwkcTJMCByCQ6kzXOtcZQUtxCNwQrokg3joaTSS+QDI3J V7/cjyNTKGWzzitdztvtEoUuDXXqub14Orr4aYGxhpV858iuCNmaniXi+OAJaARRjiyO 42Ig== 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=bV6p7d+YwaU/voPHDrsTaGmznnkTnpD1FEYUKSIY4BY=; b=hAWgdyp+qI1CU5Cd6qsYMQNKIGXRNTdnLX+Mwv8UOHd2GTRS5wS9ogVCXq0yivn30w 2/k2TsjVxhzWk3abLb21auDZkkqxwSQhOkDnkr/O9a1ajyy7wONy2O1iW3gkA1dsUPPL NZYeK2bVr/rwWMECJBLYlCKxf9qDf+z9jD8UHwkqPyJbhbmu+42u8kJPQizJlH/Zvppz y+IlO4DXysSLo8aS4bQt/JAzs+6o48Yj2hBu5smu1/pu0zSO/r1nKKjrIHylToaO9TXO 6ero6ZugLV7aeFEnbgwMGI+LMPM1n9rvcnk/cYmknq6Aa/NM1eixsn6YT6rqKxoGFV30 LgZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pkGA59EU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hd42-20020a17090796aa00b0073d847c65fdsi826238ejc.587.2022.09.06.08.01.14; Tue, 06 Sep 2022 08:01:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pkGA59EU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241269AbiIFOPk (ORCPT + 99 others); Tue, 6 Sep 2022 10:15:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241682AbiIFONw (ORCPT ); Tue, 6 Sep 2022 10:13:52 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D94407694E; Tue, 6 Sep 2022 06:48:29 -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 94AFC614C9; Tue, 6 Sep 2022 13:46:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 953B4C433C1; Tue, 6 Sep 2022 13:46:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662471994; bh=BLKt3sXsnjJfaikD6GS4b3J1vS+NSVoxDchTvMXSrkI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pkGA59EUtXtL17+I/F1sk5Es+/gNXO0xS5xoYAl6lJ8RY3TmG0aWO/j2pmsaKSeo3 /wd+Ur0vZiecP7MLMEMno+YMEPyba5J++RuzgzZnxkI9ibaaobcD2TP5Fa0gzdgAJ+ 4pY6dByeUs7oS5Zj4mYG+g0nWi50LHZyq8+FlgzM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable , Wesley Cheng Subject: [PATCH 5.19 111/155] usb: dwc3: gadget: Avoid duplicate requests to enable Run/Stop Date: Tue, 6 Sep 2022 15:30:59 +0200 Message-Id: <20220906132834.161346397@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220906132829.417117002@linuxfoundation.org> References: <20220906132829.417117002@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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: Wesley Cheng commit 040f2dbd2010c43f33ad27249e6dac48456f4d99 upstream. 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 unbinded") Cc: stable Signed-off-by: Wesley Cheng Link: https://lore.kernel.org/r/20220728020647.9377-1-quic_wcheng@quicinc.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc3/gadget.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2538,9 +2538,6 @@ static int dwc3_gadget_pullup(struct usb is_on = !!is_on; - if (dwc->pullups_connected == is_on) - return 0; - dwc->softconnect = is_on; /* @@ -2564,6 +2561,11 @@ static int dwc3_gadget_pullup(struct usb pm_runtime_put(dwc->dev); return 0; } + + if (dwc->pullups_connected == is_on) { + pm_runtime_put(dwc->dev); + return 0; + } if (!is_on) { ret = dwc3_gadget_soft_disconnect(dwc);