Skip to contentSkip to conversation

usb: dwc3: Reset the transfer resource index on SET_INTERFACE

PATCH In review Felipe Balbi 3 participants 4 messages Jul 21, 2015 – Jul 22, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: dwc3: Reset the transfer resource index on SET_INTERFACE

From: John Youn <[email protected]>

This fixes an issue introduced in commit b23c843992b6 (usb: dwc3:
gadget: fix DEPSTARTCFG for non-EP0 EPs) that made sure we would only use DEPSTARTCFG once per SetConfig.

The trick is that we should use one DEPSTARTCFG per SetConfig *OR* SetInterface. SetInterface was completely missed from the original patch.

This problem became aparent after commit 76e838c9f776 (usb: dwc3:
gadget: return error if command sent to DEPCMD register fails) added checking of the return status of device endpoint commands.

'Set Endpoint Transfer Resource' command was caught failing occasionally. This is because the Transfer Resource Index was not getting reset during a SET_INTERFACE request.

Finally, to fix the issue, was we have to do is make sure that our start_config_issued flag gets reset whenever we receive a SetInterface request.

To verify the problem (and its fix), all we have to do is run test 9 from testusb with 'testusb -t 9 -s 2048 -a -c 5000'.

Fixes b23c843992b6 (usb: dwc3: gadget: fix DEPSTARTCFG for non-EP0 EPs)
Cc <[email protected]> # v3.2+

---

I have improved commit log and blamed correct commit. Also added stable Cc so we have a chance of fixing older kernels.

If you can test on your end, I'd be glad to add Tested-bys, but do so by tomorrow because it's extra important that we get this patch in.

This is working fine for me with test.sh/testusb

cheers

 drivers/usb/dwc3/ep0.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/usb/dwc3/ep0.c +4 -0
index 2ef3c8d6a9db..69e769c35cf5 100644
@@ -727,6 +727,10 @@ static int dwc3_ep0_std_request(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl)
 		dwc3_trace(trace_dwc3_ep0, "USB_REQ_SET_ISOCH_DELAY");
 		ret = dwc3_ep0_set_isoch_delay(dwc, ctrl);
 		break;
+	case USB_REQ_SET_INTERFACE:
+		dwc3_trace(trace_dwc3_ep0, "USB_REQ_SET_INTERFACE");
+		dwc->start_config_issued = false;
+		/* Fall through */
 	default:
 		dwc3_trace(trace_dwc3_ep0, "Forwarding to gadget driver");
 		ret = dwc3_ep0_delegate_req(dwc, ctrl);
Signature · 1 line
2.4.4
#1 lore raw

PATCH 1/1 usb: dwc3: Reset the transfer resource index on SET_INTERFACE

From: John Youn <[email protected]>

This fixes an issue introduced in commit b23c843992b6 (usb: dwc3:
gadget: fix DEPSTARTCFG for non-EP0 EPs) that made sure we would only use DEPSTARTCFG once per SetConfig.

The trick is that we should use one DEPSTARTCFG per SetConfig *OR* SetInterface. SetInterface was completely missed from the original patch.

This problem became aparent after commit 76e838c9f776 (usb: dwc3:
gadget: return error if command sent to DEPCMD register fails) added checking of the return status of device endpoint commands.

'Set Endpoint Transfer Resource' command was caught failing occasionally. This is because the Transfer Resource Index was not getting reset during a SET_INTERFACE request.

Finally, to fix the issue, was we have to do is make sure that our start_config_issued flag gets reset whenever we receive a SetInterface request.

To verify the problem (and its fix), all we have to do is run test 9 from testusb with 'testusb -t 9 -s 2048 -a -c 5000'.

Fixes b23c843992b6 (usb: dwc3: gadget: fix DEPSTARTCFG for non-EP0 EPs)
Cc <[email protected]> # v3.2+

---

I have improved commit log and blamed correct commit. Also added stable Cc so we have a chance of fixing older kernels.

If you can test on your end, I'd be glad to add Tested-bys, but do so by tomorrow because it's extra important that we get this patch in.

This is working fine for me with test.sh/testusb

cheers

 drivers/usb/dwc3/ep0.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/usb/dwc3/ep0.c +4 -0
index 2ef3c8d6a9db..69e769c35cf5 100644
@@ -727,6 +727,10 @@ static int dwc3_ep0_std_request(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl)
 		dwc3_trace(trace_dwc3_ep0, "USB_REQ_SET_ISOCH_DELAY");
 		ret = dwc3_ep0_set_isoch_delay(dwc, ctrl);
 		break;
+	case USB_REQ_SET_INTERFACE:
+		dwc3_trace(trace_dwc3_ep0, "USB_REQ_SET_INTERFACE");
+		dwc->start_config_issued = false;
+		/* Fall through */
 	default:
 		dwc3_trace(trace_dwc3_ep0, "Forwarding to gadget driver");
 		ret = dwc3_ep0_delegate_req(dwc, ctrl);
