From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E25A1DA23; Thu, 3 Jul 2025 15:18:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751555932; cv=none; b=Kpf/mgSdZFbGWfWtatwrik5RIqW3SSunb3RPYXoCy6EPbPKKlAjoN4p5z7U03kuWlFo83ywIjEXG0AUt5J4+roea4i3ekoZhmK4Viers/RIzS4zMbBNf+42KZgaBvLBRgdAXBVlvHReKyUTqniNcXubc42J3Trr7xd+7TXDeqX4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751555932; c=relaxed/simple; bh=viqDd5Co+1x913oPCqfiSmzbE1zkwmEEcrwK25lDR0Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UNtYTvps3cjOA57KQJ/Qj4YaRtY4uF+qw7FpEw5UNH+6654idlrGluYX+//xWLOj1p9Usf5VQppq+6e9o+YRSg9aWGIimNA/BC0kdp0/ff3DG4pmGFDpRQNHoN9VXLU5GszE6dVdz4P4xzx5oTAsyx6n1fuFhtUEvlEP1z0lqWg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=T4UgI9Cj; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="T4UgI9Cj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1130C4CEED; Thu, 3 Jul 2025 15:18:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1751555932; bh=viqDd5Co+1x913oPCqfiSmzbE1zkwmEEcrwK25lDR0Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T4UgI9CjOEC2c7jJIloANkkRFAKTlKsze9sdwNig1zWnATot9LZahK8UfYqJFH1Wy nJPXwB9cTpzdwS+p3AcC2fkQK155XbzpJcYjlQXETnN8fPTszFwAFJzz5SBsZAawPy 6zq2qLAyL+QNFNhf+LubyBaZR4GqxmEEzf8W6Sqs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Michael Grzeschik , Minas Harutyunyan , Sasha Levin Subject: [PATCH 6.1 022/132] usb: dwc2: also exit clock_gating when stopping udc while suspended Date: Thu, 3 Jul 2025 16:41:51 +0200 Message-ID: <20250703143940.271621373@linuxfoundation.org> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250703143939.370927276@linuxfoundation.org> References: <20250703143939.370927276@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Michael Grzeschik [ Upstream commit af076a41f8a28faf9ceb9dd2d88aef2c202ef39a ] It is possible that the gadget will be disabled, while the udc is suspended. When enabling the udc in that case, the clock gating will not be enabled again. Leaving the phy unclocked. Even when the udc is not enabled, connecting this powered but not clocked phy leads to enumeration errors on the host side. To ensure that the clock gating will be in an valid state, we ensure that the clock gating will be enabled before stopping the udc. Signed-off-by: Michael Grzeschik Acked-by: Minas Harutyunyan Link: https://lore.kernel.org/r/20250417-dwc2_clock_gating-v1-1-8ea7c4d53d73@pengutronix.de Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/dwc2/gadget.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index cea6c4fc79956..d4ca1677ad234 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -4602,6 +4602,12 @@ static int dwc2_hsotg_udc_stop(struct usb_gadget *gadget) if (!hsotg) return -ENODEV; + /* Exit clock gating when driver is stopped. */ + if (hsotg->params.power_down == DWC2_POWER_DOWN_PARAM_NONE && + hsotg->bus_suspended && !hsotg->params.no_clock_gating) { + dwc2_gadget_exit_clock_gating(hsotg, 0); + } + /* all endpoints should be shutdown */ for (ep = 1; ep < hsotg->num_of_eps; ep++) { if (hsotg->eps_in[ep]) -- 2.39.5