Skip to contentSkip to conversation

usb: dwc3: core: Workaround for CSR read timeout

PATCH In review joswang 3 participants 12 messages Jun 19, 2024 – Jun 27, 2024

Subsystems (3)
lore
Share & tools
lore

joswang

author
#0 lore raw

PATCH v7 1/1 usb: dwc3: core: Workaround for CSR read timeout

From: Jos Wang <[email protected]>

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.

---
v6 -> v7: code no change. Just add the v4->v5 and v5->v6
version difference description
v5 -> v6: code no change. however, there were two v5
patches, which confused the reviewers, so a v6 version
was submitted.
v4 -> v5: code no change. Patches "1/3" and "2/3" of the
patch series are under review, this patch is submitted independently.
v3 -> v4: modify commit message, add Cc: [email protected] 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
v1 -> v2: code no change. Add other case patches to the patch series

 drivers/usb/dwc3/core.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/usb/dwc3/core.c +19 -1
index 7ee61a89520b..2a3adc80fe0f 100644
@@ -957,12 +957,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
@@ -995,6 +999,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");
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 5 lines · joswang

From: Jos Wang <[email protected]>

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

Quoted 8 lines

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.

What commit id does this fix? How far back should it be backported in the stable releases?

thanks,

greg k-h

author
#2 lore raw
Quoted 16 lines · Greg KH
Quoted 5 lines · joswang

From: Jos Wang <[email protected]>

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

Quoted 8 lines

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.

Quoted 6 lines

What commit id does this fix? How far back should it be backported in the stable releases?

thanks,

greg k-h

Hello Greg Thinh

