diff mbox series

[v4,3/3] usb: dwc3: core: Workaround for CSR read timeout

Message ID 20240612153922.2531-1-joswang1221@gmail.com (mailing list archive)
State Accepted
Commit fc1d1a712b517bbcb383b1f1f7ef478e7d0579f2
Headers show
Series None | expand

Commit Message

joswang June 12, 2024, 3:39 p.m. UTC
From: Jos Wang <joswang@lenovo.com>

This is a workaround for STAR 4846132, which only affects
DWC_usb31 version2.00a operating in host mode.

There is a problem in DWC_usb31 version 2.00a operating
in host mode that would cause a CSR read timeout When CSR
read coincides with RAM Clock Gating Entry. By disable
Clock Gating, sacrificing power consumption for normal
operation.

Cc: stable@vger.kernel.org
Signed-off-by: Jos Wang <joswang@lenovo.com>
---
v1 -> v2:
- add "dt-bindings: usb: dwc3: Add snps,p2p3tranok quirk" patch,
  this patch does not make any changes
v2 -> v3:
- code refactor
- modify comment, add STAR number, workaround applied in host mode
- modify commit message, add STAR number, workaround applied in host mode
- modify Author Jos Wang
v3 -> v4:
- modify commit message, add Cc: stable@vger.kernel.org
---
 drivers/usb/dwc3/core.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

Comments

Greg Kroah-Hartman June 12, 2024, 5:04 p.m. UTC | #1
On Wed, Jun 12, 2024 at 11:39:22PM +0800, joswang wrote:
> From: Jos Wang <joswang@lenovo.com>
> 
> This is a workaround for STAR 4846132, which only affects
> DWC_usb31 version2.00a operating in host mode.
> 
> There is a problem in DWC_usb31 version 2.00a operating
> in host mode that would cause a CSR read timeout When CSR
> read coincides with RAM Clock Gating Entry. By disable
> Clock Gating, sacrificing power consumption for normal
> operation.
> 
> Cc: stable@vger.kernel.org
> Signed-off-by: Jos Wang <joswang@lenovo.com>
> ---
> v1 -> v2:
> - add "dt-bindings: usb: dwc3: Add snps,p2p3tranok quirk" patch,
>   this patch does not make any changes
> v2 -> v3:
> - code refactor
> - modify comment, add STAR number, workaround applied in host mode
> - modify commit message, add STAR number, workaround applied in host mode
> - modify Author Jos Wang
> v3 -> v4:
> - modify commit message, add Cc: stable@vger.kernel.org

This thread is crazy, look at:
	https://lore.kernel.org/all/20240612153922.2531-1-joswang1221@gmail.com/
for how it looks.  How do I pick out the proper patches to review/apply
there at all?  What would you do if you were in my position except just
delete the whole thing?

Just properly submit new versions of patches (hint, without the ','), as
the documentation file says to, as new threads each time, with all
commits, and all should be fine.

We even have tools that can do this for you semi-automatically, why not
use them?

thanks,

greg k-h
Conor Dooley June 12, 2024, 5:13 p.m. UTC | #2
On Wed, Jun 12, 2024 at 07:04:28PM +0200, Greg KH wrote:
> On Wed, Jun 12, 2024 at 11:39:22PM +0800, joswang wrote:
> > From: Jos Wang <joswang@lenovo.com>
> > 
> > This is a workaround for STAR 4846132, which only affects
> > DWC_usb31 version2.00a operating in host mode.
> > 
> > There is a problem in DWC_usb31 version 2.00a operating
> > in host mode that would cause a CSR read timeout When CSR
> > read coincides with RAM Clock Gating Entry. By disable
> > Clock Gating, sacrificing power consumption for normal
> > operation.
> > 
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Jos Wang <joswang@lenovo.com>
> > ---
> > v1 -> v2:
> > - add "dt-bindings: usb: dwc3: Add snps,p2p3tranok quirk" patch,
> >   this patch does not make any changes
> > v2 -> v3:
> > - code refactor
> > - modify comment, add STAR number, workaround applied in host mode
> > - modify commit message, add STAR number, workaround applied in host mode
> > - modify Author Jos Wang
> > v3 -> v4:
> > - modify commit message, add Cc: stable@vger.kernel.org
> 
> This thread is crazy, look at:
> 	https://lore.kernel.org/all/20240612153922.2531-1-joswang1221@gmail.com/
> for how it looks.  How do I pick out the proper patches to review/apply
> there at all?  What would you do if you were in my position except just
> delete the whole thing?

