fix: disable wakeup_on_write by default to prevent HID lockup on host reboot#754
Open
7tg wants to merge 1 commit intosipeed:mainfrom
Open
fix: disable wakeup_on_write by default to prevent HID lockup on host reboot#7547tg wants to merge 1 commit intosipeed:mainfrom
7tg wants to merge 1 commit intosipeed:mainfrom
Conversation
… reboot
wakeup_on_write being enabled by default causes the DWC2 USB controller
to spam USB remote wakeup signals when the host PC is restarting or in
BIOS/UEFI. The host rejects these signals ("wakeup: signalling skipped:
is not allowed by host"), which leads to endpoint transfer timeouts
(dwc2_hsotg_ep_stop_xfr: timeout) and leaves the USB gadget in a stuck
state. In some cases this causes a kernel NULL pointer dereference crash.
This affects keyboard, mouse, and touchpad HID devices in both regular
(S03usbdev) and HID-only (S03usbhid) modes.
The fix inverts the default: wakeup_on_write is now disabled unless
explicitly opted-in via /boot/usb.wakeup. This is safe because USB HID
devices do not require remote wakeup to function - the host will
re-enumerate the gadget naturally after reboot.
Fixes sipeed#220, sipeed#302, sipeed#383, sipeed#544, sipeed#656
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.
Summary
wakeup_on_writeby default in bothS03usbdev(regular mode) andS03usbhid(HID-only mode)/boot/usb.notwakeup) to an opt-in flag (/boot/usb.wakeup) so the safe default requires no user actionProblem
When
wakeup_on_writeis enabled (current default), every HID write (keyboard/mouse input) triggers a USB remote wakeup signal. When the host PC is restarting, in BIOS/UEFI, or has suspended USB:This is a widespread issue affecting NanoKVM Full, Lite, and PCIe variants across many host systems.
Root Cause
The
wakeup_on_writefeature attempts USB remote wakeup signalling on every HID report write. Many host USB controllers do not allow remote wakeup (especially during boot/BIOS, restart, or on certain chipsets like Intel N100/N305). The failed wakeup attempts corrupt the DWC2 endpoint state machine, making recovery impossible without a full PHY restart.Fix
USB HID devices do not require remote wakeup to function — the host re-enumerates the gadget naturally after reboot. The fix simply inverts the default:
wakeup_on_write=1unless/boot/usb.notwakeupexists (unsafe default)wakeup_on_write=0unless/boot/usb.wakeupexists (safe default)Users who specifically need USB remote wakeup can opt in by creating
/boot/usb.wakeup.Testing
Tested on NanoKVM PCIe (firmware 2.3.1) connected to a desktop PC:
wakeup: signalling skippedorep_stop_xfr: timeouterrors in dmesgRelated Issues
Fixes #220 — Rebooting PC causes USB errors (keyboard + mouse + drive) + kernel crash
Fixes #302 — HID stops working
Fixes #383 — USB HID stops working after 10-60s (mouse + keyboard)
Fixes #544 — HID not working in BIOS
Fixes #656 — Keyboard and mouse not working on PCIe KVM