usb: dwc3: Ignore late xferNotReady event to prevent halt timeout
Subsystems (2)
RFC PATCH 1/1 usb: dwc3: Ignore late xferNotReady event to prevent halt timeout
During a device-initiated disconnect, an xferNotReady event for an ISOC IN endpoint can be received after the End Transfer command has already completed.
This late event incorrectly triggers a new Start Transfer, which prevents the controller from halting and results in a DSTS.DEVCTRLHLT bit polling timeout.
Ignore the late xferNotReady event if the controller is already in a disconnected state.
---
Tracing:
# Stop active transfers by sending End Transfer commands
android.hardwar-913 [004] d..1. 6172.855517: dwc3_gadget_ep_cmd: ep1out: cmd 'End Transfer' [20d08] params 00000000 00000000 00000000 --> status: Successful
android.hardwar-913 [004] dn.1. 6172.855734: dwc3_gadget_ep_cmd: ep1in: cmd 'End Transfer' [40d08] params 00000000 00000000 00000000 --> status: Successful
...
# Recieve an xferNotReady event on an ISOC IN endpoint
irq/991-dwc3-29741 [000] D..1. 6172.856166: dwc3_event: event (35d010c6): ep1in: Transfer Not Ready [000035d0] (Not Active)
irq/991-dwc3-29741 [000] D..1. 6172.856190: dwc3_gadget_ep_cmd: ep1in: cmd 'Start Transfer' [35d60406] params 00000000 ffffb620 00000000 --> status: Successful
android.hardwar-913 [004] dn.1. 6172.868130: dwc3_gadget_ep_cmd: ep2in: cmd 'End Transfer' [30d08] params 00000000 00000000 00000000 --> status: Timed Out ...
# Start polling DSTS.DEVCTRLHLT
android.hardwar-913 [000] ..... 6172.869253: dwc3_gadget_run_stop: start polling DWC3_DSTS_DEVCTRLHLT
...
# HALT timeout and show the endpoint status for debugging
android.hardwar-913 [004] ..... 6177.479946: dwc3_gadget_run_stop: finish polling DWC3_DSTS_DEVCTRLHLT, is_on=0, reg=0 android.hardwar-913 [004] ..... 6177.479957: dwc3_gadget_ep_status: ep1out: mps 1024/2765 streams 16 burst 5 ring 64/56 flags E:swbp:> android.hardwar-913 [004] ..... 6177.479958: dwc3_gadget_ep_status: ep1in: mps 1024/1024 streams 16 burst 2 ring 21/64 flags E:swBp:< android.hardwar-913 [004] ..... 6177.479959: dwc3_gadget_ep_status: ep2out: mps 1024/2765 streams 16 burst 5 ring 56/48 flags e:swbp:>
--- drivers/usb/dwc3/gadget.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/dwc3/gadget.c +2 -1
@@ -3896,7 +3896,8 @@ static void dwc3_endpoint_interrupt(struct dwc3 *dwc,dwc3_gadget_endpoint_transfer_in_progress (dep, event);break ;case DWC3_DEPEVT_XFERNOTREADY : -dwc3_gadget_endpoint_transfer_not_ready (dep, event); +if (dwc->connected) +dwc3_gadget_endpoint_transfer_not_ready (dep, event);break ;case DWC3_DEPEVT_EPCMDCMPLT :dwc3_gadget_endpoint_command_complete (dep, event);
--
2.50.1.565.gc32cd1483b-goog
Greg KH
maintainerQuoted 28 lines · Kuen-Han Tsai
During a device-initiated disconnect, an xferNotReady event for an ISOC IN endpoint can be received after the End Transfer command has already completed.
This late event incorrectly triggers a new Start Transfer, which prevents the controller from halting and results in a DSTS.DEVCTRLHLT bit polling timeout.
Ignore the late xferNotReady event if the controller is already in a disconnected state.
Signed-off-by Kuen-Han Tsai <[email protected]>---
Tracing:# Stop active transfers by sending End Transfer commands
android.hardwar-913 [004] d..1. 6172.855517: dwc3_gadget_ep_cmd: ep1out: cmd 'End Transfer' [20d08] params 00000000 00000000 00000000 --> status: Successful android.hardwar-913 [004] dn.1. 6172.855734: dwc3_gadget_ep_cmd: ep1in: cmd 'End Transfer' [40d08] params 00000000 00000000 00000000 --> status: Successful ... # Recieve an xferNotReady event on an ISOC IN endpoint irq/991-dwc3-29741 [000] D..1. 6172.856166: dwc3_event: event (35d010c6): ep1in: Transfer Not Ready [000035d0] (Not Active) irq/991-dwc3-29741 [000] D..1. 6172.856190: dwc3_gadget_ep_cmd: ep1in: cmd 'Start Transfer' [35d60406] params 00000000 ffffb620 00000000 --> status: Successful android.hardwar-913 [004] dn.1. 6172.868130: dwc3_gadget_ep_cmd: ep2in: cmd 'End Transfer' [30d08] params 00000000 00000000 00000000 --> status: Timed Out...
# Start polling DSTS.DEVCTRLHLT
android.hardwar-913 [000] ..... 6172.869253:dwc3_gadget_run_stop: start pollingDWC3_DSTS_DEVCTRLHLT
...
# HALT timeout and show the endpoint status for debugging
Quoted 8 lines
android.hardwar-913 [004] ..... 6177.479946: dwc3_gadget_run_stop: finish polling DWC3_DSTS_DEVCTRLHLT, is_on=0, reg=0 android.hardwar-913 [004] ..... 6177.479957: dwc3_gadget_ep_status: ep1out: mps 1024/2765 streams 16 burst 5 ring 64/56 flags E:swbp:> android.hardwar-913 [004] ..... 6177.479958: dwc3_gadget_ep_status: ep1in: mps 1024/1024 streams 16 burst 2 ring 21/64 flags E:swBp:< android.hardwar-913 [004] ..... 6177.479959: dwc3_gadget_ep_status: ep2out: mps 1024/2765 streams 16 burst 5 ring 56/48 flags e:swbp:>--- drivers/usb/dwc3/gadget.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Why is this RFC? What needs to happen to make it an actual submission that you wish to have applied?
thanks,
greg k-h
Hi Greg,
Quoted 35 lines · Greg KH
Quoted 33 lines · Kuen-Han Tsai
During a device-initiated disconnect, an xferNotReady event for an ISOC IN endpoint can be received after the End Transfer command has already completed.
This late event incorrectly triggers a new Start Transfer, which prevents the controller from halting and results in a DSTS.DEVCTRLHLT bit polling timeout.
Ignore the late xferNotReady event if the controller is already in a disconnected state.
Signed-off-by Kuen-Han Tsai <[email protected]>---
Tracing:# Stop active transfers by sending End Transfer commands
android.hardwar-913 [004] d..1. 6172.855517: dwc3_gadget_ep_cmd: ep1out: cmd 'End Transfer' [20d08] params 00000000 00000000 00000000 --> status: Successful android.hardwar-913 [004] dn.1. 6172.855734: dwc3_gadget_ep_cmd: ep1in: cmd 'End Transfer' [40d08] params 00000000 00000000 00000000 --> status: Successful ... # Recieve an xferNotReady event on an ISOC IN endpoint irq/991-dwc3-29741 [000] D..1. 6172.856166: dwc3_event: event (35d010c6): ep1in: Transfer Not Ready [000035d0] (Not Active) irq/991-dwc3-29741 [000] D..1. 6172.856190: dwc3_gadget_ep_cmd: ep1in: cmd 'Start Transfer' [35d60406] params 00000000 ffffb620 00000000 --> status: Successful android.hardwar-913 [004] dn.1. 6172.868130: dwc3_gadget_ep_cmd: ep2in: cmd 'End Transfer' [30d08] params 00000000 00000000 00000000 --> status: Timed Out...
# Start polling DSTS.DEVCTRLHLT
android.hardwar-913 [000] ..... 6172.869253:dwc3_gadget_run_stop: start pollingDWC3_DSTS_DEVCTRLHLT
...
# HALT timeout and show the endpoint status for debuggingandroid.hardwar-913 [004] ..... 6177.479946: dwc3_gadget_run_stop: finish polling DWC3_DSTS_DEVCTRLHLT, is_on=0, reg=0 android.hardwar-913 [004] ..... 6177.479957: dwc3_gadget_ep_status: ep1out: mps 1024/2765 streams 16 burst 5 ring 64/56 flags E:swbp:> android.hardwar-913 [004] ..... 6177.479958: dwc3_gadget_ep_status: ep1in: mps 1024/1024 streams 16 burst 2 ring 21/64 flags E:swBp:< android.hardwar-913 [004] ..... 6177.479959: dwc3_gadget_ep_status: ep2out: mps 1024/2765 streams 16 burst 5 ring 56/48 flags e:swbp:>
Quoted 6 lines
Quoted 3 lines
--- drivers/usb/dwc3/gadget.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)Why is this RFC? What needs to happen to make it an actual submission that you wish to have applied?
I'm not sure if this solution is acceptable since I couldn't find any guidance in the programming guide about ignoring xferNotReady events depending on the controller's status. I was thinking marking this as an RFC is more appropriate to solicit feedback on the solution.
I will send a new patch without the RFC tag soon.
Regards,
Kuen-Han
Thinh Nguyen
maintainerHi,
Quoted 3 lines · Kuen-Han Tsai
During a device-initiated disconnect, an xferNotReady event for an ISOC IN endpoint can be received after the End Transfer command has already completed.
Some more info for clarity: the controller generates xferNotReady event once when the host requests to send/receive data to an endpoint. The End Transfer command resets the event filter and allow the controller to generate the xferNotReady event again. This can occur in the middle of device-initiated disconnect and before the controller is halted.
Quoted 9 lines
This late event incorrectly triggers a new Start Transfer, which prevents the controller from halting and results in a DSTS.DEVCTRLHLT bit polling timeout.
Ignore the late xferNotReady event if the controller is already in a disconnected state.
Signed-off-by Kuen-Han Tsai <[email protected]>
Please also add Fixes tag and Cc stable.
Quoted 30 lines
---
Tracing:# Stop active transfers by sending End Transfer commands
android.hardwar-913 [004] d..1. 6172.855517: dwc3_gadget_ep_cmd: ep1out: cmd 'End Transfer' [20d08] params 00000000 00000000 00000000 --> status: Successful android.hardwar-913 [004] dn.1. 6172.855734: dwc3_gadget_ep_cmd: ep1in: cmd 'End Transfer' [40d08] params 00000000 00000000 00000000 --> status: Successful ... # Recieve an xferNotReady event on an ISOC IN endpoint irq/991-dwc3-29741 [000] D..1. 6172.856166: dwc3_event: event (35d010c6): ep1in: Transfer Not Ready [000035d0] (Not Active) irq/991-dwc3-29741 [000] D..1. 6172.856190: dwc3_gadget_ep_cmd: ep1in: cmd 'Start Transfer' [35d60406] params 00000000 ffffb620 00000000 --> status: Successful android.hardwar-913 [004] dn.1. 6172.868130: dwc3_gadget_ep_cmd: ep2in: cmd 'End Transfer' [30d08] params 00000000 00000000 00000000 --> status: Timed Out...
# Start polling DSTS.DEVCTRLHLT
android.hardwar-913 [000] ..... 6172.869253:dwc3_gadget_run_stop: start pollingDWC3_DSTS_DEVCTRLHLT
...
# HALT timeout and show the endpoint status for debuggingandroid.hardwar-913 [004] ..... 6177.479946: dwc3_gadget_run_stop: finish polling DWC3_DSTS_DEVCTRLHLT, is_on=0, reg=0 android.hardwar-913 [004] ..... 6177.479957: dwc3_gadget_ep_status: ep1out: mps 1024/2765 streams 16 burst 5 ring 64/56 flags E:swbp:> android.hardwar-913 [004] ..... 6177.479958: dwc3_gadget_ep_status: ep1in: mps 1024/1024 streams 16 burst 2 ring 21/64 flags E:swBp:< android.hardwar-913 [004] ..... 6177.479959: dwc3_gadget_ep_status: ep2out: mps 1024/2765 streams 16 burst 5 ring 56/48 flags e:swbp:>--- drivers/usb/dwc3/gadget.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/usb/dwc3/gadget.c +0
-0
drivers/usb/dwc3/gadget.c static void dwc3_endpoint_interrupt(struct dwc3 *dwc, · line 3899
Quoted 5 lines
drivers/usb/dwc3/gadget.c +1
-1@@ -3896,7 +3896,8 @@ static void dwc3_endpoint_interrupt(struct dwc3 *dwc,dwc3_gadget_endpoint_transfer_in_progress (dep, event);break ;case DWC3_DEPEVT_XFERNOTREADY : -dwc3_gadget_endpoint_transfer_not_ready (dep, event); +if (dwc->connected)
Move this check in dwc3_gadget_endpoint_transfer_not_ready().
Quoted 7 lines
drivers/usb/dwc3/gadget.c +1
-1+dwc3_gadget_endpoint_transfer_not_ready (dep, event);break ;case DWC3_DEPEVT_EPCMDCMPLT :dwc3_gadget_endpoint_command_complete (dep, event); --2.50.1.565.gc32cd1483b-goog
And remove the RFC tag in $subject.
Thanks,
Thinh
Hi Thinh,
Quoted 8 lines · Thinh Nguyen
Hi,
Quoted 3 lines · Kuen-Han Tsai
During a device-initiated disconnect, an xferNotReady event for an ISOC IN endpoint can be received after the End Transfer command has already completed.
Quoted 5 lines
Some more info for clarity: the controller generates xferNotReady event once when the host requests to send/receive data to an endpoint. The End Transfer command resets the event filter and allow the controller to generate the xferNotReady event again. This can occur in the middle of device-initiated disconnect and before the controller is halted.
Thanks for adding more details. I've revised the problem description in the new submission.
Quoted 38 lines
Quoted 10 lines
This late event incorrectly triggers a new Start Transfer, which prevents the controller from halting and results in a DSTS.DEVCTRLHLT bit polling timeout.
Ignore the late xferNotReady event if the controller is already in a disconnected state.
Signed-off-by Kuen-Han Tsai <[email protected]>Please also add Fixes tag and Cc stable.
Quoted 25 lines
---
Tracing:# Stop active transfers by sending End Transfer commands
android.hardwar-913 [004] d..1. 6172.855517: dwc3_gadget_ep_cmd: ep1out: cmd 'End Transfer' [20d08] params 00000000 00000000 00000000 --> status: Successful android.hardwar-913 [004] dn.1. 6172.855734: dwc3_gadget_ep_cmd: ep1in: cmd 'End Transfer' [40d08] params 00000000 00000000 00000000 --> status: Successful ... # Recieve an xferNotReady event on an ISOC IN endpoint irq/991-dwc3-29741 [000] D..1. 6172.856166: dwc3_event: event (35d010c6): ep1in: Transfer Not Ready [000035d0] (Not Active) irq/991-dwc3-29741 [000] D..1. 6172.856190: dwc3_gadget_ep_cmd: ep1in: cmd 'Start Transfer' [35d60406] params 00000000 ffffb620 00000000 --> status: Successful android.hardwar-913 [004] dn.1. 6172.868130: dwc3_gadget_ep_cmd: ep2in: cmd 'End Transfer' [30d08] params 00000000 00000000 00000000 --> status: Timed Out...
# Start polling DSTS.DEVCTRLHLT
android.hardwar-913 [000] ..... 6172.869253:dwc3_gadget_run_stop: start pollingDWC3_DSTS_DEVCTRLHLT
...
# HALT timeout and show the endpoint status for debuggingandroid.hardwar-913 [004] ..... 6177.479946: dwc3_gadget_run_stop: finish polling DWC3_DSTS_DEVCTRLHLT, is_on=0, reg=0 android.hardwar-913 [004] ..... 6177.479957: dwc3_gadget_ep_status: ep1out: mps 1024/2765 streams 16 burst 5 ring 64/56 flags E:swbp:> android.hardwar-913 [004] ..... 6177.479958: dwc3_gadget_ep_status: ep1in: mps 1024/1024 streams 16 burst 2 ring 21/64 flags E:swBp:< android.hardwar-913 [004] ..... 6177.479959: dwc3_gadget_ep_status: ep2out: mps 1024/2765 streams 16 burst 5 ring 56/48 flags e:swbp:>--- drivers/usb/dwc3/gadget.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 12 lines
drivers/usb/dwc3/gadget.c static void dwc3_endpoint_interrupt(struct dwc3 *dwc, · line 3899
Quoted 10 lines
drivers/usb/dwc3/gadget.c +1
-1@@ -3896,7 +3896,8 @@ static void dwc3_endpoint_interrupt(struct dwc3 *dwc,dwc3_gadget_endpoint_transfer_in_progress (dep, event);break ;case DWC3_DEPEVT_XFERNOTREADY : -dwc3_gadget_endpoint_transfer_not_ready (dep, event); +if (dwc->connected)Move this check in
dwc3_gadget_endpoint_transfer_not_ready().
Done.
Quoted 10 lines
Quoted 8 lines
drivers/usb/dwc3/gadget.c +1
-1+dwc3_gadget_endpoint_transfer_not_ready (dep, event);break ;case DWC3_DEPEVT_EPCMDCMPLT :dwc3_gadget_endpoint_command_complete (dep, event); --2.50.1.565.gc32cd1483b-goog
And remove the RFC tag in $subject.
I sent out a new change without the RFC tag.
https://lore.kernel.org/linux-usb/[email protected]/
Regards,
Kuen-Han