Skip to contentSkip to conversation

usb: dwc3: core: add p3p2tranok quirk

PATCH New joswang 6 participants 51 messages Jun 1, 2024 – Jul 1, 2024 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore

joswang

author
#0 lore raw

PATCH 1/2 usb: dwc3: core: add p3p2tranok quirk

From: joswang <[email protected]>

In the case of enable hibernation, there is an issue with the DWC31 2.00a and earlier versions where the controller link power state transition from P3/P3CPM/P4 to P2 may take longer than expected, ultimately resulting in the hibernation D3 entering time exceeding the expected 10ms.

Synopsys workaround:
If the PHY supports direct P3 to P2 transition, program GUSB3PIPECTL.P3P2Tran0K=1. However, note that as per PIPE4 Specification, direct transition from P3 to P2 is illegal.

Therefore, adding p3p2tranok quirk for workaround hibernation D3 exceeded the expected entry time.

---
 drivers/usb/dwc3/core.c | 5 +++++
 drivers/usb/dwc3/core.h | 4 ++++
 2 files changed, 9 insertions(+)
drivers/usb/dwc3/core.c +5 -0
index 7ee61a89520b..3a8fbc2d6b99 100644
@@ -666,6 +666,9 @@ static int dwc3_ss_phy_setup(struct dwc3 *dwc, int index)
 	if (dwc->dis_del_phy_power_chg_quirk)
 		reg &= ~DWC3_GUSB3PIPECTL_DEPOCHANGE;
 
+	if (dwc->p2p3tranok_quirk)
+		reg |= DWC3_GUSB3PIPECTL_P3P2TRANOK;
+
 	dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(index), reg);
 
 	return 0;
@@ -1715,6 +1718,8 @@ static void dwc3_get_properties(struct dwc3 *dwc)
 
 	dwc->dis_split_quirk = device_property_read_bool(dev,
 				"snps,dis-split-quirk");
+	dwc->p2p3tranok_quirk = device_property_read_bool(dev,
+				"snps,p2p3tranok-quirk");
 
 	dwc->lpm_nyet_threshold = lpm_nyet_threshold;
 	dwc->tx_de_emphasis = tx_de_emphasis;
drivers/usb/dwc3/core.h +4 -0
index 3781c736c1a1..2810dce8b42e 100644
@@ -327,6 +327,7 @@
 #define DWC3_GUSB3PIPECTL_DEP1P2P3_EN	DWC3_GUSB3PIPECTL_DEP1P2P3(1)
 #define DWC3_GUSB3PIPECTL_DEPOCHANGE	BIT(18)
 #define DWC3_GUSB3PIPECTL_SUSPHY	BIT(17)
+#define DWC3_GUSB3PIPECTL_P3P2TRANOK	BIT(11)
 #define DWC3_GUSB3PIPECTL_LFPSFILT	BIT(9)
 #define DWC3_GUSB3PIPECTL_RX_DETOPOLL	BIT(8)
 #define DWC3_GUSB3PIPECTL_TX_DEEPH_MASK	DWC3_GUSB3PIPECTL_TX_DEEPH(3)
