From mboxrd@z Thu Jan 1 00:00:00 1970 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 32303ECAAA1 for ; Tue, 6 Sep 2022 14:14:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241481AbiIFOOm (ORCPT ); Tue, 6 Sep 2022 10:14:42 -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 Precedence: bulk List-ID: X-Mailing-List: stable@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);