Skip to content

Commit

Permalink
drivers: usb_dc_rpi_pico: previosuly used endpoint may remain locked
Browse files Browse the repository at this point in the history
When reconfiguring a previously used endpoint, it may still be locked
when a write was taking place when e.g. the host application crashed.
The call to udc_rpi_cancel_endpoint seems to do a proper cleanup of
the endpoint, i.e. the write semaphore will be released.
Fixes #66723.

Signed-off-by: Manuel Aebischer <[email protected]>
  • Loading branch information
Manuel Aebischer authored and fabiobaltieri committed Dec 21, 2023
1 parent e05d964 commit 8cf199f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions drivers/usb/device/usb_dc_rpi_pico.c
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,13 @@ int usb_dc_ep_disable(const uint8_t ep)
return 0;
}

/* If this endpoint has previously been used and e.g. the host application
* crashed, the endpoint may remain locked even after reconfiguration
* because the write semaphore is never given back.
* udc_rpi_cancel_endpoint() handles this so the endpoint can be written again.
*/
udc_rpi_cancel_endpoint(ep);

uint8_t val = *ep_state->ep_ctl & ~EP_CTRL_ENABLE_BITS;

*ep_state->ep_ctl = val;
Expand Down

0 comments on commit 8cf199f

Please sign in to comment.