Skip to content

DCD DWC2 dcd_edpt_xfer() called from ISR hangs on spinlock #3311

@kwarc93

Description

@kwarc93

Operating System

Windows 11

Commit SHA

331c263

Board

STM32F746G-DISCO

Firmware

Custom firmware with FreeRTOS and USBFS DWC2 driver (based on examples/uac2_headset)

What happened ?

On version v0.18.0, UAC2 examples & my custom firmware works with no problems.
On version v0.19.0 (and latest master) the software hangs in FreeRTOS assertion because taskENTER_CRITICAL() was called from ISR.

In dcd_edpt_xfer() there is a spinlock which assumes non-interrupt context.

bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t* buffer, uint16_t total_bytes) {
  uint8_t const epnum = tu_edpt_number(ep_addr);
  uint8_t const dir = tu_edpt_dir(ep_addr);
  xfer_ctl_t* xfer = XFER_CTL_BASE(epnum, dir);
  bool ret;

  usbd_spin_lock(false); <--- THIS

...

In attatched image, you can see a callstack and call hierarchy of dcd_edpt_xfer().
Call hierarchy shows that its called from:
audio_tx_xfer_isr and audio_rx_xfer_isr

How to reproduce ?

Checkout to v0.19.0 and run uac2_headset example

Debug Log as txt file (LOG/CFG_TUSB_DEBUG=2)

Image

Screenshots

No response

I have checked existing issues, discussion and documentation

  • I confirm I have checked existing issues, discussion and documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions