Fix Resume() to fully reinitialize USB device after suspend#249
Open
fcatuhe wants to merge 1 commit intouunicorn:masterfrom
Open
Fix Resume() to fully reinitialize USB device after suspend#249fcatuhe wants to merge 1 commit intouunicorn:masterfrom
fcatuhe wants to merge 1 commit intouunicorn:masterfrom
Conversation
Replace the broken Resume() with a retry loop that does a full init.open() (USB re-enumeration + sensor init), giving the kernel time to enumerate the USB device after wake. - Call init.open() instead of init.open_common() for fresh USB handle - Retry up to 20 times with 100ms delay (2s max) for USB enumeration - Catch Exception since usb.open() raises plain Exception when device is not yet enumerated
This was referenced Mar 17, 2026
|
I tested this on my T480, it seems to fix issues related, good job |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace the broken
Resume()implementation with a proper retry loop that does a fullinit.open()(USB re-enumeration + sensor init), giving the kernel time to enumerate the USB device after wake.Motivation
The existing
Resume()calledinit.open_common()which skipsusb.open()— it assumes the USB handle is still valid. After suspend, the kernel resets the USB bus and the handle goes stale, causingUSBError: [Errno 19] No such device. The original single bare-except retry was also insufficient since the USB device may not be enumerated yet whenResume()is called.This became visible after open-fprintd PR #24 added
PrepareForSleephandling, which now callsDevice.Resume()automatically on wake. The hyprlock maintainer rightly pointed out that DBus services should handle suspend internally and stay alive across sleep cycles.Related issues
This change, together with open-fprintd PR #24, should address:
Related PRs
Resume().Changes
Changes to
dbus_service/dbus-serviceandvaliditysensor/usb.py:init.open()instead ofinit.open_common()to get a fresh USB handleopen_dev()to raiseUSBErrorinstead of a bareExceptionwhen the device is not found, so the retry loop can catchUSBErrorspecificallyTesting
Tested on a ThinkPad X1 Carbon 6th Gen (
06cb:009aSynaptics reader) running Arch Linux (Omarchy) withopen-fprintd+python-validity. Multiple suspend/resume cycles — USB device typically enumerates after 0-2 failed attempts (~0-200ms). Fingerprint verification works reliably after wake. Tested both successful matches and no-match retries across multiple cycles without service crashes.