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

Issue when using stalls in vendor-defined control transfers outside of the interrupt context #24

Open
nwright98 opened this issue Nov 9, 2023 · 0 comments

Comments

@nwright98
Copy link

nwright98 commented Nov 9, 2023

This was seen in a vendor-defined application on an ATSAME51G19A running FreeRTOS.

USB transfers stop working when a bus stall is used to indicate an error in vendor-defined control transfers and is called outside of the interrupt context (deferred handling.) I traced this to the following reasons:

  1. DRV_USBFSV1_DEVICE_EndpointStall() calls _DRV_USBFSV1_DEVICE_IRPQueueFlush(), but when called outside of the interrupt context a new read IRP does not get submitted for endpoint 0, so new control transfers are never received. I was able to work around this by not calling _DRV_USBFSV1_DEVICE_IRPQueueFlush() if hDriver->isInInterruptContext is true.
  2. _USB_DEVICE_Ep0ReceiveCompleteCallback() is called on completion of the stall, which subsequently calls the application callback function. This calls driver functions which attempt to make nested calls to lock hDriver->mutexID resulting in a deadlock. This may work if recursive mutexes are enabled, but I worked around by returning immediately from _USB_DEVICE_Ep0ReceiveCompleteCallback() if (irpHandle->status == USB_DEVICE_IRP_STATUS_ABORTED) || (irpHandle->status == USB_DEVICE_IRP_STATUS_ABORTED_ENDPOINT_HALT).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant