usb: dwc3: gadget: Stop EP0 transfers during pullup disable
Subsystems (2)
PATCH v4 1/1 usb: dwc3: gadget: Stop EP0 transfers during pullup disable
During a USB cable disconnect, or soft disconnect scenario, a pending SETUP transaction may not be completed, leading to the following error:
dwc3 a600000.dwc3: timed out waiting for SETUP phase
If this occurs, then the entire pullup disable routine is skipped and proper cleanup and halting of the controller does not complete.
Instead of returning an error (which is ignored from the UDC perspective), allow the pullup disable routine to continue, which will also handle disabling of EP0/1. This will end any active transfers as well. Ensure to clear any delayed_status also, as the timeout could happen within the STATUS stage.
---
Changes in v4:
- Fixed formatting and typos in commit text
- Removed braces due to the removal of the return statement
Changes in v3:
- Added suggestion by Thinh to change dev_err to dev_warn
Changes in v2:
- Removed calls to dwc3_ep0_end_control_data() and just allow the ep disables on EP0 handle the proper ending of transfers.
- Ensure that delayed_status is cleared, as ran into enumeration issues if the SETUP transaction fails on a STATUS stage. Saw delayed_status == TRUE on the next connect, which blocked further SETUP transactions to be handled.
drivers/usb/dwc3/gadget.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/usb/dwc3/gadget.c +3 -4
@@ -2428,10 +2428,8 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on) ret =wait_for_completion_timeout (&dwc->ep0_in_setup,msecs_to_jiffies (DWC3_PULL_UP_TIMEOUT )); -if (ret ==0 ) { -dev_err (dwc->dev,"timed out waiting for SETUP phase\n" ); -return -ETIMEDOUT ; - } +if (ret ==0 ) +dev_warn (dwc->dev,"timed out waiting for SETUP phase\n" ); }/*
@@ -2643,6 +2641,7 @@ static int __dwc3_gadget_start(struct dwc3 *dwc)/* begin to receive SETUP packets */ dwc->ep0state =EP0_SETUP_PHASE ; dwc->link_state =DWC3_LINK_STATE_SS_DIS ; + dwc->delayed_status = false;dwc3_ep0_out_start (dwc);dwc3_gadget_enable_irq (dwc);
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 53 lines · Wesley Cheng
During a USB cable disconnect, or soft disconnect scenario, a pending SETUP transaction may not be completed, leading to the following error:
dwc3 a600000.dwc3: timed out waiting for SETUP phase
If this occurs, then the entire pullup disable routine is skipped and proper cleanup and halting of the controller does not complete.
Instead of returning an error (which is ignored from the UDC perspective), allow the pullup disable routine to continue, which will also handle disabling of EP0/1. This will end any active transfers as well. Ensure to clear any
delayed_statusalso, as the timeout could happen within the STATUS stage.Signed-off-by Wesley Cheng <[email protected]>---
Changes in v4:
- Fixed formatting and typos in commit text
- Removed braces due to the removal of the return statementChanges in v3:
- Added suggestion by Thinh to changedev_errtodev_warnChanges in v2:
- Removed calls todwc3_ep0_end_control_data()and just allow the ep disables on EP0 handle the proper ending of transfers.
- Ensure thatdelayed_statusis cleared, as ran into enumeration issues if the SETUP transaction fails on a STATUS stage. Sawdelayed_status== TRUE on the next connect, which blocked further SETUP transactions to be handled.drivers/usb/dwc3/gadget.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)drivers/usb/dwc3/gadget.c +2
-4@@ -2428,10 +2428,8 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on) ret =wait_for_completion_timeout (&dwc->ep0_in_setup,msecs_to_jiffies (DWC3_PULL_UP_TIMEOUT )); -if (ret ==0 ) { -dev_err (dwc->dev,"timed out waiting for SETUP phase\n" ); -return -ETIMEDOUT ; - } +if (ret ==0 ) +dev_warn (dwc->dev,"timed out waiting for SETUP phase\n" ); }/*
drivers/usb/dwc3/gadget.c static int __dwc3_gadget_start(struct dwc3 *dwc) · line 2647
Quoted 7 lines
drivers/usb/dwc3/gadget.c +1
-0@@ -2643,6 +2641,7 @@ static int __dwc3_gadget_start(struct dwc3 *dwc)/* begin to receive SETUP packets */ dwc->ep0state =EP0_SETUP_PHASE ; dwc->link_state =DWC3_LINK_STATE_SS_DIS ; + dwc->delayed_status = false;dwc3_ep0_out_start (dwc);dwc3_gadget_enable_irq (dwc);
Thanks,
Thinh
Quoted 39 lines · Wesley Cheng
During a USB cable disconnect, or soft disconnect scenario, a pending SETUP transaction may not be completed, leading to the following error:
dwc3 a600000.dwc3: timed out waiting for SETUP phase
If this occurs, then the entire pullup disable routine is skipped and proper cleanup and halting of the controller does not complete.
Instead of returning an error (which is ignored from the UDC perspective), allow the pullup disable routine to continue, which will also handle disabling of EP0/1. This will end any active transfers as well. Ensure to clear any
delayed_statusalso, as the timeout could happen within the STATUS stage.Signed-off-by Wesley Cheng <[email protected]>---
Changes in v4:
- Fixed formatting and typos in commit text
- Removed braces due to the removal of the return statementChanges in v3:
- Added suggestion by Thinh to changedev_errtodev_warnChanges in v2:
- Removed calls todwc3_ep0_end_control_data()and just allow the ep disables on EP0 handle the proper ending of transfers.
- Ensure thatdelayed_statusis cleared, as ran into enumeration issues if the SETUP transaction fails on a STATUS stage. Sawdelayed_status== TRUE on the next connect, which blocked further SETUP transactions to be handled.drivers/usb/dwc3/gadget.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)drivers/usb/dwc3/gadget.c +0
-0
drivers/usb/dwc3/gadget.c static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on) · line 2432
Quoted 9 lines
drivers/usb/dwc3/gadget.c +2
-4@@ -2428,10 +2428,8 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on) ret =wait_for_completion_timeout (&dwc->ep0_in_setup,msecs_to_jiffies (DWC3_PULL_UP_TIMEOUT )); -if (ret ==0 ) { -dev_err (dwc->dev,"timed out waiting for SETUP phase\n" ); -return -ETIMEDOUT ; - } +if (ret ==0 ) +dev_warn (dwc->dev,"timed out waiting for SETUP phase\n" );
looks like a bug fix. Do we need to Cc stable?
Signature · 1 line
balbi