Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp1070439lqt; Fri, 7 Jun 2024 07:17:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXFK5e7en9Ua6kfwKQ5/NLwDOUVqo7n7rvtnI/TIzl7cJieiPXGJqUrwTWGWLbPw5s5CTSDc0vS14doFXhYfrXXzQtZz65sTL+n7iLuiA== X-Google-Smtp-Source: AGHT+IG58ijmln2BbVbmc1g2rNidUuzfIrECAH9VWBb19B7aHywz8gZhDH41VWM8XpOzQgIKgvGy X-Received: by 2002:a17:906:25d4:b0:a69:20df:bb9f with SMTP id a640c23a62f3a-a6cd7a89d4bmr192261066b.44.1717769879545; Fri, 07 Jun 2024 07:17:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717769879; cv=pass; d=google.com; s=arc-20160816; b=YgFNzwKZuMKvMBd3nFFK865wQg7citccG+vJDoSJhdvR89ptBafB6Q2R3eKBqPQaaa YMo7wBCngJmX9X0xMNkEVI/zY0J8VFimGc7RCfr46HZo4SJSwacZi5A4s/YNMDA998Uh AF22jruD+BeUf3jAEHxCzt3eHTD51CLueUriWMJUudjqnqYtRlaltrjVzKAXAE9LGOpd sj2IogqM21D9R+rzQMgMdOBxUO4q79r8piK4S9T8AvHDQ8tZ/gHIvq8Q6aecNFbrEq4Y DM51ICr2xOb/qgJ7nXtIGq8C6hcv8DoXTOxhPN9ceuNkQmDYjtGoFzvuyNx1O47/9PXq gGfQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=5Me2iTbiGcSnepzGFoeP1Kv/Pyr0OL6SqP6KwSmLQKI=; fh=2a+YY6l3JIHL1MoBbT2JfEguKxU6ODxil6cCEpizujk=; b=gF/5ytC4L80I8m1349bDQuZC8MiY2g+YAGQxxcivAh+xTGFTaCjMH64cqKgCrGs6vo WPi6ImYS+A/S//GcHaJmVJVMDfQvxCfDFHWngxqccZcdxbUn6yK9ip3QzooOFOGqyoMZ 4lWxWKRFJPT+SwE7s4X+Fkq471232pFp1Nuz/xxv9lG/Zs7sXqMN+nWQn7fO0ZXv1v6u spCYcRGWloCgEWiW9lQYIDi/GuJFS1DrTI7Qks6lzUIZoAJd7ojCmG7lcGdpMgsnVNT1 tOXt77qmLCsOutQ+dmfUMDj5/BvIk0iBvrpil8BmQgGcmatzMrKBpnTP1Bnw6GrNB9gv KB0Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=M5smkiGD; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-206217-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206217-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a6ef707e548si13737166b.653.2024.06.07.07.17.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 07:17:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-206217-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=M5smkiGD; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-206217-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206217-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 3FFFD1F28312 for ; Fri, 7 Jun 2024 14:07:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A41D719645E; Fri, 7 Jun 2024 14:07:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="M5smkiGD" Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F3CA1DFEB; Fri, 7 Jun 2024 14:07:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717769259; cv=none; b=hNlriQUCbI2NcL5PG++woebQozCBRHei2IaC2+JCK/FKyhJ5e2p2YxUZiVaAplFVkZLtz1mvCNw+SbnMtXUGKugZNEq27zNYQJ4a6aoeGHq/0pPB2IYGhrJAqPTiv0Z4bq4Y4PrHBhkYyGZxzRwRdihc9loN8xME9JFF6fNgBpk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717769259; c=relaxed/simple; bh=RTmoEXDN61rc/9JZjVN0F0j/56FrXKcrmh9lendfC9U=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=hYDrgzIwBqfl4U4p5mpBU6aNDngB8Qt4d5OoZ/D2E4lmC8sQinfSI7ZuSGNi+f1Bo/q3kpu0q6jJ1+BcWGIUSFZ+Uxv8Eki7xDQNwEv0+vMo1I0+HRaFJiRTNFcVZ4Z/8bkP1oRMMgD08tUkiOMvdWVMJiybC7OD8vopfLHrSvQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=M5smkiGD; arc=none smtp.client-ip=209.85.208.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-5751bcb3139so2427408a12.1; Fri, 07 Jun 2024 07:07:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717769256; x=1718374056; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=5Me2iTbiGcSnepzGFoeP1Kv/Pyr0OL6SqP6KwSmLQKI=; b=M5smkiGDHos/F9o5hg880v2JXv7Fx91e/exONN3KcXcjYJbQC5MZZMFzJR305ehofS 6mvfSlqbr7nSuE9AcuQPeXsJIY3h8UyxfEzW9I8Gi3UqyaE94ppYtLt6v5Xa7/BxkHw5 94HNTvzVhRsS/JzS66g3FFxCTIR4w9xx7i4QY5kP07KPwcOfCT2kvuPgtkPUWx8fVp2Z BQ2aEhuMSE2Qqqw/4jfYVTZF4SUCPZSEDkp+wtldaqeEoBuuK0mB0GSzGmdPTEIxE4r9 4NJaC/tvfiipLOSgEQWDRHx9TAHAMbQcrevDH1jsWWxJl1h6Lz9yWr6hj1K+XFBZ9Bkk xvwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717769256; x=1718374056; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5Me2iTbiGcSnepzGFoeP1Kv/Pyr0OL6SqP6KwSmLQKI=; b=w3C6T7LxWzsax24j2gUZz2ObVRnvl3PCD1t8/takyTCiBFlrcRcZxc1Zm+Yn/CrBcu vAo0GZ1UrXNdc1VCF1RAXnhAlaM185OVb3L3elwzfLRWapscJhZgVmWzVrhMMWKtgSX6 gPYUisnt89AqViLkIuzoJ2hLnOCMWJJEJ16OgUy4G+uhngeF8iR0JpsOTGCf26chFu+D EAtkCYGLBiNYKtNuvHVHDy6DKMRcf1yoe4ZRCQVjDx5qiNzWPDGiL5guP9PT58z52tkq NxDN2mTfmYYqbYTfT8Ox7x2tzQJK8IkaVwss+wyIIQFXkKB7XXGzGV3mMtNoP6cSdot4 bmtw== X-Forwarded-Encrypted: i=1; AJvYcCWlu/gvSA/atsfv3ZMS9a6Lvo2ll5Opm0HHQEOlNn07u4EDWgOKsvhwSaUpnFFrlqJyINZRQaHt+eeKSKTMWHrlpyoCnPjZywB+r+IBBs3A1kmiWWoERabFew9FOqFuGj6uqLeu6Mb8fFQe9sW9rVv2vW5gAyG8ArqAgey/x+yUcS0eMQ== X-Gm-Message-State: AOJu0Yz0t3+ohKAuUAiHkCRsZIcNB+r1v2kEEmk9hjx1Bh8vHg0DsUgy EPVpfBZWtDpYBjgqU4snHbIos4Z92Q9GV4zyR4P3EHD5gehQ7fUtPNeqqQhxIbDGmLgI07gyYFt VJps3cH4mKsPpGt5TeORTs8W6nP0= X-Received: by 2002:a50:9e06:0:b0:57a:2a46:701 with SMTP id 4fb4d7f45d1cf-57c50902d83mr1546865a12.19.1717769256110; Fri, 07 Jun 2024 07:07:36 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240601092646.52139-1-joswang1221@gmail.com> <20240603130219.25825-1-joswang1221@gmail.com> <20240604000715.3rlmzxriof6wwksm@synopsys.com> <20240606012936.jdokepv73qrdorbp@synopsys.com> In-Reply-To: <20240606012936.jdokepv73qrdorbp@synopsys.com> From: joswang Date: Fri, 7 Jun 2024 22:07:26 +0800 Message-ID: Subject: Re: [PATCH v2, 3/3] usb: dwc3: core: Workaround for CSR read timeout To: Thinh Nguyen Cc: "robh@kernel.org" , "krzk+dt@kernel.org" , "conor+dt@kernel.org" , "gregkh@linuxfoundation.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "balbi@kernel.org" , "devicetree@vger.kernel.org" , joswang Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Jun 6, 2024 at 9:29=E2=80=AFAM Thinh Nguyen wrote: > > On Tue, Jun 04, 2024, joswang wrote: > > On Tue, Jun 4, 2024 at 8:07=E2=80=AFAM Thinh Nguyen wrote: > > > > > > On Mon, Jun 03, 2024, joswang wrote: > > > > From: joswang > > > > > > > > DWC31 version 2.00a have an issue that would cause > > > > a CSR read timeout When CSR read coincides with RAM > > > > Clock Gating Entry. > > > > > > Do you have the STAR issue number? > > > > > Thanks for reviewing the code. > > The STAR number provided by Synopsys is 4846132. > > Please help review further. > > I've confirmed internally. As you have noted, this applies to DWC_usb31 > v2.00a for host mode only and DRD mode operating as host. > > > > > > > > > > > This workaround solution disable Clock Gating, sacrificing > > > > power consumption for normal operation. > > > > > > > > Signed-off-by: joswang > > > > --- > > > > drivers/usb/dwc3/core.c | 23 +++++++++++++++++++++++ > > > > 1 file changed, 23 insertions(+) > > > > > > > > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c > > > > index 3a8fbc2d6b99..1df85c505c9e 100644 > > > > --- a/drivers/usb/dwc3/core.c > > > > +++ b/drivers/usb/dwc3/core.c > > > > @@ -978,11 +978,22 @@ static void dwc3_core_setup_global_control(st= ruct dwc3 *dwc) > > > > * > > > > * STAR#9000588375: Clock Gating, SOF Issues when ref= _clk-Based > > > > * SOF/ITP Mode Used > > Since there's another STAR, let's split the if-else case separately and > provide the comments separately. > OK > > > > + * > > > > + * WORKAROUND: DWC31 version 2.00a have an issue that= would > > Can we use the full name DWC_usb31 instead of DWC31. > Subsequent V3 versions use DWC_usb31 > > > > + * cause a CSR read timeout When CSR read coincides w= ith RAM > > > > + * Clock Gating Entry. > > > > + * > > > > + * This workaround solution disable Clock Gating, sac= rificing > > > > + * power consumption for normal operation. > > > > */ > > > > if ((dwc->dr_mode =3D=3D USB_DR_MODE_HOST || > > > > dwc->dr_mode =3D=3D USB_DR_MODE_OTG) = && > > > > DWC3_VER_IS_WITHIN(DWC3, 210A, 250A)) > > > > reg |=3D DWC3_GCTL_DSBLCLKGTNG | DWC3_GCTL_SO= FITPSYNC; > > > > + else if ((dwc->dr_mode =3D=3D USB_DR_MODE_HOST || > > > > + dwc->dr_mode =3D=3D USB_DR_MODE_OTG) = && > > There's no OTG mode for DWC_usb31. Let's enable this workaround if the > HW mode is not DWC_GHWPARAMS0_MODE_GADGET. > > > > > + DWC3_VER_IS(DWC31, 200A)) > > > > + reg |=3D DWC3_GCTL_DSBLCLKGTNG; > > > > else > > > > reg &=3D ~DWC3_GCTL_DSBLCLKGTNG; > > > > break; > > > > @@ -992,6 +1003,18 @@ static void dwc3_core_setup_global_control(st= ruct dwc3 *dwc) > > > > * will work. Device-mode hibernation is not yet impl= emented. > > > > */ > > > > reg |=3D DWC3_GCTL_GBLHIBERNATIONEN; > > > > + > > > > + /* > > > > + * WORKAROUND: DWC31 version 2.00a have an issue that= would > > > > + * cause a CSR read timeout When CSR read coincides w= ith RAM > > > > + * Clock Gating Entry. > > > > + * > > > > + * This workaround solution disable Clock Gating, sac= rificing > > > > + * power consumption for normal operation. > > > > + */ > > > > + if ((dwc->dr_mode =3D=3D USB_DR_MODE_HOST || > > > > + dwc->dr_mode =3D=3D USB_DR_MODE_OTG) && DWC3_VER= _IS(DWC31, 200A)) > > > > + reg |=3D DWC3_GCTL_DSBLCLKGTNG; > > > > break; > > > > default: > > > > /* nothing */ > > > > -- > > > > 2.17.1 > > > > > > > > > We have the same checks and comments here. Can we refactor? > Perhaps something this? > > power_opt =3D DWC3_GHWPARAMS1_EN_PWROPT(dwc->hwparams.hwparams1); > switch (power_opt) { > ... > } > > /* > * > */ > if (power_opt !=3D DWC3_GHWPARAMS1_EN_PWROPT_NO) { > } > > > Thanks, > Thinh Thank you for your valuable suggestions.I can refactor according to your suggestion. Do I need to submit a V3 version patch separately, or should I submit a V3 version patch together with other cases? Thanks, Jos Wang