Page MenuHomeFreeBSD

usb: implement attach kernel driver
AcceptedPublic

Authored by aokblast on Aug 22 2025, 2:43 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Oct 15, 1:54 PM
Unknown Object (File)
Fri, Oct 10, 3:28 AM
Unknown Object (File)
Fri, Oct 10, 3:28 AM
Unknown Object (File)
Fri, Oct 10, 3:28 AM
Unknown Object (File)
Fri, Oct 10, 3:28 AM
Unknown Object (File)
Fri, Oct 10, 3:28 AM
Unknown Object (File)
Fri, Oct 10, 3:13 AM
Unknown Object (File)
Thu, Oct 9, 10:26 PM
Subscribers

Details

Reviewers
lwhsu
markj
Group Reviewers
USB
Summary

FreeBSD's USB framework supports detaching kernel drivers to allow
user space applications to exclusively claim USB interfaces. However,
it lacked support for reattaching the kernel driver afterward.

This commit adds the missing functionality, enabling user space
to return control of the device back to the kernel.

Sponsored by: The FreeBSD Foundation

Test Plan

Tested by usbconfig detach_kernel_driver a keyboard and reattach it.

Diff Detail

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

Event Timeline

I think we also need to update usbconfig(8).

lib/libusb/libusb10.c
1055
lib/libusb/libusb20_ugen20.c
728
sys/dev/usb/usb_ioctl.h
276–277
usr.sbin/usbconfig/usbconfig.c
505
lib/libusb/libusb20.h
249

Minor fixes and add usbcnfig document

sys/dev/usb/usb_device.h
315 ↗(On Diff #160875)

There seems no usb_attach_device() definition? Is the diff of usb_device.c forgot to upload?

sys/dev/usb/usb_device.h
315 ↗(On Diff #160875)

No attach actually, it is called usb_probe_and_attach. I will delete that later.

lib/libusb/libusb.h
204–205

or if you prefer, supports detching with libusb_detach_...() and attaching with libusb_attach_...().

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

Oh, it would be better to have the subject like usb: Implement attach kernel driver function or feature or so.