It seems first begin from the commit 1e43c86d84fb ("usb: dwc3: core:
Add DWC31 version 2.00a controller")
in 6.8.0-rc6 branch ?

Thanks

Jos Wang

maintainer
#3 lore raw
Quoted 22 lines · joswang
Quoted 21 lines · Greg KH
Quoted 5 lines · joswang

From: Jos Wang <[email protected]>

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

Quoted 8 lines

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.

What commit id does this fix? How far back should it be backported in the stable releases?

thanks,

Quoted 7 lines
Quoted 1 line

greg k-h

Hello Greg Thinh

It seems first begin from the commit 1e43c86d84fb ("usb: dwc3: core:
Add DWC31 version 2.00a controller")
in 6.8.0-rc6 branch ?

That commit showed up in 6.9, not 6.8. And if so, please resend with a proper "Fixes:" tag.

thanks,

greg k-h

maintainer
#4 lore raw
Quoted 25 lines · Greg KH
Quoted 24 lines · joswang
Quoted 22 lines · Greg KH
Quoted 5 lines · joswang

From: Jos Wang <[email protected]>

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

Quoted 8 lines

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.

What commit id does this fix? How far back should it be backported in the stable releases?

thanks,

greg k-h

Quoted 9 lines
Quoted 5 lines

Hello Greg Thinh

It seems first begin from the commit 1e43c86d84fb ("usb: dwc3: core:
Add DWC31 version 2.00a controller")
in 6.8.0-rc6 branch ?

That commit showed up in 6.9, not 6.8. And if so, please resend with a proper "Fixes:" tag.

This patch workarounds the controller's issue. It doesn't resolve any particular commit that requires a "Fixes" tag. So, this should go on "next". It can be backported as needed. If it's to be backported, it can probably go back to as far as v4.3, to commit 690fb3718a70 ("usb: dwc3:
Support Synopsys USB 3.1 IP"). But you'd need to collect all the dependencies including the commit mention above.

BR,
Thinh

maintainer
#5 lore raw
Quoted 32 lines · Thinh Nguyen
Quoted 31 lines · Greg KH
Quoted 29 lines · joswang
Quoted 16 lines · Greg KH
Quoted 5 lines · joswang

From: Jos Wang <[email protected]>

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

Quoted 8 lines

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.

Quoted 6 lines

What commit id does this fix? How far back should it be backported in the stable releases?

thanks,

greg k-h

Hello Greg Thinh

It seems first begin from the commit 1e43c86d84fb ("usb: dwc3: core:
Add DWC31 version 2.00a controller")
in 6.8.0-rc6 branch ?

Quoted 5 lines
Quoted 3 lines

That commit showed up in 6.9, not 6.8. And if so, please resend with a proper "Fixes:" tag.

This patch workarounds the controller's issue.

So it fixes a bug? Or does not fix a bug? I'm confused.

Quoted 3 lines

It doesn't resolve any
particular commit that requires a "Fixes" tag. So, this should go on "next". It can be backported as needed.

Who would do the backporting and when?

Quoted 4 lines

If it's to be backported, it can
probably go back to as far as v4.3, to commit 690fb3718a70 ("usb: dwc3:
Support Synopsys USB 3.1 IP"). But you'd need to collect all the dependencies including the commit mention above.

I don't understand, sorry. Is this just a normal "evolve the driver to work better" change, or is it a "fix broken code" change, or is it something else?

In other words, what do you want to see happen to this? What tree(s) would you want it applied to?

thanks,

greg k-h

maintainer
#6 lore raw
Quoted 33 lines · Greg KH
Quoted 32 lines · Thinh Nguyen
Quoted 31 lines · Greg KH
Quoted 29 lines · joswang
Quoted 16 lines · Greg KH
Quoted 5 lines · joswang

From: Jos Wang <[email protected]>

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

Quoted 8 lines

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.

Quoted 6 lines

What commit id does this fix? How far back should it be backported in the stable releases?

thanks,

greg k-h

Hello Greg Thinh

It seems first begin from the commit 1e43c86d84fb ("usb: dwc3: core:
Add DWC31 version 2.00a controller")
in 6.8.0-rc6 branch ?

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

That commit showed up in 6.9, not 6.8. And if so, please resend with a proper "Fixes:" tag.

This patch workarounds the controller's issue.

So it fixes a bug? Or does not fix a bug? I'm confused.

The bug is not a driver's bug. The fix applies to a hardware bug and not any particular commit that can be referenced with a "Fixes" tag.

Quoted 6 lines
Quoted 4 lines

It doesn't resolve any
particular commit that requires a "Fixes" tag. So, this should go on "next". It can be backported as needed.

Who would do the backporting and when?

For anyone who doesn't use mainline kernel that needs this patch backported to their kernel version.

Quoted 6 lines
Quoted 5 lines

If it's to be backported, it can
probably go back to as far as v4.3, to commit 690fb3718a70 ("usb: dwc3:
Support Synopsys USB 3.1 IP"). But you'd need to collect all the dependencies including the commit mention above.

Quoted 7 lines

I don't understand, sorry. Is this just a normal "evolve the driver to work better" change, or is it a "fix broken code" change, or is it something else?

In other words, what do you want to see happen to this? What tree(s) would you want it applied to?

It's up to you, but it seems to fit "usb-testing" branch more since it doesn't have a "Fixes" tag. The severity of this fix is debatable since it doesn't apply to every DWC_usb31 configuration or every scenario.

Thanks,
Thinh

maintainer
#7 lore raw
Quoted 38 lines · Thinh Nguyen
Quoted 37 lines · Greg KH
Quoted 36 lines · Thinh Nguyen
Quoted 34 lines · Greg KH
Quoted 22 lines · joswang
Quoted 21 lines · Greg KH
Quoted 5 lines · joswang

From: Jos Wang <[email protected]>

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

Quoted 8 lines

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.

What commit id does this fix? How far back should it be backported in the stable releases?

thanks,

Quoted 7 lines
Quoted 1 line

greg k-h

Hello Greg Thinh

It seems first begin from the commit 1e43c86d84fb ("usb: dwc3: core:
Add DWC31 version 2.00a controller")
in 6.8.0-rc6 branch ?

That commit showed up in 6.9, not 6.8. And if so, please resend with a proper "Fixes:" tag.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

This patch workarounds the controller's issue.

So it fixes a bug? Or does not fix a bug? I'm confused.

The bug is not a driver's bug. The fix applies to a hardware bug and not any particular commit that can be referenced with a "Fixes" tag.

So it's a bug that the kernel needs to work around, that's fine. But that implies it should go to "all" stable kernels that it can, right?

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

It doesn't resolve any
particular commit that requires a "Fixes" tag. So, this should go on "next". It can be backported as needed.

Who would do the backporting and when?

For anyone who doesn't use mainline kernel that needs this patch backported to their kernel version.

I can not poarse this, sorry. We can't do anything about people who don't use our kernel trees, so what does this mean?

Quoted 9 lines
Quoted 9 lines
Quoted 4 lines

If it's to be backported, it can
probably go back to as far as v4.3, to commit 690fb3718a70 ("usb: dwc3:
Support Synopsys USB 3.1 IP"). But you'd need to collect all the dependencies including the commit mention above.

I don't understand, sorry. Is this just a normal "evolve the driver to work better" change, or is it a "fix broken code" change, or is it something else?

Quoted 7 lines
Quoted 3 lines

In other words, what do you want to see happen to this? What tree(s) would you want it applied to?

It's up to you, but it seems to fit "usb-testing" branch more since it doesn't have a "Fixes" tag. The severity of this fix is debatable since it doesn't apply to every DWC_usb31 configuration or every scenario.

As it is "cc: stable" that implies that it should get to Linus for 6.10-final, not wait for 6.11-rc1 as the 6.11 release is months away, and anyone who has this issue would want it fixed sooner.

still confused,

greg k-h

maintainer
#8 lore raw
Quoted 41 lines · Greg KH
Quoted 40 lines · Thinh Nguyen
Quoted 39 lines · Greg KH
Quoted 37 lines · Thinh Nguyen
Quoted 25 lines · Greg KH
Quoted 24 lines · joswang
Quoted 22 lines · Greg KH
Quoted 5 lines · joswang

From: Jos Wang <[email protected]>

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

Quoted 8 lines

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.

What commit id does this fix? How far back should it be backported in the stable releases?

thanks,

greg k-h

Quoted 9 lines
Quoted 5 lines

Hello Greg Thinh

It seems first begin from the commit 1e43c86d84fb ("usb: dwc3: core:
Add DWC31 version 2.00a controller")
in 6.8.0-rc6 branch ?

That commit showed up in 6.9, not 6.8. And if so, please resend with a proper "Fixes:" tag.

This patch workarounds the controller's issue.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

So it fixes a bug? Or does not fix a bug? I'm confused.

The bug is not a driver's bug. The fix applies to a hardware bug and not any particular commit that can be referenced with a "Fixes" tag.

So it's a bug that the kernel needs to work around, that's fine. But that implies it should go to "all" stable kernels that it can, right?

Yes. That's right.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

It doesn't resolve any
particular commit that requires a "Fixes" tag. So, this should go on "next". It can be backported as needed.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Who would do the backporting and when?

For anyone who doesn't use mainline kernel that needs this patch backported to their kernel version.

I can not poarse this, sorry. We can't do anything about people who don't use our kernel trees, so what does this mean?

Sorry, I wasn't being clear. What I meant is that it needs some work to backport to stable version prior to v6.9. Anyone who needs to backport this prior to this will need to resolve these dependencies.

Quoted 18 lines
Quoted 10 lines
Quoted 10 lines
Quoted 5 lines

If it's to be backported, it can
probably go back to as far as v4.3, to commit 690fb3718a70 ("usb: dwc3:
Support Synopsys USB 3.1 IP"). But you'd need to collect all the dependencies including the commit mention above.

I don't understand, sorry. Is this just a normal "evolve the driver to work better" change, or is it a "fix broken code" change, or is it something else?

Quoted 7 lines
Quoted 3 lines

In other words, what do you want to see happen to this? What tree(s) would you want it applied to?

It's up to you, but it seems to fit "usb-testing" branch more since it doesn't have a "Fixes" tag. The severity of this fix is debatable since it doesn't apply to every DWC_usb31 configuration or every scenario.

Quoted 6 lines

As it is "cc: stable" that implies that it should get to Linus for 6.10-final, not wait for 6.11-rc1 as the 6.11 release is months away, and anyone who has this issue would want it fixed sooner.

still confused,

Ok. I may have misunderstood what can go into rc2 and beyond then. If we don't have to wait for the next rc1 for it to be picked up for stable, then can we add it to "usb-linus" branch?

There won't be a Fixes tag, but we can backport it up to 5.10.x:

Cc <[email protected]> # 5.10.x: 1e43c86d: usb: dwc3: core: Add DWC31 version 2.00a controller
Cc <[email protected]> # 5.10.x

This can go after the versioning scheme in dwc3 in the 5.10.x lts. I did not check what other dependencies are needed in addition to the change above.

Thanks,
Thinh

author
#9 lore raw
Quoted 104 lines · Thinh Nguyen
Quoted 41 lines · Greg KH
Quoted 40 lines · Thinh Nguyen
Quoted 39 lines · Greg KH
Quoted 37 lines · Thinh Nguyen
Quoted 25 lines · Greg KH
Quoted 24 lines · joswang
Quoted 22 lines · Greg KH
Quoted 5 lines · joswang

From: Jos Wang <[email protected]>

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

Quoted 8 lines

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.

What commit id does this fix? How far back should it be backported in the stable releases?

thanks,

greg k-h

Quoted 9 lines
Quoted 5 lines

Hello Greg Thinh

It seems first begin from the commit 1e43c86d84fb ("usb: dwc3: core:
Add DWC31 version 2.00a controller")
in 6.8.0-rc6 branch ?

That commit showed up in 6.9, not 6.8. And if so, please resend with a proper "Fixes:" tag.

This patch workarounds the controller's issue.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

So it fixes a bug? Or does not fix a bug? I'm confused.

The bug is not a driver's bug. The fix applies to a hardware bug and not any particular commit that can be referenced with a "Fixes" tag.

So it's a bug that the kernel needs to work around, that's fine. But that implies it should go to "all" stable kernels that it can, right?

Yes. That's right.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

It doesn't resolve any
particular commit that requires a "Fixes" tag. So, this should go on "next". It can be backported as needed.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Who would do the backporting and when?

For anyone who doesn't use mainline kernel that needs this patch backported to their kernel version.

I can not poarse this, sorry. We can't do anything about people who don't use our kernel trees, so what does this mean?

Sorry, I wasn't being clear. What I meant is that it needs some work to backport to stable version prior to v6.9. Anyone who needs to backport this prior to this will need to resolve these dependencies.

Quoted 18 lines
Quoted 10 lines
Quoted 10 lines
Quoted 5 lines

If it's to be backported, it can
probably go back to as far as v4.3, to commit 690fb3718a70 ("usb: dwc3:
Support Synopsys USB 3.1 IP"). But you'd need to collect all the dependencies including the commit mention above.

I don't understand, sorry. Is this just a normal "evolve the driver to work better" change, or is it a "fix broken code" change, or is it something else?

Quoted 7 lines
Quoted 3 lines

In other words, what do you want to see happen to this? What tree(s) would you want it applied to?

It's up to you, but it seems to fit "usb-testing" branch more since it doesn't have a "Fixes" tag. The severity of this fix is debatable since it doesn't apply to every DWC_usb31 configuration or every scenario.

Quoted 6 lines

As it is "cc: stable" that implies that it should get to Linus for 6.10-final, not wait for 6.11-rc1 as the 6.11 release is months away, and anyone who has this issue would want it fixed sooner.

still confused,

Ok. I may have misunderstood what can go into rc2 and beyond then. If we don't have to wait for the next rc1 for it to be picked up for stable, then can we add it to "usb-linus" branch?

There won't be a Fixes tag, but we can backport it up to 5.10.x:

Cc <[email protected]> # 5.10.x: 1e43c86d: usb: dwc3: core: Add DWC31 version 2.00a controller
Cc <[email protected]> # 5.10.x
Quoted 6 lines

This can go after the versioning scheme in dwc3 in the 5.10.x lts. I did not check what other dependencies are needed in addition to the change above.

Thanks,
Thinh

Is there anything else I need to modify for this patch?

Thanks,
Jos Wang

maintainer Acked-by
#10 lore raw
Quoted 11 lines · joswang
Quoted 10 lines · Thinh Nguyen

Ok. I may have misunderstood what can go into rc2 and beyond then. If we don't have to wait for the next rc1 for it to be picked up for stable, then can we add it to "usb-linus" branch?

There won't be a Fixes tag, but we can backport it up to 5.10.x:

Cc <[email protected]> # 5.10.x: 1e43c86d: usb: dwc3: core: Add DWC31 version 2.00a controller
Cc <[email protected]> # 5.10.x
Quoted 9 lines
Quoted 6 lines

This can go after the versioning scheme in dwc3 in the 5.10.x lts. I did not check what other dependencies are needed in addition to the change above.

Thanks,
Thinh

Is there anything else I need to modify for this patch?

Hi Greg,

Will a simple tag "Cc: <[email protected]>" sufficient? Or would you prefer using the tags above?

For either case:

Thanks,
Thinh

maintainer
#11 lore raw
Quoted 22 lines · Thinh Nguyen
Quoted 11 lines · joswang
Quoted 10 lines · Thinh Nguyen

Ok. I may have misunderstood what can go into rc2 and beyond then. If we don't have to wait for the next rc1 for it to be picked up for stable, then can we add it to "usb-linus" branch?

There won't be a Fixes tag, but we can backport it up to 5.10.x:

Cc <[email protected]> # 5.10.x: 1e43c86d: usb: dwc3: core: Add DWC31 version 2.00a controller
Cc <[email protected]> # 5.10.x
Quoted 9 lines
Quoted 6 lines

This can go after the versioning scheme in dwc3 in the 5.10.x lts. I did not check what other dependencies are needed in addition to the change above.

Thanks,
Thinh

Is there anything else I need to modify for this patch?

Quoted 8 lines

Hi Greg,

Will a simple tag "Cc: <[email protected]>" sufficient? Or would you prefer using the tags above?

For either case:

I fixed this up by hand, thanks for the ack!

greg k-h