I usually wouldn't admit to it, cos it means more for Rob or Krzysztof
to look at, but deleting the thread is exactly what I did for the
dt-binding part of it that I got sent.
joswang June 13, 2024, 11:46 a.m. UTC | #3
On Thu, Jun 13, 2024 at 1:04 AM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Wed, Jun 12, 2024 at 11:39:22PM +0800, joswang wrote:
> > From: Jos Wang <joswang@lenovo.com>
> >
> > This is a workaround for STAR 4846132, which only affects
> > DWC_usb31 version2.00a operating in host mode.
> >
> > There is a problem in DWC_usb31 version 2.00a operating
> > in host mode that would cause a CSR read timeout When CSR
> > read coincides with RAM Clock Gating Entry. By disable
> > Clock Gating, sacrificing power consumption for normal
> > operation.
> >
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Jos Wang <joswang@lenovo.com>
> > ---
> > v1 -> v2:
> > - add "dt-bindings: usb: dwc3: Add snps,p2p3tranok quirk" patch,
> >   this patch does not make any changes
> > v2 -> v3:
> > - code refactor
> > - modify comment, add STAR number, workaround applied in host mode
> > - modify commit message, add STAR number, workaround applied in host mode
> > - modify Author Jos Wang
> > v3 -> v4:
> > - modify commit message, add Cc: stable@vger.kernel.org
>
> This thread is crazy, look at:
>         https://lore.kernel.org/all/20240612153922.2531-1-joswang1221@gmail.com/
> for how it looks.  How do I pick out the proper patches to review/apply
> there at all?  What would you do if you were in my position except just
> delete the whole thing?
>
> Just properly submit new versions of patches (hint, without the ','), as
> the documentation file says to, as new threads each time, with all
> commits, and all should be fine.
>
> We even have tools that can do this for you semi-automatically, why not
> use them?
>
> thanks,
>
> greg k-h

We apologize for any inconvenience this may cause.
The following incorrect operation caused the problem you mentioned:
git send-email --in-reply-to command sends the new version patch
git format-patch --subject-prefix='PATCH v3

Should I resend the v5 patch now?
Thinh Nguyen June 18, 2024, 12:05 a.m. UTC | #4
On Thu, Jun 13, 2024, joswang wrote:
> On Thu, Jun 13, 2024 at 1:04 AM Greg KH <gregkh@linuxfoundation.org> wrote:
> >
> > On Wed, Jun 12, 2024 at 11:39:22PM +0800, joswang wrote:
> > > From: Jos Wang <joswang@lenovo.com>
> > >
> > > This is a workaround for STAR 4846132, which only affects
> > > DWC_usb31 version2.00a operating in host mode.
> > >
> > > There is a problem in DWC_usb31 version 2.00a operating
> > > in host mode that would cause a CSR read timeout When CSR
> > > read coincides with RAM Clock Gating Entry. By disable
> > > Clock Gating, sacrificing power consumption for normal
> > > operation.
> > >
> > > Cc: stable@vger.kernel.org
> > > Signed-off-by: Jos Wang <joswang@lenovo.com>
> > > ---
> > > v1 -> v2:
> > > - add "dt-bindings: usb: dwc3: Add snps,p2p3tranok quirk" patch,
> > >   this patch does not make any changes
> > > v2 -> v3:
> > > - code refactor
> > > - modify comment, add STAR number, workaround applied in host mode
> > > - modify commit message, add STAR number, workaround applied in host mode
> > > - modify Author Jos Wang
> > > v3 -> v4:
> > > - modify commit message, add Cc: stable@vger.kernel.org
> >
> > This thread is crazy, look at:
> >         https://urldefense.com/v3/__https://lore.kernel.org/all/20240612153922.2531-1-joswang1221@gmail.com/__;!!A4F2R9G_pg!a29V9NsG_rMKPnub-JtIe5I_lAoJmzK8dgo3UK-qD_xpT_TOgyPb6LkEMkIsijsDKIgdxB_QVLW_MwtdQLnyvOujOA$ 
> > for how it looks.  How do I pick out the proper patches to review/apply
> > there at all?  What would you do if you were in my position except just
> > delete the whole thing?
> >
> > Just properly submit new versions of patches (hint, without the ','), as
> > the documentation file says to, as new threads each time, with all
> > commits, and all should be fine.
> >
> > We even have tools that can do this for you semi-automatically, why not
> > use them?
> >
> > thanks,
> >
> > greg k-h
> 
> We apologize for any inconvenience this may cause.
> The following incorrect operation caused the problem you mentioned:
> git send-email --in-reply-to command sends the new version patch
> git format-patch --subject-prefix='PATCH v3
> 
> Should I resend the v5 patch now?

