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 AF639C4708A for ; Mon, 28 Nov 2022 17:46:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233609AbiK1Rqf (ORCPT ); Mon, 28 Nov 2022 12:46:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233521AbiK1RqC (ORCPT ); Mon, 28 Nov 2022 12:46:02 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D72D329CA6; Mon, 28 Nov 2022 09:41:23 -0800 (PST) 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 CF3CD612D0; Mon, 28 Nov 2022 17:41:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91001C433D7; Mon, 28 Nov 2022 17:41:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669657275; bh=GJg4/tsAGxLnr92fLZ6xKvgfaQDcFOkE2aCM0kv6URY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dS3QZpYtu7OPhubOhnden8UF+kopgERz9tvAIyWnxgJ+mJgs9yq8IvzrSaPPI3luC EAuJ/SfvCH/s0DGq6XxZuFL4Kr52VGr2FXcjpw+P9RzvUW4bHYmxYDpfSjaBq6zcFB yIINPzYJ2m+uzVS4ctDNVqJZefSbruH/TtzfdsiokbS3ubqz5CL9HzLf57mhDoghkD Y2D6kIsFnjU6SZEv4LbGsBdqtGdNM0huvAfUNTLaT39RKGjO3Y2ODtiI8jQwPIkgVP Q8LaflUqVpsadMib5id8osAnwYoLH09aeT5QLFYd+A4YVqUhCPe9cCGA8LGEcisDvi l8ZGynKuRdPXA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Thinh Nguyen , Greg Kroah-Hartman , Sasha Levin , balbi@kernel.org, linux-usb@vger.kernel.org Subject: [PATCH AUTOSEL 5.15 22/24] usb: dwc3: gadget: Disable GUSB2PHYCFG.SUSPHY for End Transfer Date: Mon, 28 Nov 2022 12:40:22 -0500 Message-Id: <20221128174027.1441921-22-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221128174027.1441921-1-sashal@kernel.org> References: <20221128174027.1441921-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thinh Nguyen [ Upstream commit 3aa07f72894d209fcf922ad686cbb28cf005aaad ] If there's a disconnection while operating in eSS, there may be a delay in VBUS drop response from the connector. In that case, the internal link state may drop to operate in usb2 speed while the controller thinks the VBUS is still high. The driver must make sure to disable GUSB2PHYCFG.SUSPHY when sending endpoint command while in usb2 speed. The End Transfer command may be called, and only that command needs to go through at this point. Let's keep it simple and unconditionally disable GUSB2PHYCFG.SUSPHY whenever we issue the command. This scenario is not seen in real hardware. In a rare case, our prototype type-c controller/interface may have a slow response triggerring this issue. Signed-off-by: Thinh Nguyen Link: https://lore.kernel.org/r/5651117207803c26e2f22ddf4e5ce9e865dcf7c7.1668045468.git.Thinh.Nguyen@synopsys.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/dwc3/gadget.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index c38418b4df90..a2693a983936 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -291,7 +291,8 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned int cmd, * * DWC_usb3 3.30a and DWC_usb31 1.90a programming guide section 3.2.2 */ - if (dwc->gadget->speed <= USB_SPEED_HIGH) { + if (dwc->gadget->speed <= USB_SPEED_HIGH || + DWC3_DEPCMD_CMD(cmd) == DWC3_DEPCMD_ENDTRANSFER) { reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)); if (unlikely(reg & DWC3_GUSB2PHYCFG_SUSPHY)) { saved_config |= DWC3_GUSB2PHYCFG_SUSPHY; -- 2.35.1