Signature · 1 line
2.4.4
Tested-by on v1 1/1
#3 lore raw
In reply to Felipe Balbi
Quoted 22 lines · Felipe Balbi

From: John Youn <[email protected]>

This fixes an issue introduced in commit b23c843992b6 (usb: dwc3:
gadget: fix DEPSTARTCFG for non-EP0 EPs) that made sure we would only use DEPSTARTCFG once per SetConfig.

The trick is that we should use one DEPSTARTCFG per SetConfig *OR* SetInterface. SetInterface was completely missed from the original patch.

This problem became aparent after commit 76e838c9f776 (usb: dwc3:
gadget: return error if command sent to DEPCMD register fails) added checking of the return status of device endpoint commands.

'Set Endpoint Transfer Resource' command was caught failing occasionally. This is because the Transfer Resource Index was not getting reset during a SET_INTERFACE request.

Finally, to fix the issue, was we have to do is make sure that our start_config_issued flag gets reset whenever we receive a SetInterface request.

Quoted 7 lines

To verify the problem (and its fix), all we have to do is run test 9 from testusb with 'testusb -t 9 -s 2048 -a -c 5000'.

Fixes b23c843992b6 (usb: dwc3: gadget: fix DEPSTARTCFG for non-EP0 EPs)
Cc <[email protected]> # v3.2+

Felipe, I've verified it in my side. :)

ray@hr-slim:~/linux-usb$ sudo ./tools/usb/testusb -D /dev/bus/usb/002/004 -t 9 -s 2048 -a -c 5000
unknown speed   /dev/bus/usb/002/004    0
/dev/bus/usb/002/004 test 9,   15.300784 secs
#2 lore raw
In reply to Felipe Balbi

Hi Felipe,

Quoted 39 lines

-----Original Message-----
From: Felipe Balbi [mailto:[email protected]]
Sent: Tuesday, July 21, 2015 7:59 PM
To: Linux USB Mailing List
Cc: David Cohen; Subbaraya Sundeep Bhatta; Andy Gross; Kukjin Kim; Heikki Krogerus; Huang Rui; John Youn; [email protected]; John Youn; Felipe Balbi
Subject: [PATCH] usb: dwc3: Reset the transfer resource index on SET_INTERFACE

From: John Youn <[email protected]>

This fixes an issue introduced in commit b23c843992b6 (usb: dwc3:
gadget: fix DEPSTARTCFG for non-EP0 EPs) that made sure we would only use DEPSTARTCFG once per SetConfig.

The trick is that we should use one DEPSTARTCFG per SetConfig *OR* SetInterface. SetInterface was completely missed from the original patch.

This problem became aparent after commit 76e838c9f776 (usb: dwc3:
gadget: return error if command sent to DEPCMD register fails) added checking of the return status of device endpoint commands.

'Set Endpoint Transfer Resource' command was caught failing occasionally. This is because the Transfer Resource Index was not getting reset during a SET_INTERFACE request.

Finally, to fix the issue, was we have to do is make sure that our start_config_issued flag gets reset whenever we receive a SetInterface request.

To verify the problem (and its fix), all we have to do is run test 9 from testusb with 'testusb -t 9 -s 2048 -a -c 5000'.

Fixes b23c843992b6 (usb: dwc3: gadget: fix DEPSTARTCFG for non-EP0

EPs)

Quoted 7 lines

---

I have improved commit log and blamed correct commit. Also added stable Cc so we have a chance of fixing older kernels.

If you can test on your end, I'd be glad to add Tested-bys, but do so by tomorrow because it's extra important that we get this patch in.

unknown speed /dev/bus/usb/001/008 0
/dev/bus/usb/001/008 test 9, 1213.703994 secs

It works fine at my end.
As I mentioned earlier, mine is very slow setup and it took ~1213 secs :)

Thanks,
Sundeep

Quoted 28 lines

This is working fine for me with test.sh/testusb

cheers

 drivers/usb/dwc3/ep0.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/usb/dwc3/ep0.c index renamed from drivers/usb/dwc3/ep0.c +0 -0

2ef3c8d6a9db..69e769c35cf5 100644

drivers/usb/dwc3/ep0.c +4 -0
@@ -727,6 +727,10 @@ static int dwc3_ep0_std_request(struct dwc3
 *dwc, struct usb_ctrlrequest *ctrl)
 		dwc3_trace(trace_dwc3_ep0,
 "USB_REQ_SET_ISOCH_DELAY");
 		ret = dwc3_ep0_set_isoch_delay(dwc, ctrl);
 		break;
+	case USB_REQ_SET_INTERFACE:
+		dwc3_trace(trace_dwc3_ep0, "USB_REQ_SET_INTERFACE");
+		dwc->start_config_issued = false;
+		/* Fall through */
 	default:

dwc3_trace(trace_dwc3_ep0, "Forwarding to gadget
driver");
ret = dwc3_ep0_delegate_req(dwc, ctrl);
--
2.4.4