Please send this as a stand-alone patch outside of the series as v5. (ie.
remove the "3/3"). I still need to review the other issue of the series.

Thanks,
Thinh
Jung Daehwan June 18, 2024, 4:24 a.m. UTC | #5
On Tue, Jun 18, 2024 at 12:05:05AM +0000, Thinh Nguyen wrote:
> On Thu, Jun 13, 2024, joswang wrote:
> > On Thu, Jun 13, 2024 at 1:04 AM Greg KH <gregkh@linuxfoundation.org> wrote:
> > >
> > > On Wed, Jun 12, 2024 at 11:39:22PM +0800, joswang wrote:
> > > > From: Jos Wang <joswang@lenovo.com>
> > > >
> > > > This is a workaround for STAR 4846132, which only affects
> > > > DWC_usb31 version2.00a operating in host mode.
> > > >
> > > > There is a problem in DWC_usb31 version 2.00a operating
> > > > in host mode that would cause a CSR read timeout When CSR
> > > > read coincides with RAM Clock Gating Entry. By disable
> > > > Clock Gating, sacrificing power consumption for normal
> > > > operation.
> > > >
> > > > Cc: stable@vger.kernel.org
> > > > Signed-off-by: Jos Wang <joswang@lenovo.com>
> > > > ---
> > > > v1 -> v2:
> > > > - add "dt-bindings: usb: dwc3: Add snps,p2p3tranok quirk" patch,
> > > >   this patch does not make any changes
> > > > v2 -> v3:
> > > > - code refactor
> > > > - modify comment, add STAR number, workaround applied in host mode
> > > > - modify commit message, add STAR number, workaround applied in host mode
> > > > - modify Author Jos Wang
> > > > v3 -> v4:
> > > > - modify commit message, add Cc: stable@vger.kernel.org
> > >
> > > This thread is crazy, look at:
> > >         https://urldefense.com/v3/__https://lore.kernel.org/all/20240612153922.2531-1-joswang1221@gmail.com/__;!!A4F2R9G_pg!a29V9NsG_rMKPnub-JtIe5I_lAoJmzK8dgo3UK-qD_xpT_TOgyPb6LkEMkIsijsDKIgdxB_QVLW_MwtdQLnyvOujOA$ 
> > > for how it looks.  How do I pick out the proper patches to review/apply
> > > there at all?  What would you do if you were in my position except just
> > > delete the whole thing?
> > >
> > > Just properly submit new versions of patches (hint, without the ','), as
> > > the documentation file says to, as new threads each time, with all
> > > commits, and all should be fine.
> > >
> > > We even have tools that can do this for you semi-automatically, why not
> > > use them?
> > >
> > > thanks,
> > >
> > > greg k-h
> > 
> > We apologize for any inconvenience this may cause.
> > The following incorrect operation caused the problem you mentioned:
> > git send-email --in-reply-to command sends the new version patch
> > git format-patch --subject-prefix='PATCH v3
> > 
> > Should I resend the v5 patch now?
> 
> Please send this as a stand-alone patch outside of the series as v5. (ie.
> remove the "3/3"). I still need to review the other issue of the series.
> 
> Thanks,
> Thinh

Hi Thinh,

We faced similar issue on DRD mode operating as device.
Could you check it internally?
Case: 01635304

