From 8cf199fb04a6a78ea67a588712f187969ed1818b Mon Sep 17 00:00:00 2001 From: Manuel Aebischer Date: Wed, 20 Dec 2023 21:21:55 +0100 Subject: [PATCH] drivers: usb_dc_rpi_pico: previosuly used endpoint may remain locked 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 --- drivers/usb/device/usb_dc_rpi_pico.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/usb/device/usb_dc_rpi_pico.c b/drivers/usb/device/usb_dc_rpi_pico.c index e3599c00bfeb..38e88afae392 100644 --- a/drivers/usb/device/usb_dc_rpi_pico.c +++ b/drivers/usb/device/usb_dc_rpi_pico.c @@ -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;