Skip to contentSkip to conversation

usb: dwc3: gadget: fix delayed status missing for clear EP halt

PATCH In review Li Jun 2 participants 3 messages Dec 1, 2020 – Dec 2, 2020

Subsystems (2)
lore
Share & tools
lore

Li Jun

author
#0 lore raw

PATCH 1/1 usb: dwc3: gadget: fix delayed status missing for clear EP halt

With several improvements on handling of ClearFeature(halt), there is one case of delayed status missing: if the xfernotready event comes after end transfer and clear ep stall command completion, we can not send the delayed status in dwc3_ep0_send_delayed_status() as the ep0status is not ready, then in xfernotready event we still can not send status because delayed_status is still set.

Fixes d97c78a1908e ("usb: dwc3: gadget: END_TRANSFER before CLEAR_STALL command")
---
 drivers/usb/dwc3/ep0.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/usb/dwc3/ep0.c +7 -1
index 7be3903..9580e9f 100644
@@ -1058,10 +1058,16 @@ void dwc3_ep0_send_delayed_status(struct dwc3 *dwc)
 {
 	unsigned int direction = !dwc->ep0_expect_in;
 
+	/*
+	 * If we are ready to send delayed status
+	 * but wait status pharse, we can clear
+	 * delayed_status flag to let EP0 XferNotReady
+	 * handle it as a normal status sending.
+	 */
+	dwc->delayed_status = false;
 	if (dwc->ep0state != EP0_STATUS_PHASE)
 		return;
 
-	dwc->delayed_status = false;
 	__dwc3_ep0_do_control_status(dwc, dwc->eps[direction]);
 }
 
Signature · 1 line
2.7.4
maintainer
#1 lore raw

Hi,

Quoted 26 lines · Li Jun

With several improvements on handling of ClearFeature(halt), there is one case of delayed status missing: if the xfernotready event comes after end transfer and clear ep stall command completion, we can not send the delayed status in dwc3_ep0_send_delayed_status() as the ep0status is not ready, then in xfernotready event we still can not send status because delayed_status is still set.

Fixes d97c78a1908e ("usb: dwc3: gadget: END_TRANSFER before CLEAR_STALL command")
---
 drivers/usb/dwc3/ep0.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/usb/dwc3/ep0.c +4 -0
index 7be3903..9580e9f 100644
@@ -1058,10 +1058,16 @@ void dwc3_ep0_send_delayed_status(struct dwc3 *dwc)
 {
 	unsigned int direction = !dwc->ep0_expect_in;
 
+	/*
+	 * If we are ready to send delayed status
+	 * but wait status pharse, we can clear
+	 * delayed_status flag to let EP0 XferNotReady

drivers/usb/dwc3/ep0.c void dwc3_ep0_send_delayed_status(struct dwc3 *dwc) · line 1073

Quoted 10 lines
drivers/usb/dwc3/ep0.c +3 -1
+	 * handle it as a normal status sending.
+	 */
+	dwc->delayed_status = false;
 	if (dwc->ep0state != EP0_STATUS_PHASE)
 		return;
 
-	dwc->delayed_status = false;
 	__dwc3_ep0_do_control_status(dwc, dwc->eps[direction]);
 }
 

This fix is already upstreamed:
fa27e2f6c5e6 ("usb: dwc3: ep0: Fix delay status handling")

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=fa27e2f6c5e674f3f1225f9ca7a7821faaf393bb

Thanks,
Thinh

author
#2 lore raw
Quoted 54 lines

-----Original Message-----
From: Thinh Nguyen <[email protected]>
Sent: Wednesday, December 2, 2020 1:00 AM
To: Jun Li <[email protected]>; [email protected]
Cc: [email protected]; Thinh Nguyen <[email protected]>; [email protected]; dl-linux-imx <[email protected]>
Subject: Re: [PATCH] usb: dwc3: gadget: fix delayed status missing for clear EP halt

Hi,

Quoted 26 lines · Li Jun

With several improvements on handling of ClearFeature(halt), there is one case of delayed status missing: if the xfernotready event comes after end transfer and clear ep stall command completion, we can not send the delayed status in dwc3_ep0_send_delayed_status() as the ep0status is not ready, then in xfernotready event we still can not send status because delayed_status is still set.

Fixes d97c78a1908e ("usb: dwc3: gadget: END_TRANSFER before

CLEAR_STALL command")

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

7be3903..9580e9f 100644

drivers/usb/dwc3/ep0.c +3 -0
@@ -1058,10 +1058,16 @@ void dwc3_ep0_send_delayed_status(struct dwc3
 *dwc)  {
 	unsigned int direction = !dwc->ep0_expect_in;
 
+	/*
+	 * If we are ready to send delayed status
+	 * but wait status pharse, we can clear

drivers/usb/dwc3/ep0.c void dwc3_ep0_send_delayed_status(struct dwc3 · line 1072

Quoted 10 lines
drivers/usb/dwc3/ep0.c +4 -1
+	 * delayed_status flag to let EP0 XferNotReady
+	 * handle it as a normal status sending.
+	 */
+	dwc->delayed_status = false;
 	if (dwc->ep0state != EP0_STATUS_PHASE)
 		return;
 
-	dwc->delayed_status = false;
 	__dwc3_ep0_do_control_status(dwc, dwc->eps[direction]);  }
 

This fix is already upstreamed:
fa27e2f6c5e6 ("usb: dwc3: ep0: Fix delay status handling")

Quoted 8 lines

https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.k
ernel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git%2Fc ommit%2F%3Fid%3Dfa27e2f6c5e674f3f1225f9ca7a7821faaf393bb&amp;data=04%7C 01%7Cjun.li%40nxp.com%7Cb4f70f5eedcc467e0ee708d8961a9f74%7C686ea1d3bc2b 4c6fa92cd99c5c301635%7C0%7C0%7C637424388404755873%7CUnknown%7CTWFpbGZsb 3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7 C1000&amp;sdata=6lpOj%2FWUvLc%2FnEYaOoLjYq6JLEqdhmJSmcXpsT8%2Bu0Q%3D&am p;reserved=0

Ah, I missed that, so ignore my patch.

Thanks
Li Jun

Quoted 3 lines

Thanks,
Thinh