Re: Failing USB_XFER_LOCK_ASSERT condition
- In reply to: Farhan Khan: "Failing USB_XFER_LOCK_ASSERT condition"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 13 May 2025 17:53:25 UTC
> Hi all, > > I am trying to submit a usbd_transfer_start, but hitting the assertion > error here: > http://bxr.su/FreeBSD/sys/dev/usb/usb_transfer.c#1954, which is this > line: > USB_XFER_LOCK_ASSERT(xfer, MA_OWNED); > > I noticed that when I lock the device with mtx_lock(sc->sc_mtx) I do > not hit that assertion condition but I do without it. However, looking > at other device drivers, they do not need an explicit > DEVICE_LOCK/UNLOCK around each transfer. > > What is the common pattern that would prevent this? I am probably > missing something, but am unclear on what. > Thank you, I figured it out...I completely misunderstood how a mutex worked in relation to a USB transfer. In short, the usdb_transfer_start requires the mutex to be locked that was created during the usbd_transfer_setup. Hope that helps someone in the future.