Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers: usb_dc_mcux: processing endpoint callbacks in ISR context causes assertion #40638

Closed
ottojo opened this issue Nov 24, 2021 · 2 comments · Fixed by #42019
Closed

drivers: usb_dc_mcux: processing endpoint callbacks in ISR context causes assertion #40638

ottojo opened this issue Nov 24, 2021 · 2 comments · Fixed by #42019
Assignees
Labels
area: Drivers area: USB Universal Serial Bus bug The issue is a bug, or the PR is fixing a bug platform: NXP NXP priority: low Low impact/importance bug

Comments

@ottojo
Copy link
Contributor

ottojo commented Nov 24, 2021

Describe the bug
When using USB networking, the driver accesses networking functions which lock mutexes from ISR context. This leads to failed assertion mutexes cannot be used inside ISRs..

  • ecm_status_cb is registered as USB status callback here (apparently called via ISR)

  • ecm_status_cb calls ecm_status_interface here

  • ecm_status_interface calls netusb_enable here

  • netusb_enable calls net_if_up here

  • net_if_up locks mutex here

  • netusb_enable calls net_if_up here

To Reproduce
(Working on providing a minimal example...)

Expected behavior
Assertion should not fail, the interface should not be enabled from ISR context.

Impact
The network interface seems to work, but this makes it impossible to me to use __ASSERT, since the program can't run with CONFIG_ASSERT enabled.

Logs and console output
(WIP)

Environment (please complete the following information):

  • OS: Ubuntu 20.04
  • Toolchain: Zephyr SDK 0.13.1
  • Zephyr: 70b0734 (reasonably recent main branch)
  • Board: teensy41
@ottojo ottojo added the bug The issue is a bug, or the PR is fixing a bug label Nov 24, 2021
@jfischer-no jfischer-no changed the title netusb ECM driver locking mutex from ISR drivers: usb_dc_mcux: processing endpoint callbacks in ISR context causes assertion Nov 24, 2021
@jfischer-no jfischer-no added area: Drivers platform: NXP NXP priority: low Low impact/importance bug area: USB Universal Serial Bus labels Nov 24, 2021
@jfischer-no
Copy link
Collaborator

@ottojo There is no workaround, USB_DeviceNotificationTrigger needs to be offloaded to a thread/workqueue.

@danieldegrasse
Copy link
Collaborator

@ottojo I can reproduce the error on a RT1064 EVK building the "echo_server" sample with the following command:
west build -p always -b mimxrt1064_evk samples/net/sockets/echo_server -DOVERLAY_CONFIG=overlay-netusb.conf -DCONFIG_ETH_MCUX=n -DCONFIG_ASSERT=y. On my board, #42019 fixes the issue (per @jfischer-no's suggestion of offloading the ISR to a thread) can you verify that branch works for you?

danieldegrasse added a commit to nxp-zephyr/zephyr that referenced this issue Jan 20, 2022
MCUX usb ISR was making usb callbacks directly, which caused assertion
failures when a callback attempted to lock a mutex. Move USB callback
handler to separate thread, and make ISR notify thread via message
queue.

Fixes zephyrproject-rtos#40638

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
carlescufi pushed a commit that referenced this issue Jan 28, 2022
MCUX usb ISR was making usb callbacks directly, which caused assertion
failures when a callback attempted to lock a mutex. Move USB callback
handler to separate thread, and make ISR notify thread via message
queue.

Fixes #40638

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Drivers area: USB Universal Serial Bus bug The issue is a bug, or the PR is fixing a bug platform: NXP NXP priority: low Low impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants