Page MenuHomeFreeBSD

ugen: fix USB_IFACE_DRIVER_ACTIVE after detaching a driver
ClosedPublic

Authored by avg on Feb 18 2024, 2:50 PM.
Tags
None
Referenced Files
F92956563: D43960.id134562.diff
Thu, Sep 5, 4:09 PM
Unknown Object (File)
Fri, Aug 30, 11:05 AM
Unknown Object (File)
Fri, Aug 30, 11:05 AM
Unknown Object (File)
Fri, Aug 30, 11:04 AM
Unknown Object (File)
Fri, Aug 30, 10:51 AM
Unknown Object (File)
Jul 17 2024, 11:19 PM
Unknown Object (File)
Jul 4 2024, 7:29 AM
Unknown Object (File)
May 29 2024, 1:41 PM
Subscribers

Details

Summary

Previosuly, USB_IFACE_DRIVER_ACTIVE would report that the driver is
active even after it detached. That's because a device(9) still
remains.

So, add device_is_alive(9) check for more accurate reporting.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

avg requested review of this revision.Feb 18 2024, 2:50 PM

Seems reasonable to me.

sys/dev/usb/usb_generic.c
2383

Is there a reason not to use device_is_attached()? That seems closer to the spirit of this ioctl, but I'm not very familiar with this area.

This revision is now accepted and ready to land.Feb 18 2024, 2:54 PM
sys/dev/usb/usb_generic.c
2383

It was what I used initially, based on ugen_get_iface_driver.
But then I got a bit worried about concurrent probing and attaching, I decided to err on the side of caution.
Both checks worked equally well in my case.
BTW, the situation was this:

  • connect a USB device
  • see it claimed by uhid driver
  • see that it is impossible to use with a libusb-based application
  • unload uhid module
  • the application still refuses to work because of USB_IFACE_DRIVER_ACTIVE
sys/dev/usb/usb_generic.c
2383

That makes sense, thanks.