Failing USB_XFER_LOCK_ASSERT condition

From: Farhan Khan <farhan_at_farhan.codes>
Date: Tue, 13 May 2025 01:14:48 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,

--
Farhan Khan
PGP Fingerprint: 1312 89CE 663E 1EB2 179C 1C83 C41D 2281 F8DA C0DE