From 8b212d80fdf8d6c5032ce538cab230cf819e7905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mo=C5=84?= Date: Wed, 27 Nov 2024 11:37:21 +0100 Subject: [PATCH] drivers: udc_dwc2: Fix isochronous endpoint disable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The NAKSts bit may be set on isochronous OUT endpoints when incomplete ISO OUT interrupt is raised. The code would then assume that endpoint is already disabled and would not perform the endpoint disable procedure. This in turn was essentially halting any transmission on the isochronous endpoint, abruptly terminating the data stream. Fix the issue by always following full endpoint disable procedure on isochronous endpoints. Signed-off-by: Tomasz Moń --- drivers/usb/udc/udc_dwc2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/udc/udc_dwc2.c b/drivers/usb/udc/udc_dwc2.c index 7e716201d3c2a2..2ecf230baafa2c 100644 --- a/drivers/usb/udc/udc_dwc2.c +++ b/drivers/usb/udc/udc_dwc2.c @@ -1387,11 +1387,12 @@ static void udc_dwc2_ep_disable(const struct device *dev, uint8_t ep_idx = USB_EP_GET_IDX(cfg->addr); mem_addr_t dxepctl_reg; uint32_t dxepctl; + const bool is_iso = dwc2_ep_is_iso(cfg); dxepctl_reg = dwc2_get_dxepctl_reg(dev, cfg->addr); dxepctl = sys_read32(dxepctl_reg); - if (dxepctl & USB_DWC2_DEPCTL_NAKSTS) { + if (!is_iso && (dxepctl & USB_DWC2_DEPCTL_NAKSTS)) { /* Endpoint already sends forced NAKs. STALL if necessary. */ if (stall) { dxepctl |= USB_DWC2_DEPCTL_STALL;