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 phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 42A28EB64D8 for ; Thu, 22 Jun 2023 10:00:57 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EAF9486378; Thu, 22 Jun 2023 11:59:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.b="X3VJM31D"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2ED788591B; Thu, 22 Jun 2023 11:59:36 +0200 (CEST) Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 46F1386139 for ; Thu, 22 Jun 2023 11:59:30 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=eugen.hristev@collabora.com Received: from eugen-station.. (unknown [192.166.149.251]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: ehristev) by madras.collabora.co.uk (Postfix) with ESMTPSA id D1278660700E; Thu, 22 Jun 2023 10:59:25 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1687427969; bh=EEMWFrlTCb5GoyvmpeMAl34zVh2yKFJGOyYURx4YP4w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X3VJM31DGBN2HUKpvH5P8dHAeKUT4ay+m3ZMFXDYCYPqjoGQV567eoFoIm4Lb+zK5 UUILAMcAGXLd7B4ULuXB1a7HhqQ+3vHZkSjlz9Otfen4IFdnTNv1zHHEMwZJ7yy/9x GBeCySsB1p/KchsRo5nZir0CgIllIieBOveBS57l4xx4ih2MLvK5G3eR/O689kuPiR JQLyPLpwdtmt7RiqvCjhUdoQq8KKqgSGh55IIqvWSRAd4us1rwrzL0IyV6mw0o5zzK JkavcGPfySmSBaUnzVIzzOugYVC0yZBiiFZn5UcW9snqQtWoJja12W36GrEA5T9aEF guu/WDu4UthdQ== From: Eugen Hristev To: kever.yang@rock-chips.com Cc: marex@denx.de, jonas@kwiboo.se, jagan@edgeble.ai, venkatesh.abbarapu@amd.com, eugen.hristev@collabora.com, u-boot@lists.denx.de Subject: [PATCH 04/10] usb: dwc3: core: Only handle soft-reset in DCTL Date: Thu, 22 Jun 2023 12:58:43 +0300 Message-Id: <20230622095849.498702-5-eugen.hristev@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230622095849.498702-1-eugen.hristev@collabora.com> References: <20230622095849.498702-1-eugen.hristev@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Venkatesh Yadav Abbarapu [ Nguyen/Greg: Ported from Linux kernel commit f4fd84ae0765a ("usb: dwc3: core: Only handle soft-reset in DCTL") ] Make sure not to set run_stop bit or link state change request while initiating soft-reset. Register read-modify-write operation may unintentionally start the controller before the initialization completes with its previous DCTL value, which can cause initialization failure. Signed-off-by: Venkatesh Yadav Abbarapu --- drivers/usb/dwc3/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index bdfe51c3df96..06ca3fc96842 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -72,7 +72,8 @@ static int dwc3_core_soft_reset(struct dwc3 *dwc) reg = dwc3_readl(dwc->regs, DWC3_DCTL); reg |= DWC3_DCTL_CSFTRST; - dwc3_writel(dwc->regs, DWC3_DCTL, reg); + reg &= ~DWC3_DCTL_RUN_STOP; + dwc3_gadget_dctl_write_safe(dwc, reg); /* Assert USB3 PHY reset */ reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0)); -- 2.34.1