@@ -1132,6 +1133,8 @@ struct dwc3_scratchpad_array {
  *			instances in park mode.
  * @parkmode_disable_hs_quirk: set if we need to disable all HishSpeed
  *			instances in park mode.
+ * @p2p3tranok_quirk: set if Controller transitions directly from phy
+ *			power state P2 to P3 or from state P3 to P2.
  * @gfladj_refclk_lpm_sel: set if we need to enable SOF/ITP counter
  *                          running based on ref_clk
  * @tx_de_emphasis_quirk: set if we enable Tx de-emphasis quirk
@@ -1361,6 +1364,7 @@ struct dwc3 {
 	unsigned		ulpi_ext_vbus_drv:1;
 	unsigned		parkmode_disable_ss_quirk:1;
 	unsigned		parkmode_disable_hs_quirk:1;
+	unsigned		p2p3tranok_quirk:1;
 	unsigned		gfladj_refclk_lpm_sel:1;
 
 	unsigned		tx_de_emphasis_quirk:1;
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 2/2 usb: dwc3: core: Workaround for CSR read timeout

From: joswang <[email protected]>

DWC31 version 2.00a have an issue that would cause a CSR read timeout When CSR read coincides with RAM Clock Gating Entry.

This workaround solution disable Clock Gating, sacrificing power consumption for normal operation.

---
 drivers/usb/dwc3/core.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
drivers/usb/dwc3/core.c +23 -0
index 3a8fbc2d6b99..1df85c505c9e 100644
@@ -978,11 +978,22 @@ static void dwc3_core_setup_global_control(struct dwc3 *dwc)
 		 *
 		 * STAR#9000588375: Clock Gating, SOF Issues when ref_clk-Based
 		 * SOF/ITP Mode Used
+		 *
+		 * WORKAROUND: DWC31 version 2.00a have an issue that would
+		 * cause a CSR read timeout When CSR read coincides with RAM
+		 * Clock Gating Entry.
+		 *
+		 * This workaround solution disable Clock Gating, sacrificing
+		 * power consumption for normal operation.
 		 */
 		if ((dwc->dr_mode == USB_DR_MODE_HOST ||
 				dwc->dr_mode == USB_DR_MODE_OTG) &&
 				DWC3_VER_IS_WITHIN(DWC3, 210A, 250A))
 			reg |= DWC3_GCTL_DSBLCLKGTNG | DWC3_GCTL_SOFITPSYNC;
+		else if ((dwc->dr_mode == USB_DR_MODE_HOST ||
+				dwc->dr_mode == USB_DR_MODE_OTG) &&
+				DWC3_VER_IS(DWC31, 200A))
+			reg |= DWC3_GCTL_DSBLCLKGTNG;
 		else
 			reg &= ~DWC3_GCTL_DSBLCLKGTNG;
 		break;
@@ -992,6 +1003,18 @@ static void dwc3_core_setup_global_control(struct dwc3 *dwc)
 		 * will work. Device-mode hibernation is not yet implemented.
 		 */
 		reg |= DWC3_GCTL_GBLHIBERNATIONEN;
+
+		/*
+		 * WORKAROUND: DWC31 version 2.00a have an issue that would
+		 * cause a CSR read timeout When CSR read coincides with RAM
+		 * Clock Gating Entry.
+		 *
+		 * This workaround solution disable Clock Gating, sacrificing
+		 * power consumption for normal operation.
+		 */
+		if ((dwc->dr_mode == USB_DR_MODE_HOST ||
+		     dwc->dr_mode == USB_DR_MODE_OTG) && DWC3_VER_IS(DWC31, 200A))
+			reg |= DWC3_GCTL_DSBLCLKGTNG;
 		break;
 	default:
 		/* nothing */
Signature · 1 line
2.17.1
author
#2 lore raw

PATCH v2 1/3 dt-bindings: usb: dwc3: Add snps,p2p3tranok quirk

In reply to joswang

From: joswang <[email protected]>

There is an issue with the DWC31 2.00a and earlier versions where the controller link power state transition from P3/P3CPM/P4 to P2 may take longer than expected, ultimately resulting in the hibernation D3 entering time exceeding the expected 10ms.

Add a new 'snps,p2p3tranok-quirk' DT quirk to dwc3 core for enable the controller transitions directly from phy power state P2 to P3 or from state P3 to P2.

Note that this can only be set if the USB3 PHY supports direct p3 to p2 or p2 to p3 conversion.

---
 Documentation/devicetree/bindings/usb/snps,dwc3.yaml | 7 +++++++
 1 file changed, 7 insertions(+)
Documentation/devicetree/bindings/usb/snps,dwc3.yaml +7 -0
index 1cd0ca90127d..721927495887 100644
@@ -242,6 +242,13 @@ properties:
       When set, all HighSpeed bus instances in park mode are disabled.
     type: boolean
 
+  snps,p2p3tranok-quirk:
+    description:
+      When set, the controller transitions directly from phy power state
+      P2 to P3 or from state P3 to P2. Note that this can only be set
+      if the USB3 PHY supports direct p3 to p2 or p2 to p3 conversion.
+    type: boolean
+
   snps,dis_metastability_quirk:
     description:
       When set, disable metastability workaround. CAUTION! Use only if you are
Signature · 1 line
2.17.1
#3 lore raw

Re: [PATCH v2, 1/3] dt-bindings: usb: dwc3: Add snps,p2p3tranok quirk

Quoted 1 line · joswang

From: joswang <[email protected]>

Is this your full name or known identity you want to use for all kernel contributions? Looks like login...

Quoted 24 lines

There is an issue with the DWC31 2.00a and earlier versions where the controller link power state transition from P3/P3CPM/P4 to P2 may take longer than expected, ultimately resulting in the hibernation D3 entering time exceeding the expected 10ms.

Add a new 'snps,p2p3tranok-quirk' DT quirk to dwc3 core for enable the controller transitions directly from phy power state P2 to P3 or from state P3 to P2.

Note that this can only be set if the USB3 PHY supports direct p3 to p2 or p2 to p3 conversion.

---
 Documentation/devicetree/bindings/usb/snps,dwc3.yaml | 7 +++++++
 1 file changed, 7 insertions(+)
Documentation/devicetree/bindings/usb/snps,dwc3.yaml +0 -0
index 1cd0ca90127d..721927495887 100644

Documentation/devicetree/bindings/usb/snps,dwc3.yaml properties: · line 245

Quoted 4 lines
Documentation/devicetree/bindings/usb/snps,dwc3.yaml +1 -0
@@ -242,6 +242,13 @@ properties:
       When set, all HighSpeed bus instances in park mode are disabled.
     type: boolean
 
+  snps,p2p3tranok-quirk:

Why this cannot be deduced from compatible? Which upstream SoCs are affected?

Best regards,
Krzysztof

author
#4 lore raw

Re: [PATCH v2, 1/3] dt-bindings: usb: dwc3: Add snps,p2p3tranok quirk

Quoted 41 lines · Krzysztof Kozlowski
Quoted 1 line · joswang

From: joswang <[email protected]>

Is this your full name or known identity you want to use for all kernel contributions? Looks like login...

Quoted 24 lines

There is an issue with the DWC31 2.00a and earlier versions where the controller link power state transition from P3/P3CPM/P4 to P2 may take longer than expected, ultimately resulting in the hibernation D3 entering time exceeding the expected 10ms.

Add a new 'snps,p2p3tranok-quirk' DT quirk to dwc3 core for enable the controller transitions directly from phy power state P2 to P3 or from state P3 to P2.

Note that this can only be set if the USB3 PHY supports direct p3 to p2 or p2 to p3 conversion.

---
 Documentation/devicetree/bindings/usb/snps,dwc3.yaml | 7 +++++++
 1 file changed, 7 insertions(+)
Documentation/devicetree/bindings/usb/snps,dwc3.yaml +0 -0
index 1cd0ca90127d..721927495887 100644

Documentation/devicetree/bindings/usb/snps,dwc3.yaml properties: · line 245

Quoted 4 lines
Documentation/devicetree/bindings/usb/snps,dwc3.yaml +1 -0
@@ -242,6 +242,13 @@ properties:
       When set, all HighSpeed bus instances in park mode are disabled.
     type: boolean
 
+  snps,p2p3tranok-quirk:

Why this cannot be deduced from compatible? Which upstream SoCs are affected?

Quoted 3 lines

Best regards,
Krzysztof

Thanks for your help in reviewing the code
DWC31_USB 2.00a and earlier versions IP bug, regardless of platform.

#5 lore raw

Re: [PATCH v2, 1/3] dt-bindings: usb: dwc3: Add snps,p2p3tranok quirk

Quoted 42 lines · joswang
Quoted 41 lines · Krzysztof Kozlowski
Quoted 1 line · joswang

From: joswang <[email protected]>

Is this your full name or known identity you want to use for all kernel contributions? Looks like login...

Quoted 24 lines

There is an issue with the DWC31 2.00a and earlier versions where the controller link power state transition from P3/P3CPM/P4 to P2 may take longer than expected, ultimately resulting in the hibernation D3 entering time exceeding the expected 10ms.

Add a new 'snps,p2p3tranok-quirk' DT quirk to dwc3 core for enable the controller transitions directly from phy power state P2 to P3 or from state P3 to P2.

Note that this can only be set if the USB3 PHY supports direct p3 to p2 or p2 to p3 conversion.

---
 Documentation/devicetree/bindings/usb/snps,dwc3.yaml | 7 +++++++
 1 file changed, 7 insertions(+)
Documentation/devicetree/bindings/usb/snps,dwc3.yaml +0 -0
index 1cd0ca90127d..721927495887 100644

Documentation/devicetree/bindings/usb/snps,dwc3.yaml properties: · line 245

Quoted 4 lines
Documentation/devicetree/bindings/usb/snps,dwc3.yaml +1 -0
@@ -242,6 +242,13 @@ properties:
       When set, all HighSpeed bus instances in park mode are disabled.
     type: boolean
 
+  snps,p2p3tranok-quirk:

Why this cannot be deduced from compatible? Which upstream SoCs are affected?

Quoted 6 lines
Quoted 3 lines

Best regards,
Krzysztof

Thanks for your help in reviewing the code
DWC31_USB 2.00a and earlier versions IP bug, regardless of platform.

So this can be deduced from compatible, then use quirks in the driver based on compatible and drop the property.

Best regards,
Krzysztof

author
#6 lore raw

PATCH v2 2/3 usb: dwc3: core: add p3p2tranok quirk

In reply to joswang

From: joswang <[email protected]>

In the case of enable hibernation, there is an issue with the DWC31 2.00a and earlier versions where the controller link power state transition from P3/P3CPM/P4 to P2 may take longer than expected, ultimately resulting in the hibernation D3 entering time exceeding the expected 10ms.

Synopsys workaround:
If the PHY supports direct P3 to P2 transition, program GUSB3PIPECTL.P3P2Tran0K=1.

Therefore, adding p3p2tranok quirk for workaround hibernation D3 exceeded the expected entry time.

---
 drivers/usb/dwc3/core.c | 5 +++++
 drivers/usb/dwc3/core.h | 4 ++++
 2 files changed, 9 insertions(+)
drivers/usb/dwc3/core.c +5 -0
index 7ee61a89520b..3a8fbc2d6b99 100644
@@ -666,6 +666,9 @@ static int dwc3_ss_phy_setup(struct dwc3 *dwc, int index)
 	if (dwc->dis_del_phy_power_chg_quirk)
 		reg &= ~DWC3_GUSB3PIPECTL_DEPOCHANGE;
 
+	if (dwc->p2p3tranok_quirk)
+		reg |= DWC3_GUSB3PIPECTL_P3P2TRANOK;
+
 	dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(index), reg);
 
 	return 0;
@@ -1715,6 +1718,8 @@ static void dwc3_get_properties(struct dwc3 *dwc)
 
 	dwc->dis_split_quirk = device_property_read_bool(dev,
 				"snps,dis-split-quirk");
+	dwc->p2p3tranok_quirk = device_property_read_bool(dev,
+				"snps,p2p3tranok-quirk");
 
 	dwc->lpm_nyet_threshold = lpm_nyet_threshold;
 	dwc->tx_de_emphasis = tx_de_emphasis;
drivers/usb/dwc3/core.h +4 -0
index 3781c736c1a1..2810dce8b42e 100644
@@ -327,6 +327,7 @@
 #define DWC3_GUSB3PIPECTL_DEP1P2P3_EN	DWC3_GUSB3PIPECTL_DEP1P2P3(1)
 #define DWC3_GUSB3PIPECTL_DEPOCHANGE	BIT(18)
 #define DWC3_GUSB3PIPECTL_SUSPHY	BIT(17)
+#define DWC3_GUSB3PIPECTL_P3P2TRANOK	BIT(11)
 #define DWC3_GUSB3PIPECTL_LFPSFILT	BIT(9)
 #define DWC3_GUSB3PIPECTL_RX_DETOPOLL	BIT(8)
 #define DWC3_GUSB3PIPECTL_TX_DEEPH_MASK	DWC3_GUSB3PIPECTL_TX_DEEPH(3)
@@ -1132,6 +1133,8 @@ struct dwc3_scratchpad_array {
  *			instances in park mode.
  * @parkmode_disable_hs_quirk: set if we need to disable all HishSpeed
  *			instances in park mode.
+ * @p2p3tranok_quirk: set if Controller transitions directly from phy
+ *			power state P2 to P3 or from state P3 to P2.
  * @gfladj_refclk_lpm_sel: set if we need to enable SOF/ITP counter
  *                          running based on ref_clk
  * @tx_de_emphasis_quirk: set if we enable Tx de-emphasis quirk
@@ -1361,6 +1364,7 @@ struct dwc3 {
 	unsigned		ulpi_ext_vbus_drv:1;
 	unsigned		parkmode_disable_ss_quirk:1;
 	unsigned		parkmode_disable_hs_quirk:1;
+	unsigned		p2p3tranok_quirk:1;
 	unsigned		gfladj_refclk_lpm_sel:1;
 
 	unsigned		tx_de_emphasis_quirk:1;
Signature · 1 line
2.17.1
maintainer
#7 lore raw
Quoted 3 lines · joswang

From: joswang <[email protected]>

In the case of enable hibernation, there is an issue with

I assume this is for host mode since we currently don't handle hibernation in device mode (please confirm).

Quoted 4 lines

the DWC31 2.00a and earlier versions where the controller link power state transition from P3/P3CPM/P4 to P2 may take longer than expected, ultimately resulting in the hibernation D3 entering time exceeding the expected 10ms.

Can you provide more context where the 10ms requirement is from?

Quoted 5 lines

Synopsys workaround:
If the PHY supports direct P3 to P2 transition, program GUSB3PIPECTL.P3P2Tran0K=1.

Which STAR issue is this?

Quoted 5 lines

Therefore, adding p3p2tranok quirk for workaround hibernation D3 exceeded the expected entry time.

---

Please provide change note for v1->v2 here (and the rest of the other patches).

Quoted 59 lines
 drivers/usb/dwc3/core.c | 5 +++++
 drivers/usb/dwc3/core.h | 4 ++++
 2 files changed, 9 insertions(+)
drivers/usb/dwc3/core.c +5 -0
index 7ee61a89520b..3a8fbc2d6b99 100644
@@ -666,6 +666,9 @@ static int dwc3_ss_phy_setup(struct dwc3 *dwc, int index)
 	if (dwc->dis_del_phy_power_chg_quirk)
 		reg &= ~DWC3_GUSB3PIPECTL_DEPOCHANGE;
 
+	if (dwc->p2p3tranok_quirk)
+		reg |= DWC3_GUSB3PIPECTL_P3P2TRANOK;
+
 	dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(index), reg);
 
 	return 0;
@@ -1715,6 +1718,8 @@ static void dwc3_get_properties(struct dwc3 *dwc)
 
 	dwc->dis_split_quirk = device_property_read_bool(dev,
 				"snps,dis-split-quirk");
+	dwc->p2p3tranok_quirk = device_property_read_bool(dev,
+				"snps,p2p3tranok-quirk");
 
 	dwc->lpm_nyet_threshold = lpm_nyet_threshold;
 	dwc->tx_de_emphasis = tx_de_emphasis;
drivers/usb/dwc3/core.h +4 -0
index 3781c736c1a1..2810dce8b42e 100644
@@ -327,6 +327,7 @@
 #define DWC3_GUSB3PIPECTL_DEP1P2P3_EN	DWC3_GUSB3PIPECTL_DEP1P2P3(1)
 #define DWC3_GUSB3PIPECTL_DEPOCHANGE	BIT(18)
 #define DWC3_GUSB3PIPECTL_SUSPHY	BIT(17)
+#define DWC3_GUSB3PIPECTL_P3P2TRANOK	BIT(11)
 #define DWC3_GUSB3PIPECTL_LFPSFILT	BIT(9)
 #define DWC3_GUSB3PIPECTL_RX_DETOPOLL	BIT(8)
 #define DWC3_GUSB3PIPECTL_TX_DEEPH_MASK	DWC3_GUSB3PIPECTL_TX_DEEPH(3)
@@ -1132,6 +1133,8 @@ struct dwc3_scratchpad_array {
  *			instances in park mode.
  * @parkmode_disable_hs_quirk: set if we need to disable all HishSpeed
  *			instances in park mode.
+ * @p2p3tranok_quirk: set if Controller transitions directly from phy
+ *			power state P2 to P3 or from state P3 to P2.
  * @gfladj_refclk_lpm_sel: set if we need to enable SOF/ITP counter
  *                          running based on ref_clk
  * @tx_de_emphasis_quirk: set if we enable Tx de-emphasis quirk
@@ -1361,6 +1364,7 @@ struct dwc3 {
 	unsigned		ulpi_ext_vbus_drv:1;
 	unsigned		parkmode_disable_ss_quirk:1;
 	unsigned		parkmode_disable_hs_quirk:1;
+	unsigned		p2p3tranok_quirk:1;
 	unsigned		gfladj_refclk_lpm_sel:1;
 
 	unsigned		tx_de_emphasis_quirk:1;
Signature · 1 line
2.17.1

Thanks,
Thinh

author
#8 lore raw
Quoted 8 lines · Thinh Nguyen
Quoted 3 lines · joswang

From: joswang <[email protected]>

In the case of enable hibernation, there is an issue with

I assume this is for host mode since we currently don't handle hibernation in device mode (please confirm).

Yes, your consideration is correct, hibernation is only handled in host mode

Quoted 8 lines
Quoted 5 lines

the DWC31 2.00a and earlier versions where the controller link power state transition from P3/P3CPM/P4 to P2 may take longer than expected, ultimately resulting in the hibernation D3 entering time exceeding the expected 10ms.

Can you provide more context where the 10ms requirement is from?

The P3/P3CPM/P4 to P2 power state change might take longer (maximum 10 ms). If there is an impending D3 entry request, the controller does not respond as long as the power state change is completed causing unnecessary delays in D3 entry.
The above information is provided by your company.
STAR number 4236358

Quoted 7 lines
Quoted 5 lines

Synopsys workaround:
If the PHY supports direct P3 to P2 transition, program GUSB3PIPECTL.P3P2Tran0K=1.

Which STAR issue is this?

This is the solution provided by your company
STAR issue: the DWC31 2.00a and earlier versions where the controller link power state transition from P3/P3CPM/P4 to P2 may take longer than expected.

Quoted 72 lines
Quoted 6 lines

Therefore, adding p3p2tranok quirk for workaround hibernation D3 exceeded the expected entry time.

---

Please provide change note for v1->v2 here (and the rest of the other patches).

Quoted 57 lines
 drivers/usb/dwc3/core.c | 5 +++++
 drivers/usb/dwc3/core.h | 4 ++++
 2 files changed, 9 insertions(+)
drivers/usb/dwc3/core.c +5 -0
index 7ee61a89520b..3a8fbc2d6b99 100644
@@ -666,6 +666,9 @@ static int dwc3_ss_phy_setup(struct dwc3 *dwc, int index)
      if (dwc->dis_del_phy_power_chg_quirk)
              reg &= ~DWC3_GUSB3PIPECTL_DEPOCHANGE;
 
+     if (dwc->p2p3tranok_quirk)
+             reg |= DWC3_GUSB3PIPECTL_P3P2TRANOK;
+
      dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(index), reg);
 
      return 0;
@@ -1715,6 +1718,8 @@ static void dwc3_get_properties(struct dwc3 *dwc)
 
      dwc->dis_split_quirk = device_property_read_bool(dev,
                              "snps,dis-split-quirk");
+     dwc->p2p3tranok_quirk = device_property_read_bool(dev,
+                             "snps,p2p3tranok-quirk");
 
      dwc->lpm_nyet_threshold = lpm_nyet_threshold;
      dwc->tx_de_emphasis = tx_de_emphasis;
drivers/usb/dwc3/core.h +4 -1
index 3781c736c1a1..2810dce8b42e 100644
@@ -327,6 +327,7 @@
 #define DWC3_GUSB3PIPECTL_DEP1P2P3_EN        DWC3_GUSB3PIPECTL_DEP1P2P3(1)
 #define DWC3_GUSB3PIPECTL_DEPOCHANGE BIT(18)
 #define DWC3_GUSB3PIPECTL_SUSPHY     BIT(17)
+#define DWC3_GUSB3PIPECTL_P3P2TRANOK BIT(11)
 #define DWC3_GUSB3PIPECTL_LFPSFILT   BIT(9)
 #define DWC3_GUSB3PIPECTL_RX_DETOPOLL        BIT(8)
 #define DWC3_GUSB3PIPECTL_TX_DEEPH_MASK      DWC3_GUSB3PIPECTL_TX_DEEPH(3)
@@ -1132,6 +1133,8 @@ struct dwc3_scratchpad_array {
  *                   instances in park mode.
  * @parkmode_disable_hs_quirk: set if we need to disable all HishSpeed
  *                   instances in park mode.
+ * @p2p3tranok_quirk: set if Controller transitions directly from phy
+ *                   power state P2 to P3 or from state P3 to P2.
  * @gfladj_refclk_lpm_sel: set if we need to enable SOF/ITP counter
  *                          running based on ref_clk
  * @tx_de_emphasis_quirk: set if we enable Tx de-emphasis quirk
@@ -1361,6 +1364,7 @@ struct dwc3 {
      unsigned                ulpi_ext_vbus_drv:1;
      unsigned                parkmode_disable_ss_quirk:1;
      unsigned                parkmode_disable_hs_quirk:1;
+     unsigned                p2p3tranok_quirk:1;
      unsigned                gfladj_refclk_lpm_sel:1;
 
      unsigned                tx_de_emphasis_quirk:1;
--
Quoted 2 lines

2.17.1

Thanks,
Thinh

author
#9 lore raw
In reply to Thinh Nguyen
Quoted 88 lines · Thinh Nguyen
Quoted 3 lines · joswang

From: joswang <[email protected]>

In the case of enable hibernation, there is an issue with

I assume this is for host mode since we currently don't handle hibernation in device mode (please confirm).

Quoted 4 lines

the DWC31 2.00a and earlier versions where the controller link power state transition from P3/P3CPM/P4 to P2 may take longer than expected, ultimately resulting in the hibernation D3 entering time exceeding the expected 10ms.

Can you provide more context where the 10ms requirement is from?

Quoted 5 lines

Synopsys workaround:
If the PHY supports direct P3 to P2 transition, program GUSB3PIPECTL.P3P2Tran0K=1.

Which STAR issue is this?

Quoted 5 lines

Therefore, adding p3p2tranok quirk for workaround hibernation D3 exceeded the expected entry time.

---

Please provide change note for v1->v2 here (and the rest of the other patches).

Quoted 55 lines
 drivers/usb/dwc3/core.c | 5 +++++
 drivers/usb/dwc3/core.h | 4 ++++
 2 files changed, 9 insertions(+)
drivers/usb/dwc3/core.c +5 -0
index 7ee61a89520b..3a8fbc2d6b99 100644
@@ -666,6 +666,9 @@ static int dwc3_ss_phy_setup(struct dwc3 *dwc, int index)
      if (dwc->dis_del_phy_power_chg_quirk)
              reg &= ~DWC3_GUSB3PIPECTL_DEPOCHANGE;
 
+     if (dwc->p2p3tranok_quirk)
+             reg |= DWC3_GUSB3PIPECTL_P3P2TRANOK;
+
      dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(index), reg);
 
      return 0;
@@ -1715,6 +1718,8 @@ static void dwc3_get_properties(struct dwc3 *dwc)
 
      dwc->dis_split_quirk = device_property_read_bool(dev,
                              "snps,dis-split-quirk");
+     dwc->p2p3tranok_quirk = device_property_read_bool(dev,
+                             "snps,p2p3tranok-quirk");
 
      dwc->lpm_nyet_threshold = lpm_nyet_threshold;
      dwc->tx_de_emphasis = tx_de_emphasis;
drivers/usb/dwc3/core.h +4 -0
index 3781c736c1a1..2810dce8b42e 100644
@@ -327,6 +327,7 @@
 #define DWC3_GUSB3PIPECTL_DEP1P2P3_EN        DWC3_GUSB3PIPECTL_DEP1P2P3(1)
 #define DWC3_GUSB3PIPECTL_DEPOCHANGE BIT(18)
 #define DWC3_GUSB3PIPECTL_SUSPHY     BIT(17)
+#define DWC3_GUSB3PIPECTL_P3P2TRANOK BIT(11)
 #define DWC3_GUSB3PIPECTL_LFPSFILT   BIT(9)
 #define DWC3_GUSB3PIPECTL_RX_DETOPOLL        BIT(8)
 #define DWC3_GUSB3PIPECTL_TX_DEEPH_MASK      DWC3_GUSB3PIPECTL_TX_DEEPH(3)
@@ -1132,6 +1133,8 @@ struct dwc3_scratchpad_array {
  *                   instances in park mode.
  * @parkmode_disable_hs_quirk: set if we need to disable all HishSpeed
  *                   instances in park mode.
+ * @p2p3tranok_quirk: set if Controller transitions directly from phy
+ *                   power state P2 to P3 or from state P3 to P2.
  * @gfladj_refclk_lpm_sel: set if we need to enable SOF/ITP counter
  *                          running based on ref_clk
  * @tx_de_emphasis_quirk: set if we enable Tx de-emphasis quirk
@@ -1361,6 +1364,7 @@ struct dwc3 {
      unsigned                ulpi_ext_vbus_drv:1;
      unsigned                parkmode_disable_ss_quirk:1;
      unsigned                parkmode_disable_hs_quirk:1;
+     unsigned                p2p3tranok_quirk:1;
      unsigned                gfladj_refclk_lpm_sel:1;
 
Quoted 7 lines
Quoted 4 lines
drivers/usb/dwc3/core.h +0 -1
      unsigned                tx_de_emphasis_quirk:1;
--

2.17.1

Thanks,
Thinh

Difference between V2 and V1: This patch has no changes, only the "dt-bindings: usb: dwc3: Add snps,p2p3tranok quirk" patch is added.

Thanks
Jos Wang

author
#10 lore raw
In reply to Thinh Nguyen

Hi Thinh

The workaround solution provided by your company for this issue is as follows:
Workaround:if the phy support direct P3 to P2 transition,program
GUSB3PIPECTL.P3P2Tranok=1

As the databook mentions:
This bit is used only for some non-Synopsys PHYs that cannot do LFPS in P3. This bit is used by third-party SS PHY. It must be set to '0' for Synopsys PHY.

For Synopsys PHY, if this bit is set to "1", will it cause unknown problems? Please help confirm this, thank you!

Thanks,
Jos Wang

maintainer
#11 lore raw

Sorry for the delay response regarding this.

Quoted 6 lines · joswang

Hi Thinh

The workaround solution provided by your company for this issue is as follows:
Workaround:if the phy support direct P3 to P2 transition,program
GUSB3PIPECTL.P3P2Tranok=1

Quoted 7 lines

As the databook mentions:
This bit is used only for some non-Synopsys PHYs that cannot do LFPS in P3. This bit is used by third-party SS PHY. It must be set to '0' for Synopsys PHY.

For Synopsys PHY, if this bit is set to "1", will it cause unknown problems? Please help confirm this, thank you!

That depends on what your use case and requirements are.

I've reviewed this case. The impact to this issue is that power state change may take longer than expected. It may violate the PIPE spec, but functionally, at least for how linux drivers are handled, I'm not clear on how this will impact the typical user.

Can you help clarify your use case and what does this resolve beside the fact that it workaround the increase latency/response time.

Thanks,
Thinh

author
#12 lore raw
Quoted 25 lines · Thinh Nguyen

Sorry for the delay response regarding this.

Quoted 6 lines · joswang

Hi Thinh

The workaround solution provided by your company for this issue is as follows:
Workaround:if the phy support direct P3 to P2 transition,program
GUSB3PIPECTL.P3P2Tranok=1

Quoted 7 lines

As the databook mentions:
This bit is used only for some non-Synopsys PHYs that cannot do LFPS in P3. This bit is used by third-party SS PHY. It must be set to '0' for Synopsys PHY.

For Synopsys PHY, if this bit is set to "1", will it cause unknown problems? Please help confirm this, thank you!

That depends on what your use case and requirements are.

I've reviewed this case. The impact to this issue is that power state change may take longer than expected. It may violate the PIPE spec, but functionally, at least for how linux drivers are handled, I'm not clear on how this will impact the typical user.

Quoted 5 lines

Can you help clarify your use case and what does this resolve beside the fact that it workaround the increase latency/response time.

Thanks,
Thinh

Your company provides usage scenarios:
System software places the controller in low-power when there is no traffic on the USB.
Subsequently, system software programs the controller to exit low-power to resume traffic.

The method to reproduce the problem provided by your company:
1. Program the DWC_usb31 controller to operate in device mode of operation. Program GUSB3PIPECTL.P3P2TranOK=0. To increase the probability of hitting the problem run with a slower frequency for suspend_clk (for example, 32 KHz and 160 KHz).
2. Place the link in U3 while ensuring that pipe_powerdown is driven to P3.
3. Program DWC_usb31 controller to exit U3. Ensure that for P0 ->P2 transition pipe_PhyStatus is returned immediately.
4. Program U3 exit from the remote link.
5. Program a D3 entry (pm_power_state_request=D3) at the same time (from the device application) and observe if the D3 entry acknowledgement (current_power_state_u3pmu=D3) takes longer than expected (> 10 ms).

Currently, we do not have a real environment to verify this case, but considering the Android GKI regulations, we need to submit patches to Linux in advance. Based on the following workaround solution provided by your company,since the hardware cannot be changed, we can only use workaround 1 at present.
Workaround 1: If the PHY supports direct P3 to P2 transition, program GUSB3PIPECTL.P3P2TranOK=1. However, note that as per PIPE4 Specification, direct transition from P3 to P2 is illegal. Workaround 2: Delay the pipe_PhyStatus assertion by an amount greater than two suspend_clk durations at the input of the controller's PIPE interface.

We have the following questions and hope you can help us confirm them. Thank you!
1. This case seems to describe that the P3 to P2 power state change takes a long time, that is, the DWC3_usb31 controller takes a long time to exit the D3 state. Please help evaluate whether this problem is perceived from the software perspective, such as whether there is a problem in the xhci_suspend or xhci_resume process. If from the software perspective, this case will not cause the xhci driver to fail, then we may not deal with this problem.
2. If this case causes the above problem, for Synopsys PHY, configuring GUSB3PIPECTL.P3P2TranOK=1 will cause other unknown problems?

maintainer
#13 lore raw

Hi Joswang,

Quoted 64 lines · joswang
Quoted 25 lines · Thinh Nguyen

Sorry for the delay response regarding this.

Quoted 6 lines · joswang

Hi Thinh

The workaround solution provided by your company for this issue is as follows:
Workaround:if the phy support direct P3 to P2 transition,program
GUSB3PIPECTL.P3P2Tranok=1

Quoted 7 lines

As the databook mentions:
This bit is used only for some non-Synopsys PHYs that cannot do LFPS in P3. This bit is used by third-party SS PHY. It must be set to '0' for Synopsys PHY.

For Synopsys PHY, if this bit is set to "1", will it cause unknown problems? Please help confirm this, thank you!

That depends on what your use case and requirements are.

I've reviewed this case. The impact to this issue is that power state change may take longer than expected. It may violate the PIPE spec, but functionally, at least for how linux drivers are handled, I'm not clear on how this will impact the typical user.

Quoted 5 lines

Can you help clarify your use case and what does this resolve beside the fact that it workaround the increase latency/response time.

Thanks,
Thinh

Your company provides usage scenarios:
System software places the controller in low-power when there is no traffic on the USB.
Subsequently, system software programs the controller to exit low-power to resume traffic.

The method to reproduce the problem provided by your company:
1. Program the DWC_usb31 controller to operate in device mode of operation. Program GUSB3PIPECTL.P3P2TranOK=0. To increase the probability of hitting the problem run with a slower frequency for suspend_clk (for example, 32 KHz and 160 KHz).
2. Place the link in U3 while ensuring that pipe_powerdown is driven to P3.
3. Program DWC_usb31 controller to exit U3. Ensure that for P0 ->P2 transition pipe_PhyStatus is returned immediately.
4. Program U3 exit from the remote link.
5. Program a D3 entry (pm_power_state_request=D3) at the same time (from the device application) and observe if the D3 entry acknowledgement (current_power_state_u3pmu=D3) takes longer than expected (> 10 ms).

Currently, we do not have a real environment to verify this case, but considering the Android GKI regulations, we need to submit patches to Linux in advance. Based on the following workaround solution provided by your company,since the hardware cannot be changed, we can only use workaround 1 at present.
Workaround 1: If the PHY supports direct P3 to P2 transition, program GUSB3PIPECTL.P3P2TranOK=1. However, note that as per PIPE4 Specification, direct transition from P3 to P2 is illegal. Workaround 2: Delay the pipe_PhyStatus assertion by an amount greater than two suspend_clk durations at the input of the controller's PIPE interface.

Quoted 12 lines

We have the following questions and hope you can help us confirm them. Thank you!
1. This case seems to describe that the P3 to P2 power state change takes a long time, that is, the DWC3_usb31 controller takes a long time to exit the D3 state. Please help evaluate whether this problem is perceived from the software perspective, such as whether there is a problem in the xhci_suspend or xhci_resume process. If from the software perspective, this case will not cause the xhci driver to fail, then we may not deal with this problem.
2. If this case causes the above problem, for Synopsys PHY, configuring GUSB3PIPECTL.P3P2TranOK=1 will cause other unknown problems?

For this to occur, the host must try to transition from P3 to P2, and somehow goes into suspend and request for D3 immediately, which causes D3 request to take longer than expected.

This is not something we would expect for xhci, because:
1) On xhci_resume(), we would expect the pci device to be powered on (D0). So it would not be in a condition for this issue to occur.
2) xhci_resume() takes some time restore the host controller states and reinitialize the registers and start the controller. Then xhci_suspend() also takes some time to save the states and halt the controller. So there's some time before the pci driver can send a D3 request. I don't know how long your setup may take, but it's unlikely to hit this condition.

Even if we do somehow manage to run into this scenario, we can set a pci quirk to increase pci_pm_d3hot_delay to increase the suspend/resume timeout, avoid hitting this.

Unfortunately we don't have the real environment to verify this. But IMHO, for a typical use case, I don't see the need to introduce this "snps,p2p3tranok-quirk".

BR,
Thinh

author
#14 lore raw

Thank you for your feedback. We will not deal with this issue after internal discussion.
Thank you again for taking the time to review the code.

Thanks,
Jos Wang

Quoted 105 lines · Thinh Nguyen

Hi Joswang,

Quoted 64 lines · joswang
Quoted 25 lines · Thinh Nguyen

Sorry for the delay response regarding this.

Quoted 6 lines · joswang

Hi Thinh

The workaround solution provided by your company for this issue is as follows:
Workaround:if the phy support direct P3 to P2 transition,program
GUSB3PIPECTL.P3P2Tranok=1

Quoted 7 lines

As the databook mentions:
This bit is used only for some non-Synopsys PHYs that cannot do LFPS in P3. This bit is used by third-party SS PHY. It must be set to '0' for Synopsys PHY.

For Synopsys PHY, if this bit is set to "1", will it cause unknown problems? Please help confirm this, thank you!

That depends on what your use case and requirements are.

I've reviewed this case. The impact to this issue is that power state change may take longer than expected. It may violate the PIPE spec, but functionally, at least for how linux drivers are handled, I'm not clear on how this will impact the typical user.

Quoted 5 lines

Can you help clarify your use case and what does this resolve beside the fact that it workaround the increase latency/response time.

Thanks,
Thinh

Your company provides usage scenarios:
System software places the controller in low-power when there is no traffic on the USB.
Subsequently, system software programs the controller to exit low-power to resume traffic.

The method to reproduce the problem provided by your company:
1. Program the DWC_usb31 controller to operate in device mode of operation. Program GUSB3PIPECTL.P3P2TranOK=0. To increase the probability of hitting the problem run with a slower frequency for suspend_clk (for example, 32 KHz and 160 KHz).
2. Place the link in U3 while ensuring that pipe_powerdown is driven to P3.
3. Program DWC_usb31 controller to exit U3. Ensure that for P0 ->P2 transition pipe_PhyStatus is returned immediately.
4. Program U3 exit from the remote link.
5. Program a D3 entry (pm_power_state_request=D3) at the same time (from the device application) and observe if the D3 entry acknowledgement (current_power_state_u3pmu=D3) takes longer than expected (> 10 ms).

Currently, we do not have a real environment to verify this case, but considering the Android GKI regulations, we need to submit patches to Linux in advance. Based on the following workaround solution provided by your company,since the hardware cannot be changed, we can only use workaround 1 at present.
Workaround 1: If the PHY supports direct P3 to P2 transition, program GUSB3PIPECTL.P3P2TranOK=1. However, note that as per PIPE4 Specification, direct transition from P3 to P2 is illegal. Workaround 2: Delay the pipe_PhyStatus assertion by an amount greater than two suspend_clk durations at the input of the controller's PIPE interface.

Quoted 12 lines

We have the following questions and hope you can help us confirm them. Thank you!
1. This case seems to describe that the P3 to P2 power state change takes a long time, that is, the DWC3_usb31 controller takes a long time to exit the D3 state. Please help evaluate whether this problem is perceived from the software perspective, such as whether there is a problem in the xhci_suspend or xhci_resume process. If from the software perspective, this case will not cause the xhci driver to fail, then we may not deal with this problem.
2. If this case causes the above problem, for Synopsys PHY, configuring GUSB3PIPECTL.P3P2TranOK=1 will cause other unknown problems?

For this to occur, the host must try to transition from P3 to P2, and somehow goes into suspend and request for D3 immediately, which causes D3 request to take longer than expected.

This is not something we would expect for xhci, because:
1) On xhci_resume(), we would expect the pci device to be powered on (D0). So it would not be in a condition for this issue to occur.
2) xhci_resume() takes some time restore the host controller states and reinitialize the registers and start the controller. Then xhci_suspend() also takes some time to save the states and halt the controller. So there's some time before the pci driver can send a D3 request. I don't know how long your setup may take, but it's unlikely to hit this condition.

Even if we do somehow manage to run into this scenario, we can set a pci quirk to increase pci_pm_d3hot_delay to increase the suspend/resume timeout, avoid hitting this.

Unfortunately we don't have the real environment to verify this. But IMHO, for a typical use case, I don't see the need to introduce this "snps,p2p3tranok-quirk".

BR,
Thinh

author
#15 lore raw

PATCH v2 3/3 usb: dwc3: core: Workaround for CSR read timeout

In reply to joswang

From: joswang <[email protected]>

DWC31 version 2.00a have an issue that would cause a CSR read timeout When CSR read coincides with RAM Clock Gating Entry.

This workaround solution disable Clock Gating, sacrificing power consumption for normal operation.

---
 drivers/usb/dwc3/core.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
drivers/usb/dwc3/core.c +23 -0
index 3a8fbc2d6b99..1df85c505c9e 100644
@@ -978,11 +978,22 @@ static void dwc3_core_setup_global_control(struct dwc3 *dwc)
 		 *
 		 * STAR#9000588375: Clock Gating, SOF Issues when ref_clk-Based
 		 * SOF/ITP Mode Used
+		 *
+		 * WORKAROUND: DWC31 version 2.00a have an issue that would
+		 * cause a CSR read timeout When CSR read coincides with RAM
+		 * Clock Gating Entry.
+		 *
+		 * This workaround solution disable Clock Gating, sacrificing
+		 * power consumption for normal operation.
 		 */
 		if ((dwc->dr_mode == USB_DR_MODE_HOST ||
 				dwc->dr_mode == USB_DR_MODE_OTG) &&
 				DWC3_VER_IS_WITHIN(DWC3, 210A, 250A))
 			reg |= DWC3_GCTL_DSBLCLKGTNG | DWC3_GCTL_SOFITPSYNC;
+		else if ((dwc->dr_mode == USB_DR_MODE_HOST ||
+				dwc->dr_mode == USB_DR_MODE_OTG) &&
+				DWC3_VER_IS(DWC31, 200A))
+			reg |= DWC3_GCTL_DSBLCLKGTNG;
 		else
 			reg &= ~DWC3_GCTL_DSBLCLKGTNG;
 		break;
@@ -992,6 +1003,18 @@ static void dwc3_core_setup_global_control(struct dwc3 *dwc)
 		 * will work. Device-mode hibernation is not yet implemented.
 		 */
 		reg |= DWC3_GCTL_GBLHIBERNATIONEN;
+
+		/*
+		 * WORKAROUND: DWC31 version 2.00a have an issue that would
+		 * cause a CSR read timeout When CSR read coincides with RAM
+		 * Clock Gating Entry.
+		 *
+		 * This workaround solution disable Clock Gating, sacrificing
+		 * power consumption for normal operation.
+		 */
+		if ((dwc->dr_mode == USB_DR_MODE_HOST ||
+		     dwc->dr_mode == USB_DR_MODE_OTG) && DWC3_VER_IS(DWC31, 200A))
+			reg |= DWC3_GCTL_DSBLCLKGTNG;
 		break;
 	default:
 		/* nothing */
Signature · 1 line
2.17.1
maintainer
#16 lore raw

Re: [PATCH v2, 3/3] usb: dwc3: core: Workaround for CSR read timeout

Quoted 5 lines · joswang

From: joswang <[email protected]>

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?

Quoted 58 lines

This workaround solution disable Clock Gating, sacrificing power consumption for normal operation.

---
 drivers/usb/dwc3/core.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
drivers/usb/dwc3/core.c +23 -0
index 3a8fbc2d6b99..1df85c505c9e 100644
@@ -978,11 +978,22 @@ static void dwc3_core_setup_global_control(struct dwc3 *dwc)
 		 *
 		 * STAR#9000588375: Clock Gating, SOF Issues when ref_clk-Based
 		 * SOF/ITP Mode Used
+		 *
+		 * WORKAROUND: DWC31 version 2.00a have an issue that would
+		 * cause a CSR read timeout When CSR read coincides with RAM
+		 * Clock Gating Entry.
+		 *
+		 * This workaround solution disable Clock Gating, sacrificing
+		 * power consumption for normal operation.
 		 */
 		if ((dwc->dr_mode == USB_DR_MODE_HOST ||
 				dwc->dr_mode == USB_DR_MODE_OTG) &&
 				DWC3_VER_IS_WITHIN(DWC3, 210A, 250A))
 			reg |= DWC3_GCTL_DSBLCLKGTNG | DWC3_GCTL_SOFITPSYNC;
+		else if ((dwc->dr_mode == USB_DR_MODE_HOST ||
+				dwc->dr_mode == USB_DR_MODE_OTG) &&
+				DWC3_VER_IS(DWC31, 200A))
+			reg |= DWC3_GCTL_DSBLCLKGTNG;
 		else
 			reg &= ~DWC3_GCTL_DSBLCLKGTNG;
 		break;
@@ -992,6 +1003,18 @@ static void dwc3_core_setup_global_control(struct dwc3 *dwc)
 		 * will work. Device-mode hibernation is not yet implemented.
 		 */
 		reg |= DWC3_GCTL_GBLHIBERNATIONEN;
+
+		/*
+		 * WORKAROUND: DWC31 version 2.00a have an issue that would
+		 * cause a CSR read timeout When CSR read coincides with RAM
+		 * Clock Gating Entry.
+		 *
+		 * This workaround solution disable Clock Gating, sacrificing
+		 * power consumption for normal operation.
+		 */
+		if ((dwc->dr_mode == USB_DR_MODE_HOST ||
+		     dwc->dr_mode == USB_DR_MODE_OTG) && DWC3_VER_IS(DWC31, 200A))
+			reg |= DWC3_GCTL_DSBLCLKGTNG;
 		break;
 	default:
 		/* nothing */
Signature · 1 line
2.17.1

This doesn't seem like it should be applied globally. Please provide the STAR number if you can so I can review further. If possible I'd prefer to only target your platform.

Thanks,
Thinh

author
#17 lore raw

Re: [PATCH v2, 3/3] usb: dwc3: core: Workaround for CSR read timeout

Quoted 10 lines · Thinh Nguyen
Quoted 5 lines · joswang

From: joswang <[email protected]>

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.

Quoted 54 lines
Quoted 54 lines

This workaround solution disable Clock Gating, sacrificing power consumption for normal operation.

---
 drivers/usb/dwc3/core.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
drivers/usb/dwc3/core.c +23 -0
index 3a8fbc2d6b99..1df85c505c9e 100644
@@ -978,11 +978,22 @@ static void dwc3_core_setup_global_control(struct dwc3 *dwc)
               *
               * STAR#9000588375: Clock Gating, SOF Issues when ref_clk-Based
               * SOF/ITP Mode Used
+              *
+              * WORKAROUND: DWC31 version 2.00a have an issue that would
+              * cause a CSR read timeout When CSR read coincides with RAM
+              * Clock Gating Entry.
+              *
+              * This workaround solution disable Clock Gating, sacrificing
+              * power consumption for normal operation.
               */
              if ((dwc->dr_mode == USB_DR_MODE_HOST ||
                              dwc->dr_mode == USB_DR_MODE_OTG) &&
                              DWC3_VER_IS_WITHIN(DWC3, 210A, 250A))
                      reg |= DWC3_GCTL_DSBLCLKGTNG | DWC3_GCTL_SOFITPSYNC;
+             else if ((dwc->dr_mode == USB_DR_MODE_HOST ||
+                             dwc->dr_mode == USB_DR_MODE_OTG) &&
+                             DWC3_VER_IS(DWC31, 200A))
+                     reg |= DWC3_GCTL_DSBLCLKGTNG;
              else
                      reg &= ~DWC3_GCTL_DSBLCLKGTNG;
              break;
@@ -992,6 +1003,18 @@ static void dwc3_core_setup_global_control(struct dwc3 *dwc)
               * will work. Device-mode hibernation is not yet implemented.
               */
              reg |= DWC3_GCTL_GBLHIBERNATIONEN;
+
+             /*
+              * WORKAROUND: DWC31 version 2.00a have an issue that would
+              * cause a CSR read timeout When CSR read coincides with RAM
+              * Clock Gating Entry.
+              *
+              * This workaround solution disable Clock Gating, sacrificing
+              * power consumption for normal operation.
+              */
+             if ((dwc->dr_mode == USB_DR_MODE_HOST ||
+                  dwc->dr_mode == USB_DR_MODE_OTG) && DWC3_VER_IS(DWC31, 200A))
+                     reg |= DWC3_GCTL_DSBLCLKGTNG;
              break;
      default:
Quoted 9 lines
Quoted 4 lines
drivers/usb/dwc3/core.c +0 -1
              /* nothing */
--

2.17.1

This doesn't seem like it should be applied globally. Please provide the STAR number if you can so I can review further. If possible I'd prefer to only target your platform.

Best Regards,
Jos Wang

Quoted 2 lines

Thanks,
Thinh

maintainer
#18 lore raw

Re: [PATCH v2, 3/3] usb: dwc3: core: Workaround for CSR read timeout

Quoted 9 lines · joswang
Quoted 8 lines · Thinh Nguyen
Quoted 5 lines · joswang

From: joswang <[email protected]>

DWC31 version 2.00a have an issue that would cause a CSR read timeout When CSR read coincides with RAM Clock Gating Entry.

Quoted 6 lines
Quoted 2 lines

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'll get back on this. Please also provide the STAR for the other case.

Thanks,
Thinh

maintainer
#19 lore raw

Re: [PATCH v2, 3/3] usb: dwc3: core: Workaround for CSR read timeout

In reply to joswang
Quoted 9 lines · joswang
Quoted 8 lines · Thinh Nguyen
Quoted 5 lines · joswang

From: joswang <[email protected]>

DWC31 version 2.00a have an issue that would cause a CSR read timeout When CSR read coincides with RAM Clock Gating Entry.

Quoted 5 lines
Quoted 2 lines

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.

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

This workaround solution disable Clock Gating, sacrificing power consumption for normal operation.

---
 drivers/usb/dwc3/core.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
Quoted 8 lines
Quoted 8 lines

drivers/usb/dwc3/core.c static void dwc3_core_setup_global_control(struct dwc3 *dwc) · line 980

Quoted 8 lines
drivers/usb/dwc3/core.c +0 -0
index 3a8fbc2d6b99..1df85c505c9e 100644
@@ -978,11 +978,22 @@ static void dwc3_core_setup_global_control(struct 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.

Quoted 2 lines
Quoted 2 lines

drivers/usb/dwc3/core.c static void dwc3_core_setup_global_control(struct dwc3 *dwc) · line 982

Quoted 2 lines
drivers/usb/dwc3/core.c +2 -0
+              *
+              * WORKAROUND: DWC31 version 2.00a have an issue that would

Can we use the full name DWC_usb31 instead of DWC31.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/usb/dwc3/core.c +4 -0
+              * cause a CSR read timeout When CSR read coincides with RAM
+              * Clock Gating Entry.
+              *
+              * This workaround solution disable Clock Gating, sacrificing
Quoted 8 lines
Quoted 8 lines

drivers/usb/dwc3/core.c static void dwc3_core_setup_global_control(struct dwc3 *dwc) · line 994

Quoted 8 lines
drivers/usb/dwc3/core.c +3 -0
+              * power consumption for normal operation.
               */
              if ((dwc->dr_mode == USB_DR_MODE_HOST ||
                              dwc->dr_mode == USB_DR_MODE_OTG) &&
                              DWC3_VER_IS_WITHIN(DWC3, 210A, 250A))
                      reg |= DWC3_GCTL_DSBLCLKGTNG | DWC3_GCTL_SOFITPSYNC;
+             else if ((dwc->dr_mode == USB_DR_MODE_HOST ||
+                             dwc->dr_mode == 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.

Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
drivers/usb/dwc3/core.c +13 -0
+                             DWC3_VER_IS(DWC31, 200A))
+                     reg |= DWC3_GCTL_DSBLCLKGTNG;
              else
                      reg &= ~DWC3_GCTL_DSBLCLKGTNG;
              break;
@@ -992,6 +1003,18 @@ static void dwc3_core_setup_global_control(struct dwc3 *dwc)
               * will work. Device-mode hibernation is not yet implemented.
               */
              reg |= DWC3_GCTL_GBLHIBERNATIONEN;
+
+             /*
+              * WORKAROUND: DWC31 version 2.00a have an issue that would
+              * cause a CSR read timeout When CSR read coincides with RAM
+              * Clock Gating Entry.
+              *
+              * This workaround solution disable Clock Gating, sacrificing
+              * power consumption for normal operation.
+              */
+             if ((dwc->dr_mode == USB_DR_MODE_HOST ||
+                  dwc->dr_mode == USB_DR_MODE_OTG) && DWC3_VER_IS(DWC31, 200A))
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
drivers/usb/dwc3/core.c +1 -1
+                     reg |= 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 = DWC3_GHWPARAMS1_EN_PWROPT(dwc->hwparams.hwparams1);

switch (power_opt) {
    ...
}

/*
* <comment>
*/
if (power_opt != DWC3_GHWPARAMS1_EN_PWROPT_NO) {
}

Thanks,
Thinh

author
#20 lore raw

Re: [PATCH v2, 3/3] usb: dwc3: core: Workaround for CSR read timeout

Quoted 30 lines · Thinh Nguyen
Quoted 9 lines · joswang
Quoted 8 lines · Thinh Nguyen
Quoted 5 lines · joswang

From: joswang <[email protected]>

DWC31 version 2.00a have an issue that would cause a CSR read timeout When CSR read coincides with RAM Clock Gating Entry.

Quoted 5 lines
Quoted 2 lines

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.

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

This workaround solution disable Clock Gating, sacrificing power consumption for normal operation.

---
 drivers/usb/dwc3/core.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
Quoted 12 lines
Quoted 8 lines
Quoted 8 lines

drivers/usb/dwc3/core.c static void dwc3_core_setup_global_control(struct dwc3 *dwc) · line 980

Quoted 8 lines
drivers/usb/dwc3/core.c +0 -0
index 3a8fbc2d6b99..1df85c505c9e 100644
@@ -978,11 +978,22 @@ static void dwc3_core_setup_global_control(struct 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

Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

drivers/usb/dwc3/core.c static void dwc3_core_setup_global_control(struct dwc3 *dwc) · line 982

Quoted 2 lines
drivers/usb/dwc3/core.c +2 -0
+              *
+              * 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

Quoted 60 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/usb/dwc3/core.c +4 -0
+              * cause a CSR read timeout When CSR read coincides with RAM
+              * Clock Gating Entry.
+              *
+              * This workaround solution disable Clock Gating, sacrificing
Quoted 8 lines
Quoted 8 lines

drivers/usb/dwc3/core.c static void dwc3_core_setup_global_control(struct dwc3 *dwc) · line 994

Quoted 8 lines
drivers/usb/dwc3/core.c +3 -0
+              * power consumption for normal operation.
               */
              if ((dwc->dr_mode == USB_DR_MODE_HOST ||
                              dwc->dr_mode == USB_DR_MODE_OTG) &&
                              DWC3_VER_IS_WITHIN(DWC3, 210A, 250A))
                      reg |= DWC3_GCTL_DSBLCLKGTNG | DWC3_GCTL_SOFITPSYNC;
+             else if ((dwc->dr_mode == USB_DR_MODE_HOST ||
+                             dwc->dr_mode == 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.

Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
drivers/usb/dwc3/core.c +13 -0
+                             DWC3_VER_IS(DWC31, 200A))
+                     reg |= DWC3_GCTL_DSBLCLKGTNG;
              else
                      reg &= ~DWC3_GCTL_DSBLCLKGTNG;
              break;
@@ -992,6 +1003,18 @@ static void dwc3_core_setup_global_control(struct dwc3 *dwc)
               * will work. Device-mode hibernation is not yet implemented.
               */
              reg |= DWC3_GCTL_GBLHIBERNATIONEN;
+
+             /*
+              * WORKAROUND: DWC31 version 2.00a have an issue that would
+              * cause a CSR read timeout When CSR read coincides with RAM
+              * Clock Gating Entry.
+              *
+              * This workaround solution disable Clock Gating, sacrificing
+              * power consumption for normal operation.
+              */
+             if ((dwc->dr_mode == USB_DR_MODE_HOST ||
+                  dwc->dr_mode == USB_DR_MODE_OTG) && DWC3_VER_IS(DWC31, 200A))
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
drivers/usb/dwc3/core.c +1 -1
+                     reg |= 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 = DWC3_GHWPARAMS1_EN_PWROPT(dwc->hwparams.hwparams1);

switch (power_opt) {
    ...
}

/*
* <comment>
*/
if (power_opt != DWC3_GHWPARAMS1_EN_PWROPT_NO) {
}

Quoted 2 lines

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

maintainer
#21 lore raw

Re: [PATCH v2, 3/3] usb: dwc3: core: Workaround for CSR read timeout

Quoted 110 lines · joswang
Quoted 30 lines · Thinh Nguyen
Quoted 9 lines · joswang
Quoted 8 lines · Thinh Nguyen
Quoted 5 lines · joswang

From: joswang <[email protected]>

DWC31 version 2.00a have an issue that would cause a CSR read timeout When CSR read coincides with RAM Clock Gating Entry.

Quoted 5 lines
Quoted 2 lines

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.

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

This workaround solution disable Clock Gating, sacrificing power consumption for normal operation.

---
 drivers/usb/dwc3/core.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
Quoted 12 lines
Quoted 8 lines
Quoted 8 lines

drivers/usb/dwc3/core.c static void dwc3_core_setup_global_control(struct dwc3 *dwc) · line 980

Quoted 8 lines
drivers/usb/dwc3/core.c +0 -0
index 3a8fbc2d6b99..1df85c505c9e 100644
@@ -978,11 +978,22 @@ static void dwc3_core_setup_global_control(struct 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

Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

drivers/usb/dwc3/core.c static void dwc3_core_setup_global_control(struct dwc3 *dwc) · line 982

Quoted 2 lines
drivers/usb/dwc3/core.c +2 -0
+              *
+              * 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

Quoted 60 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/usb/dwc3/core.c +4 -0
+              * cause a CSR read timeout When CSR read coincides with RAM
+              * Clock Gating Entry.
+              *
+              * This workaround solution disable Clock Gating, sacrificing
Quoted 8 lines
Quoted 8 lines

drivers/usb/dwc3/core.c static void dwc3_core_setup_global_control(struct dwc3 *dwc) · line 994

Quoted 8 lines
drivers/usb/dwc3/core.c +3 -0
+              * power consumption for normal operation.
               */
              if ((dwc->dr_mode == USB_DR_MODE_HOST ||
                              dwc->dr_mode == USB_DR_MODE_OTG) &&
                              DWC3_VER_IS_WITHIN(DWC3, 210A, 250A))
                      reg |= DWC3_GCTL_DSBLCLKGTNG | DWC3_GCTL_SOFITPSYNC;
+             else if ((dwc->dr_mode == USB_DR_MODE_HOST ||
+                             dwc->dr_mode == 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.

Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
drivers/usb/dwc3/core.c +13 -0
+                             DWC3_VER_IS(DWC31, 200A))
+                     reg |= DWC3_GCTL_DSBLCLKGTNG;
              else
                      reg &= ~DWC3_GCTL_DSBLCLKGTNG;
              break;
@@ -992,6 +1003,18 @@ static void dwc3_core_setup_global_control(struct dwc3 *dwc)
               * will work. Device-mode hibernation is not yet implemented.
               */
              reg |= DWC3_GCTL_GBLHIBERNATIONEN;
+
+             /*
+              * WORKAROUND: DWC31 version 2.00a have an issue that would
+              * cause a CSR read timeout When CSR read coincides with RAM
+              * Clock Gating Entry.
+              *
+              * This workaround solution disable Clock Gating, sacrificing
+              * power consumption for normal operation.
+              */
+             if ((dwc->dr_mode == USB_DR_MODE_HOST ||
+                  dwc->dr_mode == USB_DR_MODE_OTG) && DWC3_VER_IS(DWC31, 200A))
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
drivers/usb/dwc3/core.c +1 -1
+                     reg |= 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 = DWC3_GHWPARAMS1_EN_PWROPT(dwc->hwparams.hwparams1);

switch (power_opt) {
    ...
}

/*
* <comment>
*/
if (power_opt != DWC3_GHWPARAMS1_EN_PWROPT_NO) {
}

Quoted 7 lines
Quoted 2 lines

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?

I haven't reviewed the other case in detail yet. I'll get back on that.

It may be better if you can submit this separatedly so that the other case won't hold this back (and it maybe easier for tracking too).

Thanks,
Thinh

A message that is not in the archive (sent off-list or not yet received): CAMtoTm1roAvvWCu9LSfcbnozZnakMEexdUVxNyZ7N5KOG8tHcg@mail.gmail.com

maintainer
#23 lore raw

Re: [PATCH v2, 3/3] usb: dwc3: core: Workaround for CSR read timeout

drivers/usb/dwc3/core.c static bool dwc3_core_is_valid(struct dwc3 *dwc) · line 965

Quoted 13 lines · joswang

My initial idea was similar to yours,Please help review the following changes.

drivers/usb/dwc3/core.c +2 -0
index 3a8fbc2d6b99..8c6a09718737 100644
@@ -961,11 +961,15 @@ static bool dwc3_core_is_valid(struct dwc3 *dwc)
 static void dwc3_core_setup_global_control(struct dwc3 *dwc)
 {
        u32 reg;
+       unsigned int power_opt;
+       unsigned int hw_mode;

Use reverse christmas tree declaration style:

type1 abcdefg
type2 abcde
type3 abc

Quoted 12 lines
drivers/usb/dwc3/core.c +3 -1
        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

drivers/usb/dwc3/core.c static void dwc3_core_setup_global_control(struct dwc3 · line 1009

Quoted 8 lines
drivers/usb/dwc3/core.c +4 -0
@@ -998,6 +1002,18 @@ static void dwc3_core_setup_global_control(struct dwc3
 *dwc)
                break;
        }
 
+       /*
+        * WORKAROUND: DWC_usb31 version 2.00a have an issue that would
+        * cause a CSR read timeout When CSR read coincides with RAM
+        * Clock Gating Entry.

Note in the comment and commit message that this applies while operating as host mode. Add the STAR number reference in the commit message.

drivers/usb/dwc3/core.c static void dwc3_core_setup_global_control(struct dwc3 *dwc)

Quoted 8 lines
drivers/usb/dwc3/core.c +8 -0
+        *
+        * This workaround solution 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;
+

Thanks,
Thinh

author
#24 lore raw

PATCH v3 1/3 dt-bindings: usb: dwc3: Add snps,p2p3tranok quirk

In reply to joswang

From: Jos Wang <[email protected]>

There is an issue with the DWC31 2.00a and earlier versions where the controller link power state transition from P3/P3CPM/P4 to P2 may take longer than expected, ultimately resulting in the hibernation D3 entering time exceeding the expected 10ms.

Add a new 'snps,p2p3tranok-quirk' DT quirk to dwc3 core for enable the controller transitions directly from phy power state P2 to P3 or from state P3 to P2.

Note that this can only be set if the USB3 PHY supports direct p3 to p2 or p2 to p3 conversion.

---
v1 -> v2:
- v1 did not add this PATCH
v2 -> v3:
- modify Author Jos Wang

---
 Documentation/devicetree/bindings/usb/snps,dwc3.yaml | 7 +++++++
 1 file changed, 7 insertions(+)
Documentation/devicetree/bindings/usb/snps,dwc3.yaml +7 -0
index 1cd0ca90127d..721927495887 100644
@@ -242,6 +242,13 @@ properties:
       When set, all HighSpeed bus instances in park mode are disabled.
     type: boolean
 
+  snps,p2p3tranok-quirk:
+    description:
+      When set, the controller transitions directly from phy power state
+      P2 to P3 or from state P3 to P2. Note that this can only be set
+      if the USB3 PHY supports direct p3 to p2 or p2 to p3 conversion.
+    type: boolean
+
   snps,dis_metastability_quirk:
     description:
       When set, disable metastability workaround. CAUTION! Use only if you are
Signature · 1 line
2.17.1
author
#25 lore raw

PATCH v3 2/3 usb: dwc3: core: add p3p2tranok quirk

In reply to joswang

From: Jos Wang <[email protected]>

In the case of enable hibernation, there is an issue with the DWC31 2.00a and earlier versions where the controller link power state transition from P3/P3CPM/P4 to P2 may take longer than expected, ultimately resulting in the hibernation D3 entering time exceeding the expected 10ms.

Synopsys workaround:
If the PHY supports direct P3 to P2 transition, program GUSB3PIPECTL.P3P2Tran0K=1.

Therefore, adding p3p2tranok quirk for workaround hibernation D3 exceeded the expected entry time.

---
v1 -> v2:
- no change
v2 -> v3:
- modify Author Jos Wang

---
 drivers/usb/dwc3/core.c | 5 +++++
 drivers/usb/dwc3/core.h | 4 ++++
 2 files changed, 9 insertions(+)
drivers/usb/dwc3/core.c +5 -0
index 7ee61a89520b..3a8fbc2d6b99 100644
@@ -666,6 +666,9 @@ static int dwc3_ss_phy_setup(struct dwc3 *dwc, int index)
 	if (dwc->dis_del_phy_power_chg_quirk)
 		reg &= ~DWC3_GUSB3PIPECTL_DEPOCHANGE;
 
+	if (dwc->p2p3tranok_quirk)
+		reg |= DWC3_GUSB3PIPECTL_P3P2TRANOK;
+
 	dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(index), reg);
 
 	return 0;
@@ -1715,6 +1718,8 @@ static void dwc3_get_properties(struct dwc3 *dwc)
 
 	dwc->dis_split_quirk = device_property_read_bool(dev,
 				"snps,dis-split-quirk");
+	dwc->p2p3tranok_quirk = device_property_read_bool(dev,
+				"snps,p2p3tranok-quirk");
 
 	dwc->lpm_nyet_threshold = lpm_nyet_threshold;
 	dwc->tx_de_emphasis = tx_de_emphasis;
drivers/usb/dwc3/core.h +4 -0
index 3781c736c1a1..2810dce8b42e 100644
@@ -327,6 +327,7 @@
 #define DWC3_GUSB3PIPECTL_DEP1P2P3_EN	DWC3_GUSB3PIPECTL_DEP1P2P3(1)
 #define DWC3_GUSB3PIPECTL_DEPOCHANGE	BIT(18)
 #define DWC3_GUSB3PIPECTL_SUSPHY	BIT(17)
+#define DWC3_GUSB3PIPECTL_P3P2TRANOK	BIT(11)
 #define DWC3_GUSB3PIPECTL_LFPSFILT	BIT(9)
 #define DWC3_GUSB3PIPECTL_RX_DETOPOLL	BIT(8)
 #define DWC3_GUSB3PIPECTL_TX_DEEPH_MASK	DWC3_GUSB3PIPECTL_TX_DEEPH(3)
@@ -1132,6 +1133,8 @@ struct dwc3_scratchpad_array {
  *			instances in park mode.
  * @parkmode_disable_hs_quirk: set if we need to disable all HishSpeed
  *			instances in park mode.
+ * @p2p3tranok_quirk: set if Controller transitions directly from phy
+ *			power state P2 to P3 or from state P3 to P2.
  * @gfladj_refclk_lpm_sel: set if we need to enable SOF/ITP counter
  *                          running based on ref_clk
  * @tx_de_emphasis_quirk: set if we enable Tx de-emphasis quirk
@@ -1361,6 +1364,7 @@ struct dwc3 {
 	unsigned		ulpi_ext_vbus_drv:1;
 	unsigned		parkmode_disable_ss_quirk:1;
 	unsigned		parkmode_disable_hs_quirk:1;
+	unsigned		p2p3tranok_quirk:1;
 	unsigned		gfladj_refclk_lpm_sel:1;
 
 	unsigned		tx_de_emphasis_quirk:1;
Signature · 1 line
2.17.1
author
#26 lore raw

PATCH v3 3/3 usb: dwc3: core: Workaround for CSR read timeout

In reply to joswang

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.

---
v1 -> v2:
- add "dt-bindings: usb: dwc3: Add snps,p2p3tranok quirk" patch 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

---
 drivers/usb/dwc3/core.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/usb/dwc3/core.c +19 -1
index 3a8fbc2d6b99..61f858f64e5a 100644
@@ -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");
Signature · 1 line
2.17.1
maintainer
#27 lore raw

Re: [PATCH v3, 3/3] usb: dwc3: core: Workaround for CSR read timeout

Quoted 20 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.

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.

---
v1 -> v2:
- add "dt-bindings: usb: dwc3: Add snps,p2p3tranok quirk" patch 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

Quoted 3 lines
---
 drivers/usb/dwc3/core.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

Should this have a cc: stable line?

thanks,

greg k-h

author
#28 lore raw

Re: [PATCH v3, 3/3] usb: dwc3: core: Workaround for CSR read timeout

Quoted 26 lines · Greg KH
Quoted 20 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.

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.

---
v1 -> v2:
- add "dt-bindings: usb: dwc3: Add snps,p2p3tranok quirk" patch 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

Quoted 3 lines
---
 drivers/usb/dwc3/core.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
Quoted 5 lines

Should this have a cc: stable line?

thanks,

greg k-h

Thanks for your help in reviewing the code.
In the subsequent v4 version, Cc: [email protected] will be added to the patch approval area.

Thanks,

Jos Wang

author
#29 lore raw

Re: [PATCH v3, 3/3] usb: dwc3: core: Workaround for CSR read timeout

In reply to Greg KH
Quoted 26 lines · Greg KH
Quoted 20 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.

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.

---
v1 -> v2:
- add "dt-bindings: usb: dwc3: Add snps,p2p3tranok quirk" patch 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

Quoted 3 lines
---
 drivers/usb/dwc3/core.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
Quoted 5 lines

Should this have a cc: stable line?

thanks,

greg k-h

I have a question here, please help me confirm
1. Cc: [email protected] or Cc: [email protected] ?
2. Do I need to modify the commit message, for example:

maintainer
#30 lore raw

Re: [PATCH v3, 3/3] usb: dwc3: core: Workaround for CSR read timeout

Quoted 33 lines · joswang
Quoted 26 lines · Greg KH
Quoted 20 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.

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.

---
v1 -> v2:
- add "dt-bindings: usb: dwc3: Add snps,p2p3tranok quirk" patch 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

Quoted 3 lines
---
 drivers/usb/dwc3/core.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
Quoted 5 lines

Should this have a cc: stable line?

thanks,

greg k-h

Quoted 7 lines

I have a question here, please help me confirm
1. Cc: [email protected] or Cc: [email protected] ?
2. Do I need to modify the commit message, for example:

Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.

author
#31 lore raw

Re: [PATCH v3, 3/3] usb: dwc3: core: Workaround for CSR read timeout

Quoted 43 lines · Greg KH
Quoted 33 lines · joswang
Quoted 26 lines · Greg KH
Quoted 20 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.

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.

---
v1 -> v2:
- add "dt-bindings: usb: dwc3: Add snps,p2p3tranok quirk" patch 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

Quoted 3 lines
---
 drivers/usb/dwc3/core.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
Quoted 5 lines

Should this have a cc: stable line?

thanks,

greg k-h

Quoted 7 lines

I have a question here, please help me confirm
1. Cc: [email protected] or Cc: [email protected] ?
2. Do I need to modify the commit message, for example:

Quoted 3 lines

Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.

Thank You

maintainer
#32 lore raw

Re: [PATCH v3, 3/3] usb: dwc3: core: Workaround for CSR read timeout

In reply to joswang
Quoted 20 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.

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.

---
v1 -> v2:
- add "dt-bindings: usb: dwc3: Add snps,p2p3tranok quirk" patch 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

Quoted 3 lines
---
 drivers/usb/dwc3/core.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

Where are patches 1/3 and 2/3 of this series?

thanks,

greg k-h

author
#33 lore raw

Re: [PATCH v3, 3/3] usb: dwc3: core: Workaround for CSR read timeout

Quoted 26 lines · Greg KH
Quoted 20 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.

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.

---
v1 -> v2:
- add "dt-bindings: usb: dwc3: Add snps,p2p3tranok quirk" patch 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

Quoted 3 lines
---
 drivers/usb/dwc3/core.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
Quoted 5 lines

Where are patches 1/3 and 2/3 of this series?

thanks,

greg k-h

Patches 1/3 and 2/3 are other cases. The maintainer is reviewing them and has no accurate conclusion yet, so only patches 3/3 are submitted.

Thanks,

Jos Wang

maintainer
#34 lore raw

Re: [PATCH v3, 3/3] usb: dwc3: core: Workaround for CSR read timeout

Quoted 27 lines · joswang
Quoted 26 lines · Greg KH
Quoted 23 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.

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.

---
v1 -> v2:
- add "dt-bindings: usb: dwc3: Add snps,p2p3tranok quirk" patch 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

---
 drivers/usb/dwc3/core.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
Quoted 8 lines
Quoted 5 lines

Where are patches 1/3 and 2/3 of this series?

thanks,

greg k-h

Patches 1/3 and 2/3 are other cases. The maintainer is reviewing them and has no accurate conclusion yet, so only patches 3/3 are submitted.

How are we supposed to know this? A patch series should be taken all at once, right?

confused,

greg k-h

author
#35 lore raw

Re: [PATCH v3, 3/3] usb: dwc3: core: Workaround for CSR read timeout

Quoted 38 lines · Greg KH
Quoted 27 lines · joswang
Quoted 26 lines · Greg KH
Quoted 23 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.

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.

---
v1 -> v2:
- add "dt-bindings: usb: dwc3: Add snps,p2p3tranok quirk" patch 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

---
 drivers/usb/dwc3/core.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
Quoted 8 lines
Quoted 5 lines

Where are patches 1/3 and 2/3 of this series?

thanks,

greg k-h

Patches 1/3 and 2/3 are other cases. The maintainer is reviewing them and has no accurate conclusion yet, so only patches 3/3 are submitted.

Quoted 6 lines

How are we supposed to know this? A patch series should be taken all at once, right?

confused,

greg k-h

I am very sorry, I misunderstood the patch series before. How should I deal with this patch now? Should Patches 1/3 and 2/3 also be submitted?

maintainer
#36 lore raw

Re: [PATCH v3, 3/3] usb: dwc3: core: Workaround for CSR read timeout

Quoted 42 lines · joswang
Quoted 41 lines · Greg KH
Quoted 27 lines · joswang
Quoted 26 lines · Greg KH
Quoted 23 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.

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.

---
v1 -> v2:
- add "dt-bindings: usb: dwc3: Add snps,p2p3tranok quirk" patch 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

---
 drivers/usb/dwc3/core.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
Quoted 8 lines
Quoted 5 lines

Where are patches 1/3 and 2/3 of this series?

thanks,

greg k-h

Patches 1/3 and 2/3 are other cases. The maintainer is reviewing them and has no accurate conclusion yet, so only patches 3/3 are submitted.

How are we supposed to know this? A patch series should be taken all at once, right?

Quoted 7 lines
Quoted 3 lines

confused,

greg k-h

I am very sorry, I misunderstood the patch series before. How should I deal with this patch now? Should Patches 1/3 and 2/3 also be submitted?

Yes please.

author
#37 lore raw

PATCH v4 1/3 dt-bindings: usb: dwc3: Add snps,p2p3tranok quirk

In reply to joswang

From: Jos Wang <[email protected]>

There is an issue with the DWC31 2.00a and earlier versions where the controller link power state transition from P3/P3CPM/P4 to P2 may take longer than expected, ultimately resulting in the hibernation D3 entering time exceeding the expected 10ms.

Add a new 'snps,p2p3tranok-quirk' DT quirk to dwc3 core for enable the controller transitions directly from phy power state P2 to P3 or from state P3 to P2.

Note that this can only be set if the USB3 PHY supports direct p3 to p2 or p2 to p3 conversion.

---
v1 -> v2:
- v1 did not add this PATCH
v2 -> v3:
- modify Author Jos Wang
v3 -> v4:
- no change

---
 Documentation/devicetree/bindings/usb/snps,dwc3.yaml | 7 +++++++
 1 file changed, 7 insertions(+)
Documentation/devicetree/bindings/usb/snps,dwc3.yaml +7 -0
index 1cd0ca90127d..721927495887 100644
@@ -242,6 +242,13 @@ properties:
       When set, all HighSpeed bus instances in park mode are disabled.
     type: boolean
 
+  snps,p2p3tranok-quirk:
+    description:
+      When set, the controller transitions directly from phy power state
+      P2 to P3 or from state P3 to P2. Note that this can only be set
+      if the USB3 PHY supports direct p3 to p2 or p2 to p3 conversion.
+    type: boolean
+
   snps,dis_metastability_quirk:
     description:
       When set, disable metastability workaround. CAUTION! Use only if you are
Signature · 1 line
2.17.1
#38 lore raw

Re: [PATCH v4, 1/3] dt-bindings: usb: dwc3: Add snps,p2p3tranok quirk

Documentation/devicetree/bindings/usb/snps,dwc3.yaml properties: · line 250

Quoted 7 lines · joswang
Documentation/devicetree/bindings/usb/snps,dwc3.yaml +6 -0
+  snps,p2p3tranok-quirk:
+    description:
+      When set, the controller transitions directly from phy power state
+      P2 to P3 or from state P3 to P2. Note that this can only be set
+      if the USB3 PHY supports direct p3 to p2 or p2 to p3 conversion.
+    type: boolean

Hm? You respond to feedback and, without waiting for my answer, immediately send new version?

No. Read feedback on your previous version. Drop the quirk.

Best regards,
Krzysztof

author
#39 lore raw

Re: [PATCH v4, 1/3] dt-bindings: usb: dwc3: Add snps,p2p3tranok quirk

Quoted 10 lines · Krzysztof Kozlowski

Documentation/devicetree/bindings/usb/snps,dwc3.yaml properties: · line 250

Quoted 7 lines · joswang
Documentation/devicetree/bindings/usb/snps,dwc3.yaml +6 -0
+  snps,p2p3tranok-quirk:
+    description:
+      When set, the controller transitions directly from phy power state
+      P2 to P3 or from state P3 to P2. Note that this can only be set
+      if the USB3 PHY supports direct p3 to p2 or p2 to p3 conversion.
+    type: boolean
Quoted 8 lines

Hm? You respond to feedback and, without waiting for my answer, immediately send new version?

No. Read feedback on your previous version. Drop the quirk.

Best regards,
Krzysztof

Thank you for your help in reviewing the code.
Sorry, I submitted three patches in total. Patch1 (the current patch) and patch2 solve one case, and patch3 solves another case. Because patch3 needs to submit a new version, I resubmitted v3 and v4 versions.
Patch2 is under review, and there is no clear conclusion. For now, patch1 does not need to be paid attention to. I will notify you when patch2 has a clear conclusion.

Thanks,

Jos Wang

#40 lore raw

Re: [PATCH v4, 1/3] dt-bindings: usb: dwc3: Add snps,p2p3tranok quirk

Quoted 20 lines · joswang
Quoted 10 lines · Krzysztof Kozlowski

Documentation/devicetree/bindings/usb/snps,dwc3.yaml properties: · line 250

Quoted 7 lines · joswang
Documentation/devicetree/bindings/usb/snps,dwc3.yaml +6 -0
+  snps,p2p3tranok-quirk:
+    description:
+      When set, the controller transitions directly from phy power state
+      P2 to P3 or from state P3 to P2. Note that this can only be set
+      if the USB3 PHY supports direct p3 to p2 or p2 to p3 conversion.
+    type: boolean
Quoted 8 lines

Hm? You respond to feedback and, without waiting for my answer, immediately send new version?

No. Read feedback on your previous version. Drop the quirk.

Best regards,
Krzysztof

Quoted 8 lines

Thank you for your help in reviewing the code.
Sorry, I submitted three patches in total. Patch1 (the current patch) and patch2 solve one case, and patch3 solves another case. Because patch3 needs to submit a new version, I resubmitted v3 and v4 versions.
Patch2 is under review, and there is no clear conclusion. For now, patch1 does not need to be paid attention to. I will notify you when patch2 has a clear conclusion.

This does no work like this.

Implement feedback and send new version of entire patchset *ONCE* there is conclusion. Sending new version of some parts ignoring feedback or skipping conclusion is not the way.

Sorry.

Still drop.

Or in case we still have here misunderstanding - so far it looks like: NAK

Best regards,
Krzysztof

author
#41 lore raw

PATCH v4 2/3 usb: dwc3: core: add p3p2tranok quirk

In reply to joswang

From: Jos Wang <[email protected]>

In the case of enable hibernation, there is an issue with the DWC31 2.00a and earlier versions where the controller link power state transition from P3/P3CPM/P4 to P2 may take longer than expected, ultimately resulting in the hibernation D3 entering time exceeding the expected 10ms.

Synopsys workaround:
If the PHY supports direct P3 to P2 transition, program GUSB3PIPECTL.P3P2Tran0K=1.

Therefore, adding p3p2tranok quirk for workaround hibernation D3 exceeded the expected entry time.

---
v1 -> v2:
- no change
v2 -> v3:
- modify Author Jos Wang
v3 -> v4:
- no change

---
 drivers/usb/dwc3/core.c | 5 +++++
 drivers/usb/dwc3/core.h | 4 ++++
 2 files changed, 9 insertions(+)
drivers/usb/dwc3/core.c +5 -0
index 7ee61a89520b..3a8fbc2d6b99 100644
@@ -666,6 +666,9 @@ static int dwc3_ss_phy_setup(struct dwc3 *dwc, int index)
 	if (dwc->dis_del_phy_power_chg_quirk)
 		reg &= ~DWC3_GUSB3PIPECTL_DEPOCHANGE;
 
+	if (dwc->p2p3tranok_quirk)
+		reg |= DWC3_GUSB3PIPECTL_P3P2TRANOK;
+
 	dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(index), reg);
 
 	return 0;
@@ -1715,6 +1718,8 @@ static void dwc3_get_properties(struct dwc3 *dwc)
 
 	dwc->dis_split_quirk = device_property_read_bool(dev,
 				"snps,dis-split-quirk");
+	dwc->p2p3tranok_quirk = device_property_read_bool(dev,
+				"snps,p2p3tranok-quirk");
 
 	dwc->lpm_nyet_threshold = lpm_nyet_threshold;
 	dwc->tx_de_emphasis = tx_de_emphasis;
drivers/usb/dwc3/core.h +4 -0
index 3781c736c1a1..2810dce8b42e 100644
@@ -327,6 +327,7 @@
 #define DWC3_GUSB3PIPECTL_DEP1P2P3_EN	DWC3_GUSB3PIPECTL_DEP1P2P3(1)
 #define DWC3_GUSB3PIPECTL_DEPOCHANGE	BIT(18)
 #define DWC3_GUSB3PIPECTL_SUSPHY	BIT(17)
+#define DWC3_GUSB3PIPECTL_P3P2TRANOK	BIT(11)
 #define DWC3_GUSB3PIPECTL_LFPSFILT	BIT(9)
 #define DWC3_GUSB3PIPECTL_RX_DETOPOLL	BIT(8)
 #define DWC3_GUSB3PIPECTL_TX_DEEPH_MASK	DWC3_GUSB3PIPECTL_TX_DEEPH(3)
@@ -1132,6 +1133,8 @@ struct dwc3_scratchpad_array {
  *			instances in park mode.
  * @parkmode_disable_hs_quirk: set if we need to disable all HishSpeed
  *			instances in park mode.
+ * @p2p3tranok_quirk: set if Controller transitions directly from phy
+ *			power state P2 to P3 or from state P3 to P2.
  * @gfladj_refclk_lpm_sel: set if we need to enable SOF/ITP counter
  *                          running based on ref_clk
  * @tx_de_emphasis_quirk: set if we enable Tx de-emphasis quirk
@@ -1361,6 +1364,7 @@ struct dwc3 {
 	unsigned		ulpi_ext_vbus_drv:1;
 	unsigned		parkmode_disable_ss_quirk:1;
 	unsigned		parkmode_disable_hs_quirk:1;
+	unsigned		p2p3tranok_quirk:1;
 	unsigned		gfladj_refclk_lpm_sel:1;
 
 	unsigned		tx_de_emphasis_quirk:1;
Signature · 1 line
2.17.1
author
#42 lore raw

PATCH v4 3/3 usb: dwc3: core: Workaround for CSR read timeout

In reply to joswang

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.

---
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: [email protected]

---
 drivers/usb/dwc3/core.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/usb/dwc3/core.c +19 -1
index 3a8fbc2d6b99..61f858f64e5a 100644
@@ -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");
Signature · 1 line
2.17.1
maintainer
#43 lore raw

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

Quoted 13 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.

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 11 lines

---
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: [email protected]

This thread is crazy, look at:

	https://lore.kernel.org/all/[email protected]/

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

#44 lore raw

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

Quoted 26 lines · Greg KH
Quoted 13 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.

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 11 lines

---
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: [email protected]

Quoted 5 lines

This thread is crazy, look at:

	https://lore.kernel.org/all/[email protected]/

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.

author
#45 lore raw

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

In reply to Greg KH
Quoted 37 lines · Greg KH
Quoted 13 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.

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 11 lines

---
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: [email protected]

This thread is crazy, look at:

        https://lore.kernel.org/all/[email protected]/

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.

Quoted 6 lines

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?

maintainer
#46 lore raw

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

Quoted 43 lines · joswang
Quoted 42 lines · Greg KH
Quoted 13 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.

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 11 lines

---
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: [email protected]

This thread is crazy, look at:

        https://urldefense.com/v3/__https://lore.kernel.org/all/[email protected]/__;!!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,

Quoted 8 lines
Quoted 1 line

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

#47 lore raw

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

Quoted 51 lines · Thinh Nguyen
Quoted 50 lines · joswang
Quoted 37 lines · Greg KH
Quoted 13 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.

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 11 lines

---
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: [email protected]

This thread is crazy, look at:

        https://urldefense.com/v3/__https://lore.kernel.org/all/[email protected]/__;!!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.

Quoted 6 lines

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

Quoted 7 lines
Quoted 1 line

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

maintainer
#48 lore raw

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

Quoted 7 lines · Jung Daehwan

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

#49 lore raw

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

Quoted 9 lines · Thinh Nguyen
Quoted 7 lines · Jung Daehwan

Hi Thinh,

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

Quoted 7 lines

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

author
#50 lore raw

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

In reply to Thinh Nguyen
Quoted 52 lines · Thinh Nguyen
Quoted 50 lines · joswang
Quoted 37 lines · Greg KH
Quoted 13 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.

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 11 lines

---
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: [email protected]

This thread is crazy, look at:

        https://urldefense.com/v3/__https://lore.kernel.org/all/[email protected]/__;!!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.

Quoted 6 lines

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

Quoted 7 lines
Quoted 1 line

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

maintainer
#51 lore raw

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

Quoted 55 lines · joswang
Quoted 54 lines · Thinh Nguyen
Quoted 51 lines · joswang
Quoted 37 lines · Greg KH
Quoted 13 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.

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 11 lines

---
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: [email protected]

This thread is crazy, look at:

        https://urldefense.com/v3/__https://lore.kernel.org/all/[email protected]/__;!!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.

Quoted 6 lines

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?

Quoted 7 lines
Quoted 5 lines

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