zephyr/drivers/usb
Tomasz Moń 6e3f8d4967 drivers: udc_dwc2: Set control endpoint CNAK only when necessary
SETUP data is unconditionally ACKed by the controller. Other DATA
packets sent to OUT control endpoint 0 (i.e. OUT Data Stage packets
and OUT Status Stage packet) are ACKed by the device only if the
endpoint was enabled with CNAK bit set.

In Buffer DMA mode controller will lock up in following scenario:
  * OUT EP0 is not enabled, e.g. OUT Status Stage has finished
  * Host starts Control Write transfer, i.e. sends SETUP DATA0 and
    device ACKs (regardless if endpoint is enabled or not)
  * host sends OUT Data Stage (OUT DATA1)
      - software enables endpoint to be able to receive next SETUP data
	while host is transmitting the OUT token. If CNAK bit is set
        alongside the EPENA bit, the device will ACK the OUT Data Stage.
        If CNAK bit is not set, the device will NAK the OUT Data Stage.

When the lockup occurs, from host perspective the OUT Data Stage packet
was successfully transmitted. This can result in host starting IN Status
Stage if there was only one OUT Data Stage packet. This in turn results
in device never getting the DOEPTINT0 SetUp interrupt. Besides just not
getting the SetUp interrupt, any subsequent control transfer won't be
noticed by device at all.

The lockup was first observed while stress testing. The host was issuing
endless sequence of Control Write, Control Read, Control Write, Control
Read, ... commands. When the controller did lock up in Buffer DMA mode,
from host perspective the device was timing out all control transfers.

Avoid the Buffer DMA lockup by setting CNAK bit only when necessary.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2025-03-26 11:32:33 +01:00
..
bc12 drivers: bc12: Place API into iterable section 2024-12-03 19:56:37 +01:00
common drivers: udc_dwc2: Workaround hibernation exit glitch 2025-02-05 10:21:13 +01:00
device drivers: nxp_usb: usb_dc_mcux error condition updated 2025-03-07 19:48:38 +01:00
udc drivers: udc_dwc2: Set control endpoint CNAK only when necessary 2025-03-26 11:32:33 +01:00
uhc usb: host: rework usbh_xfer_alloc() parameters 2025-02-10 09:02:45 +01:00
uvb
CMakeLists.txt
Kconfig