Support for USBD_FORCE_SHORT_XFER for xhci

Nat Sloss <[email protected]>
Newsgroups gmane.os.netbsd.devel.kernel
Message-ID <[email protected]>
Hi,

I've done recent work on urtwn that fixes transfers when the device is used 
with xhci.

It turns out the root of the problem was a lack of support in the xhci stack 
for the flag USBD_FORCE_SHORT_XFER.


There is some previous artwork for ehci/uhci/ohci that has special handling 
for this particuar flag.

Attached is my attempt at fixing this - this would also make possible for me to 
revert the last 2 commits to urtwn as I would no longer have to send zero 
lengh xfers in the driver.

Thoughts?


Best regards and TIA,

Nat
xhci-fix.diff (text/x-patch, 611 B)
diff -r b3936ad349df sys/dev/usb/xhci.c
--- a/sys/dev/usb/xhci.c	Thu Aug 21 03:06:52 2025 +0000
+++ b/sys/dev/usb/xhci.c	Fri Aug 22 23:08:51 2025 +1000
@@ -4794,6 +4794,13 @@ xhci_device_bulk_start(struct usbd_xfer 
 	    XHCI_TRB_3_IOC_BIT;
 	xhci_xfer_put_trb(xx, i++, parameter, status, control);
 
+	if (!isread && (xfer->ux_flags & USBD_FORCE_SHORT_XFER)) {
+		status = XHCI_TRB_2_IRQ_SET(0) |
+		    XHCI_TRB_2_TDSZ_SET(0) |
+		    XHCI_TRB_2_BYTES_SET(0);
+		xhci_xfer_put_trb(xx, i++, parameter, status, control);
+	}
+
 	if (!polling)
 		mutex_enter(&tr->xr_lock);
 	xhci_ring_put_xfer(sc, tr, xx, i);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.