{arm,xtensa}/otg: unmask WKUP so USB resume reaches the class driver. - #19936
Merged
xiaoxiang781216 merged 2 commits intoAug 25, 2026
Conversation
dakejahl
requested review from
davids5,
gustavonihei,
jerpelea,
raiden00pl,
xiaoxiang781216 and
yamt
as code owners
August 22, 2026 17:52
dakejahl
force-pushed
the
fix/otg-device-unmask-wkup
branch
from
August 23, 2026 18:02
7345f04 to
8096371
Compare
jerpelea
requested changes
Aug 24, 2026
jerpelea
left a comment
Contributor
There was a problem hiding this comment.
please write pr/commit title according to the contribution guidelines
Contributor
|
@dakejahl please fix: |
dakejahl
force-pushed
the
fix/otg-device-unmask-wkup
branch
from
August 24, 2026 17:10
8096371 to
3e56a15
Compare
Every DWC2-derived USB device driver enables USBSUSP in GINTMSK but not WKUP, and every one of them ANDs GINTSTS with GINTMSK before dispatch. The resume handler is therefore unreachable: CLASS_SUSPEND is delivered on suspend, CLASS_RESUME never is. For CDC/ACM that is fatal. cdcacm_suspend() calls uart_connected(false), after which serial.c refuses every open() and write() with -ENOTCONN, and the cdcacm_resume() that would clear it never runs. On a Linux host with the default USB autosuspend (power/control=auto, 2000 ms) simply closing the tty is enough to trip it, and the port stays dead for the rest of the boot while the device remains enumerated. Verified on STM32H7 (ARK FMU v6X): before, one host suspend leaves the CDC/ACM port permanently -ENOTCONN; after, ten forced suspend/resume cycles all recover with the MAVLink stream intact. The remaining drivers carry a line-for-line copy of the same initialisation. Assisted-by: Claude:claude-fable-5 Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
dakejahl
force-pushed
the
fix/otg-device-unmask-wkup
branch
from
August 24, 2026 17:23
3e56a15 to
6dcc761
Compare
xiaoxiang781216
previously approved these changes
Aug 24, 2026
nxstyle now checks case labels against their enclosing brace, and the DWC2-derived OTG device drivers align every case label with the switch brace itself, so any change that touches one of these files fails checkpatch on hundreds of pre-existing lines. Indent the switch bodies by two columns as the standard requires and re-wrap the lines that this pushes past the width limit. Whitespace and comment re-flow only; no code changes. Assisted-by: Claude:claude-fable-5 Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
dakejahl
force-pushed
the
fix/otg-device-unmask-wkup
branch
from
August 24, 2026 17:42
0155b91 to
88e9ad1
Compare
Contributor
Author
|
Not really sure what's going on with the CI checks. Running locally is producing different results than the workflow. My Claude can't seem to figure it out which is surprising. |
xiaoxiang781216
approved these changes
Aug 25, 2026
jerpelea
approved these changes
Aug 25, 2026
eren-terzioglu
approved these changes
Aug 25, 2026
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
Fixes PX4/PX4-Autopilot#28340
The Synopsys DWC2-derived USB device drivers enable
USBSUSPinGINTMSKbut notWKUP, and every one of them ANDsGINTSTSwithGINTMSKat the top of its ISR before dispatching. TheWKUPbranch and the*_resumeinterrupt()it calls are therefore dead code:CLASS_SUSPENDis delivered,CLASS_RESUMEnever is.For CDC/ACM the asymmetry is fatal rather than merely lossy.
cdcacm_suspend()callsuart_connected(&priv->serdev, false), and from then onserial.crefuses every board-sideopen()andwrite()with-ENOTCONN. Thecdcacm_resume()that would calluart_connected(true)never runs, so the port stays unusable for the rest of the boot even though the device remains enumerated and the host has long since resumed it.Adding
WKUPto the mask makes the existing handler reachable. The status bit is already acknowledged in the same read/ack cycle as the rest of the writable interrupts, so unmasking it cannot latch.The host-side check used to characterise this is in review for nuttx-ntfc-testing: apache/nuttx-ntfc-testing#4
Impact
Affects any board whose USB device controller is one of these eight drivers and whose host suspends it. Linux hosts do that by default: with
power/control=autoand the usualautosuspend_delay_ms=2000, closing the tty is enough. Software that opens, reads and closes the port — as opposed to holding it open — kills the link on the first close, which is why this reads as an intermittent wedge rather than a deterministic bug.No configuration, API or wire-format change. One extra interrupt source per suspend/resume, handled by code already present.
Drivers touched:
Testing
Host: Linux 7.0.0-28-generic x86_64, xhci_hcd,
usbcore.autosuspend=2.Board: ARK FMU v6X (STM32H743),
CONFIG_STM32H7_OTGFS=y,CONFIG_CDCACM=y(whichselectsSERIAL_REMOVABLE), NuttX 11.0.0 under PX4. Console on a separate STLINK-V3 VCP so it survives the CDC port dying.Only the STM32H7 path was exercised on hardware. The other seven drivers carry a line-for-line copy of the same
GINTMSKinitialisation and the same masked-off resume handler.Each cycle below forces a verified runtime suspend, resumes the device by opening the port, reads for 2 s, then asks the board over its console whether the CDC port is writable again.
Before:
The 12179 bytes on the first cycle are the stale
CONFIG_CDCACM_TXBUFSIZE=12000TX buffer flushing on resume, not a working link — hencetail=0, the bytes seen in the last second of the window.After:
Board side on the unpatched build, after a single host suspend, the port is gone for good:
Patched, the same command succeeds once the host resumes, and a 22 s suspend is followed by full recovery of the CDC stream (
tx 21946 B/s,txerr 0.0 B/s, 217 kB read by the host over the following 10 s).Build-tested beyond STM32H7:
cubepilot_cubeyellow(stm32f7 OTGFS),airmind_mindpx-v2(common/stm32 OTGFS),matek_gnss-m9n-f4(common/stm32 OTGHS)../tools/checkpatch.sh -c -u -m -g master..HEADpasses.