From patchwork Fri Apr 22 02:33:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thinh Nguyen X-Patchwork-Id: 568077 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 7F486C433F5 for ; Fri, 22 Apr 2022 02:34:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443389AbiDVCgv (ORCPT ); Thu, 21 Apr 2022 22:36:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386192AbiDVCgt (ORCPT ); Thu, 21 Apr 2022 22:36:49 -0400 Received: from smtprelay-out1.synopsys.com (smtprelay-out1.synopsys.com [149.117.87.133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E88E4B412; Thu, 21 Apr 2022 19:33:58 -0700 (PDT) Received: from mailhost.synopsys.com (sv2-mailhost2.synopsys.com [10.205.2.134]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client CN "mailhost.synopsys.com", Issuer "SNPSica2" (verified OK)) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id 2D5F1C48D2; Fri, 22 Apr 2022 02:33:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1650594838; bh=n9FpOGd9YMXIa1WVENSgR2Gi361LNjTGArYt+37NDvI=; h=Date:From:Subject:To:Cc:From; b=IpEjvZ/+iQj1ZnrwrpeRwubstUe1V9/V/BOnA5u31dLPLtwDRbHzQ5Y4g0m7ML5S/ PYnqTwGDql/7lGanRqXVnWsPVczw7C+ULTWD+TxyG/OkJj4AiQHUXTAVeKBOUgs1Uu o+N6CZaseg+r9YIoy3a//MmVVzSI6jbEDmD459ROg6KHFCjfHrXlIjjc3TSCu/deLS B2+HJOrSy45B++o4wK3m/RHbnVwPMW+PjS5LBe/SdSra5Edkx/a/Af/AjykOqrO/Q1 vFFbQYdqd4VtrpZDXvFssv3254S9BK9JAOfuEWIBccg56vBbFnMWN8HorGf6EsRfqH US/YdqT30y2Wg== Received: from te-lab16-v2 (nanobot.internal.synopsys.com [10.204.48.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mailhost.synopsys.com (Postfix) with ESMTPSA id CB608A0096; Fri, 22 Apr 2022 02:33:56 +0000 (UTC) Received: by te-lab16-v2 (sSMTP sendmail emulation); Thu, 21 Apr 2022 19:33:56 -0700 Date: Thu, 21 Apr 2022 19:33:56 -0700 Message-Id: <6aecbd78328f102003d40ccf18ceeebd411d3703.1650594792.git.Thinh.Nguyen@synopsys.com> X-SNPS-Relay: synopsys.com From: Thinh Nguyen Subject: [PATCH] usb: dwc3: core: Only handle soft-reset in DCTL To: Felipe Balbi , Greg Kroah-Hartman , linux-usb@vger.kernel.org Cc: John Youn , Thinh Nguyen , Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 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. Fixes: f59dcab17629 ("usb: dwc3: core: improve reset sequence") Cc: Signed-off-by: Thinh Nguyen --- drivers/usb/dwc3/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) base-commit: bf95c4d4630c7a2c16e7b424fdea5177d9ce0864 diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 1ca9dae57855..d28cd1a6709b 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -274,7 +274,8 @@ 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); /* * For DWC_usb31 controller 1.90a and later, the DCTL.CSFRST bit