Skip to contentSkip to conversation

usb: dwc3: fix Clear Stall EP command failure

PATCH Superseded Lu Baolu 2 participants 4 messages Sep 8, 2016

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Lu Baolu

author
#0 lore raw

PATCH 1/1 usb: dwc3: fix Clear Stall EP command failure

Commit 50c763f8c1bac ("usb: dwc3: Set the ClearPendIN bit on Clear Stall EP command") sets ClearPendIN bit for all IN endpoints in v2.60a+ cores no matter which speed mode they're in. This causes Clear Stall EP command failing on some Intel devices.

In page 539 of 2.60a specification, it says:

"When issuing Clear Stall command for IN endpoints in SuperSpeed mode, the software must set the "ClearPendIN" bit to '1' to clear any pending IN transcations, so that the device does not expect any ACK TP from the host for the data sent earlier."

It's obviously that we only need to apply this rule to those IN endpoints in SuperSpeed mode.

Fixes 50c763f8c1bac ("usb: dwc3: Set the ClearPendIN bit on Clear Stall EP command")
---
 drivers/usb/dwc3/gadget.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/dwc3/gadget.c +2 -1
index 7a8d3d8..f1858d6 100644
@@ -348,7 +348,8 @@ static int dwc3_send_clear_stall_ep_cmd(struct dwc3_ep *dep)
 	 * IN transfers due to a mishandled error condition. Synopsys
 	 * STAR 9000614252.
 	 */
-	if (dep->direction && (dwc->revision >= DWC3_REVISION_260A))
+	if (dep->direction && (dwc->revision >= DWC3_REVISION_260A) &&
+	    (dwc->maximum_speed >= USB_SPEED_SUPER))
 		cmd |= DWC3_DEPCMD_CLEARPENDIN;
 
 	memset(&params, 0, sizeof(params));
Signature · 1 line
2.1.4
#1 lore raw

Hi,

Quoted 4 lines · Lu Baolu

Commit 50c763f8c1bac ("usb: dwc3: Set the ClearPendIN bit on Clear Stall EP command") sets ClearPendIN bit for all IN endpoints in v2.60a+ cores no matter which speed mode they're in. This causes Clear Stall EP command failing on some Intel devices.

Well, the fact that is fails on some Intel device is, IMO, a symptom. You should have said that ClearStall command fails on 2.60+ operating in HighSpeed mode. That's the real failure. It doesn't matter if it's Intel or not, what matters is the *current* speed.

Quoted 8 lines

In page 539 of 2.60a specification, it says:

"When issuing Clear Stall command for IN endpoints in SuperSpeed mode, the software must set the "ClearPendIN" bit to '1' to clear any pending IN transcations, so that the device does not expect any ACK TP from the host for the data sent earlier."

It's obviously that we only need to apply this rule to those IN

s/obviously/obvious/

Quoted 1 line

endpoints in SuperSpeed mode.

endpoints currently operating in SuperSpeed mode.

Quoted 2 lines
Fixes 50c763f8c1bac ("usb: dwc3: Set the ClearPendIN bit on Clear Stall EP command")

please use proper email format:

Cc <[email protected]> # v4.7+
Quoted 10 lines
---
 drivers/usb/dwc3/gadget.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/dwc3/gadget.c +0 -0
index 7a8d3d8..f1858d6 100644

drivers/usb/dwc3/gadget.c static int dwc3_send_clear_stall_ep_cmd(struct dwc3_ep *dep) · line 352

Quoted 6 lines
drivers/usb/dwc3/gadget.c +2 -1
@@ -348,7 +348,8 @@ static int dwc3_send_clear_stall_ep_cmd(struct dwc3_ep *dep)
 	 * IN transfers due to a mishandled error condition. Synopsys
 	 * STAR 9000614252.
 	 */
-	if (dep->direction && (dwc->revision >= DWC3_REVISION_260A))
+	if (dep->direction && (dwc->revision >= DWC3_REVISION_260A) &&
+	    (dwc->maximum_speed >= USB_SPEED_SUPER))

not sure this is correct. Based on text quoted above, it seems to be me we should check *current* speed, not maximum speed. We hold current speed in dwc->gadget.speed.

Signature · 1 line
balbi
author
#2 lore raw
In reply to Lu Baolu

