Page MenuHomeFreeBSD

bhyve: introduce cancel interface for usb device
Needs ReviewPublic

Authored by kevans on Aug 5 2025, 9:37 AM.
Tags
None
Referenced Files
F174257335: D51735.id159748.diff
Thu, Oct 1, 7:14 PM
F174252897: D51735.id161045.diff
Thu, Oct 1, 6:19 PM
F174252421: D51735.id161036.diff
Thu, Oct 1, 6:14 PM
F174249068: D51735.id161059.diff
Thu, Oct 1, 5:27 PM
F174247556: D51735.id186899.diff
Thu, Oct 1, 5:09 PM
F174244085: D51735.id161097.diff
Thu, Oct 1, 4:26 PM
F174237315: D51735.id179608.diff
Thu, Oct 1, 3:02 PM
F174237179: D51735.id161115.diff
Thu, Oct 1, 3:00 PM

Details

Reviewers
markj
lwhsu
khng
bz
aokblast
Group Reviewers
bhyve
Summary

When disabling a port, xHCI should allow the backend a chance to cancel
all active transfers before deallocating memory. To support this, we
introduce an interface in UE that lets the backend register a
cancellation callback.

Additionally, this commit allows the backend to populate the tr_softc
field when setting up a transfer in ue_data, enabling context-specific
handling for transfer cancellation and cleanup.

Sponsored By: The FreeBSD Foundation

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 76988
Build 73871: arc lint + arc unit

Event Timeline

This revision is now accepted and ready to land.Aug 27 2025, 1:35 PM

You don't need to call ue_cancel in pci_xhci_cmd_reset_ep()?

This revision now requires review to proceed.Aug 27 2025, 3:31 PM
usr.sbin/bhyve/pci_xhci.c
1216–1217

The rest ep only stop the xfer. However, the parameter of ue_reset pass a whole device instead of a xfer.

1216–1217

Sorry, only clear the stall bit instead of stop whole transfer.

markj added inline comments.
usr.sbin/bhyve/pci_xhci.c
1220

We definitely don't need to be able to return an error from ue_cancel?

This revision is now accepted and ready to land.Aug 27 2025, 3:41 PM
This revision now requires review to proceed.Aug 27 2025, 4:01 PM
usr.sbin/bhyve/pci_xhci.c
757

Or print a warning if it fails.

1218
usr.sbin/bhyve/pci_xhci.c
704

If you move the mutex_destroy to pci_xhci_disable_ep() (which also handles freeing the xfer), you can use this subroutine in pci_xhci_reset_slot() as well.

1221
usr.sbin/bhyve/pci_xhci.c
1196

Why did we drop handling of XHCI_TRB_TYPE_RESET_EP?

kevans added inline comments.
usr.sbin/bhyve/pci_xhci.c
1196

I thought this was actually a bugfix, but section 4.6.8 of the xhci spec kind of buries the key detail: "[...] any subsequent packets received for the endpoint will be silently dropped." We only have usb_mouse.c as an example, but its implementation clears sc->newdata which would seem to silently drop future packets. I will restore it here.

Restore handling of XHCI_TRB_TYPE_RESET_EP to be sure that we don't retain data
that should be dropped according to the spec.

kevans added a reviewer: aokblast.
kevans marked 5 inline comments as done.

Fixed one indentation issue