Best Regards,
Jung Daehwan
joswang June 18, 2024, 12:47 p.m. UTC | #6
On Tue, Jun 18, 2024 at 8:05 AM Thinh Nguyen <Thinh.Nguyen@synopsys.com> wrote:
>
> On Thu, Jun 13, 2024, joswang wrote:
> > On Thu, Jun 13, 2024 at 1:04 AM Greg KH <gregkh@linuxfoundation.org> wrote:
> > >
> > > On Wed, Jun 12, 2024 at 11:39:22PM +0800, joswang wrote:
> > > > From: Jos Wang <joswang@lenovo.com>
> > > >
> > > > This is a workaround for STAR 4846132, which only affects
> > > > DWC_usb31 version2.00a operating in host mode.
> > > >
> > > > There is a problem in DWC_usb31 version 2.00a operating
> > > > in host mode that would cause a CSR read timeout When CSR
> > > > read coincides with RAM Clock Gating Entry. By disable
> > > > Clock Gating, sacrificing power consumption for normal
> > > > operation.
> > > >
> > > > Cc: stable@vger.kernel.org
> > > > Signed-off-by: Jos Wang <joswang@lenovo.com>
> > > > ---
> > > > v1 -> v2:
> > > > - add "dt-bindings: usb: dwc3: Add snps,p2p3tranok quirk" patch,
> > > >   this patch does not make any changes
> > > > v2 -> v3:
> > > > - code refactor
> > > > - modify comment, add STAR number, workaround applied in host mode
> > > > - modify commit message, add STAR number, workaround applied in host mode
> > > > - modify Author Jos Wang
> > > > v3 -> v4:
> > > > - modify commit message, add Cc: stable@vger.kernel.org
> > >
> > > This thread is crazy, look at:
> > >         https://urldefense.com/v3/__https://lore.kernel.org/all/20240612153922.2531-1-joswang1221@gmail.com/__;!!A4F2R9G_pg!a29V9NsG_rMKPnub-JtIe5I_lAoJmzK8dgo3UK-qD_xpT_TOgyPb6LkEMkIsijsDKIgdxB_QVLW_MwtdQLnyvOujOA$
> > > for how it looks.  How do I pick out the proper patches to review/apply
> > > there at all?  What would you do if you were in my position except just
> > > delete the whole thing?
> > >
> > > Just properly submit new versions of patches (hint, without the ','), as
> > > the documentation file says to, as new threads each time, with all
> > > commits, and all should be fine.
> > >
> > > We even have tools that can do this for you semi-automatically, why not
> > > use them?
> > >
> > > thanks,
> > >
> > > greg k-h
> >
> > We apologize for any inconvenience this may cause.
> > The following incorrect operation caused the problem you mentioned:
> > git send-email --in-reply-to command sends the new version patch
> > git format-patch --subject-prefix='PATCH v3
> >
> > Should I resend the v5 patch now?
>
> Please send this as a stand-alone patch outside of the series as v5. (ie.
> remove the "3/3"). I still need to review the other issue of the series.
>
> Thanks,
> Thinh

This patch has been sent separately, please help review it.

Thanks
Jos Wang
Greg Kroah-Hartman June 18, 2024, 1:38 p.m. UTC | #7
On Tue, Jun 18, 2024 at 08:47:38PM +0800, joswang wrote:
> On Tue, Jun 18, 2024 at 8:05 AM Thinh Nguyen <Thinh.Nguyen@synopsys.com> wrote:
> >
> > On Thu, Jun 13, 2024, joswang wrote:
> > > On Thu, Jun 13, 2024 at 1:04 AM Greg KH <gregkh@linuxfoundation.org> wrote:
> > > >
> > > > On Wed, Jun 12, 2024 at 11:39:22PM +0800, joswang wrote:
> > > > > From: Jos Wang <joswang@lenovo.com>
> > > > >
> > > > > This is a workaround for STAR 4846132, which only affects
> > > > > DWC_usb31 version2.00a operating in host mode.
> > > > >
> > > > > There is a problem in DWC_usb31 version 2.00a operating
> > > > > in host mode that would cause a CSR read timeout When CSR
> > > > > read coincides with RAM Clock Gating Entry. By disable
> > > > > Clock Gating, sacrificing power consumption for normal
> > > > > operation.
> > > > >
> > > > > Cc: stable@vger.kernel.org
> > > > > Signed-off-by: Jos Wang <joswang@lenovo.com>
> > > > > ---
> > > > > v1 -> v2:
> > > > > - add "dt-bindings: usb: dwc3: Add snps,p2p3tranok quirk" patch,
> > > > >   this patch does not make any changes
> > > > > v2 -> v3:
> > > > > - code refactor
> > > > > - modify comment, add STAR number, workaround applied in host mode
> > > > > - modify commit message, add STAR number, workaround applied in host mode
> > > > > - modify Author Jos Wang
> > > > > v3 -> v4:
> > > > > - modify commit message, add Cc: stable@vger.kernel.org
> > > >
> > > > This thread is crazy, look at:
> > > >         https://urldefense.com/v3/__https://lore.kernel.org/all/20240612153922.2531-1-joswang1221@gmail.com/__;!!A4F2R9G_pg!a29V9NsG_rMKPnub-JtIe5I_lAoJmzK8dgo3UK-qD_xpT_TOgyPb6LkEMkIsijsDKIgdxB_QVLW_MwtdQLnyvOujOA$
> > > > for how it looks.  How do I pick out the proper patches to review/apply
> > > > there at all?  What would you do if you were in my position except just
> > > > delete the whole thing?
> > > >
> > > > Just properly submit new versions of patches (hint, without the ','), as
> > > > the documentation file says to, as new threads each time, with all
> > > > commits, and all should be fine.
> > > >
> > > > We even have tools that can do this for you semi-automatically, why not
> > > > use them?
> > > >
> > > > thanks,
> > > >
> > > > greg k-h
> > >
> > > We apologize for any inconvenience this may cause.
> > > The following incorrect operation caused the problem you mentioned:
> > > git send-email --in-reply-to command sends the new version patch
> > > git format-patch --subject-prefix='PATCH v3
> > >
> > > Should I resend the v5 patch now?
> >
> > Please send this as a stand-alone patch outside of the series as v5. (ie.
> > remove the "3/3"). I still need to review the other issue of the series.
> >
> > Thanks,
> > Thinh
> 
> This patch has been sent separately, please help review it.