Hi Felipe,

Quoted 27 lines · Lu Baolu

Commit 50c763f8c1bac ("usb: dwc3: Set the ClearPendIN bit on Clear Stall EP command") sets ClearPendIN bit for all IN endpoints in v2.60a+ cores no matter which speed mode they're in. This causes Clear Stall EP command failing on some Intel devices.

In page 539 of 2.60a specification, it says:

"When issuing Clear Stall command for IN endpoints in SuperSpeed mode, the software must set the "ClearPendIN" bit to '1' to clear any pending IN transcations, so that the device does not expect any ACK TP from the host for the data sent earlier."

It's obviously that we only need to apply this rule to those IN endpoints in SuperSpeed mode.

Fixes 50c763f8c1bac ("usb: dwc3: Set the ClearPendIN bit on Clear Stall EP command")
---
 drivers/usb/dwc3/gadget.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/dwc3/gadget.c +0 -0
index 7a8d3d8..f1858d6 100644

drivers/usb/dwc3/gadget.c static int dwc3_send_clear_stall_ep_cmd(struct dwc3_ep *dep) · line 355

Quoted 9 lines
drivers/usb/dwc3/gadget.c +2 -1
@@ -348,7 +348,8 @@ static int dwc3_send_clear_stall_ep_cmd(struct dwc3_ep *dep)
 	 * IN transfers due to a mishandled error condition. Synopsys
 	 * STAR 9000614252.
 	 */
-	if (dep->direction && (dwc->revision >= DWC3_REVISION_260A))
+	if (dep->direction && (dwc->revision >= DWC3_REVISION_260A) &&
+	    (dwc->maximum_speed >= USB_SPEED_SUPER))
 		cmd |= DWC3_DEPCMD_CLEARPENDIN;
 
 	memset(&params, 0, sizeof(params));

Oh, my bad.

I'm sending you a patch which hasn't been verified on the real hardware yet.

My mind goes blank after a whole day's work. Poor me. :-(

I will send you a refreshed one tomorrow. Really sorry about it.

Best regards,
Lu Baolu

#3 lore raw

Hi,

Quoted 35 lines · Lu Baolu
Quoted 35 lines

Commit 50c763f8c1bac ("usb: dwc3: Set the ClearPendIN bit on Clear Stall EP command") sets ClearPendIN bit for all IN endpoints in v2.60a+ cores no matter which speed mode they're in. This causes Clear Stall EP command failing on some Intel devices.

In page 539 of 2.60a specification, it says:

"When issuing Clear Stall command for IN endpoints in SuperSpeed mode, the software must set the "ClearPendIN" bit to '1' to clear any pending IN transcations, so that the device does not expect any ACK TP from the host for the data sent earlier."

It's obviously that we only need to apply this rule to those IN endpoints in SuperSpeed mode.

Fixes 50c763f8c1bac ("usb: dwc3: Set the ClearPendIN bit on Clear Stall EP command")
---
 drivers/usb/dwc3/gadget.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/dwc3/gadget.c +2 -1
index 7a8d3d8..f1858d6 100644
@@ -348,7 +348,8 @@ static int dwc3_send_clear_stall_ep_cmd(struct dwc3_ep *dep)
 	 * IN transfers due to a mishandled error condition. Synopsys
 	 * STAR 9000614252.
 	 */
-	if (dep->direction && (dwc->revision >= DWC3_REVISION_260A))
+	if (dep->direction && (dwc->revision >= DWC3_REVISION_260A) &&
+	    (dwc->maximum_speed >= USB_SPEED_SUPER))
 		cmd |= DWC3_DEPCMD_CLEARPENDIN;
 
Quoted 8 lines

drivers/usb/dwc3/gadget.c static int dwc3_send_clear_stall_ep_cmd(struct dwc3_ep *dep) · line 355

Quoted 1 line
drivers/usb/dwc3/gadget.c +0 -0
 	memset(&params, 0, sizeof(params));

Oh, my bad.

I'm sending you a patch which hasn't been verified on the real hardware yet.

My mind goes blank after a whole day's work. Poor me. :-(

happens to all of us ;-)

Quoted 1 line

I will send you a refreshed one tomorrow. Really sorry about it.

no problem, thanks

Signature · 1 line
balbi