Page MenuHomeFreeBSD

hidbus: stop interrupts before finalizing child deactivation
AcceptedPublic

Authored by kevans on Jul 12 2026, 7:48 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Aug 13, 10:15 AM
Unknown Object (File)
Thu, Aug 13, 10:15 AM
Unknown Object (File)
Thu, Aug 13, 10:14 AM
Unknown Object (File)
Wed, Aug 12, 7:10 PM
Unknown Object (File)
Wed, Aug 12, 1:21 PM
Unknown Object (File)
Mon, Aug 10, 10:14 AM
Unknown Object (File)
Mon, Aug 10, 8:38 AM
Unknown Object (File)
Sat, Aug 8, 4:10 PM
Subscribers

Details

Reviewers
wulf
aokblast
Summary

In the case of usbhid, the parent will drain any transfers that are
pending, which could lead to just a little bit of data being plumbed
through. Stop interrupts *before* we mark the child as inactive so that
anything that was inflight makes it through.

This primarily helps a little with debugging, so that we can tell if
data was dropped as a result of hid_intr_stop().

Diff Detail

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

Event Timeline

sys/dev/hid/hidbus.c
639

I can't understand. If it is the last bit. We should clear the bit then do foreach check? Or it will never deactive?

sys/dev/hid/hidbus.c
639

Clearing the bit up-front means hidbus_intr won't drain any last minute response to the device driver thaat hid_intr_stop (doing a usbd_transfer_drain) triggers. The device driver will either be discarding them anyways (e.g., u2f(4), hidraw(4)) or it's harmless; in either case, it's useful for debugging to be able to observe the response at that level even if it wll be ignored.

sys/dev/hid/hidbus.c
639

Ok. I think you want to trigger the hidbus_intr in the last minutes and let the decision pass to the underlying driver. But would it actually work? ivar->actiave = false set after the active |= tlc->active, it measn active would never equals to 0 if we don't deactive twice in the same node.

sys/dev/hid/hidbus.c
639

Right, that's why setting active in the loop iss predicated on tlc != ivar -- so that it's explicitly not accounted for, and if every other device is inactive then we will call hid_intr_stop() before clearing tlc->active

LGTM. Sorry that I though it was copy and paste from line 633. It should work. Thanks!

This revision is now accepted and ready to land.Sat, Jul 25, 1:29 PM
sys/dev/hid/hidbus.c
639

Do you think it worth a __unlikely here?