You too can help review other commits on the list to reduce the
maintainer load here.  Please do so in order to insure that there is
time to review your changes as well.

thanks,

greg k-h
Thinh Nguyen June 18, 2024, 9:36 p.m. UTC | #8
On Tue, Jun 18, 2024, Jung Daehwan wrote:
> 
> Hi Thinh,
> 
> We faced similar issue on DRD mode operating as device.
> Could you check it internally?
> Case: 01635304
> 

Hi Jung,

It's a separate case. Please check through our support channel to avoid
any miscommunication/disconnect.

Thanks,
Thinh
Jung Daehwan June 19, 2024, 1:34 a.m. UTC | #9
On Tue, Jun 18, 2024 at 09:36:03PM +0000, Thinh Nguyen wrote:
> On Tue, Jun 18, 2024, Jung Daehwan wrote:
> > 
> > Hi Thinh,
> > 
> > We faced similar issue on DRD mode operating as device.
> > Could you check it internally?
> > Case: 01635304
> > 
> 
> Hi Jung,
> 
> It's a separate case. Please check through our support channel to avoid
> any miscommunication/disconnect.
> 
> Thanks,
> Thinh

Thanks for the check. I will check through the support channel again.

Best Regards,
Jung Daehwan
diff mbox series

Patch

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 3a8fbc2d6b99..61f858f64e5a 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -960,12 +960,16 @@  static bool dwc3_core_is_valid(struct dwc3 *dwc)
 
 static void dwc3_core_setup_global_control(struct dwc3 *dwc)
 {
+	unsigned int power_opt;
+	unsigned int hw_mode;
 	u32 reg;
 
 	reg = dwc3_readl(dwc->regs, DWC3_GCTL);
 	reg &= ~DWC3_GCTL_SCALEDOWN_MASK;
+	hw_mode = DWC3_GHWPARAMS0_MODE(dwc->hwparams.hwparams0);
+	power_opt = DWC3_GHWPARAMS1_EN_PWROPT(dwc->hwparams.hwparams1);
 
-	switch (DWC3_GHWPARAMS1_EN_PWROPT(dwc->hwparams.hwparams1)) {
+	switch (power_opt) {
 	case DWC3_GHWPARAMS1_EN_PWROPT_CLK:
 		/**
 		 * WORKAROUND: DWC3 revisions between 2.10a and 2.50a have an
@@ -998,6 +1002,20 @@  static void dwc3_core_setup_global_control(struct dwc3 *dwc)
 		break;
 	}
 
+	/*
+	 * This is a workaround for STAR#4846132, which only affects
+	 * DWC_usb31 version2.00a operating in host mode.
+	 *
+	 * There is a problem in DWC_usb31 version 2.00a operating
+	 * in host mode that would cause a CSR read timeout When CSR
+	 * read coincides with RAM Clock Gating Entry. By disable
+	 * Clock Gating, sacrificing power consumption for normal
+	 * operation.
+	 */
+	if (power_opt != DWC3_GHWPARAMS1_EN_PWROPT_NO &&
+	    hw_mode != DWC3_GHWPARAMS0_MODE_GADGET && DWC3_VER_IS(DWC31, 200A))
+		reg |= DWC3_GCTL_DSBLCLKGTNG;
+
 	/* check if current dwc3 is on simulation board */
 	if (dwc->hwparams.hwparams6 & DWC3_GHWPARAMS6_EN_FPGA) {
 		dev_info(dwc->dev, "Running with FPGA optimizations\n");