Skip to content

usb: gadget: f_ncm: retry a busy aggregation flush - #225

Draft
latentoperator wants to merge 2 commits into
derekross:omamobilefrom
latentoperator:omamobile-bluejay-ncm
Draft

latentoperator wants to merge 2 commits into
derekross:omamobilefrom
latentoperator:omamobile-bluejay-ncm

Conversation

@latentoperator

@latentoperator latentoperator commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

A full USB request pool can leave an NCM aggregation tail buffered. Retry a timer flush after NETDEV_TX_BUSY, track bus/function suspend in f_ncm, stop retries while suspended, and schedule a flush on resume.

The driver change and host-only callback selftest are now separate commits. The source-extracted test covers successful flush, repeated BUSY, suspend before/during transmit, resume and disconnect, and skips cleanly from an installed selftest tree without kernel sources unless KERNEL_SRC is supplied. The attended SSH transfer profile has moved to omarchy-mobile #666, whose revised tool passed local suites and sixteen USB transfers on both the historical and revised Bluejay kernels. Those transfers do not establish execution of a full-pool aggregation retry.

Keep draft for the maintainer's Pixel 7 Pro qualification, including laptop sleep with the phone attached. Revised-kernel ordinary transfers passed as described below; USB replug and suspend remain unqualified.

Runtime update — November 12–13, 2026

November 13 runtime follow-up:

Tested signed integration: 720a495233734e4328a09c33c095d72a8291e1c4, based on fc7086a68fcaaed8960d09f1bdf6c51c9926c759; uname -r = 7.3.0-rc6-omamobile-bluejay-review-20261111, with its matching Image, stage DTs and modules. This is an integration result containing the submitted changes, rather than a boot of each PR in isolation.

The final tools/ncm-transfer from mobile #666 (8ca0de9) passed all sixteen exact 2 MiB SHA-256-checked reads over USB on the revised kernel's w0 restricted-pool boot. This adds a revised-kernel ordinary-transfer result to the earlier historical-kernel tool validation. It does not show that the request pool filled or that the BUSY/aggregation retry path executed; no USB replug, phone suspend or laptop-sleep qualification is claimed.

The maintainer's Pixel 7 Pro/laptop-sleep gate remains, so this stays draft. These were attended headless stages with storage guards, a PID-1-owned 20-second watchdog, host logging and fresh SSH postchecks. They do not qualify the revised desktop/GPU path, native panel modesetting, suspend, endurance or a release installer. The historical graphical desktop has been restored. No kernel commit or DCO metadata changed; AUTO_WRITE=no and masked automatic boot-success remain in force.

Prior source/build validation

Validation on current upstream base fc7086a: independent source review found no remaining concrete blocker. The common integration passes policy, strict checkpatch without errors, W=1 builds of seven touched C files, ten Google device trees with no new dtbs_check warnings and four binding checks. New-file coverage warnings and one continuation-alignment check are disclosed. A full Image, Bluejay DTB and 1,828 modules also build for 7.3.0-rc6-omamobile-bluejay-review-20261111; matching dependency indexes and module resolution pass. The full build reports two format warnings in unchanged AoC ALSA code.

The human certified the final patches under DCO on November 11. Independent checks verify every author sign-off, all 22 commit objects including integration copies, and identical source trees and exact diffs before/after certification. Signing changed metadata only; the frozen source-build evidence remains applicable. Fresh published-head CI passed on 5291303165f3c9c881caf1c29bbe5aa629b6579c (sign-offs, checkpatch, W=1 and device-tree/binding gates as applicable).

The original tested source c934e31 and known-good phone setup remain preserved. AUTO_WRITE=no, the automatic boot-success mask and the GS101 slot-marking hold remain in force. No firmware, private captures, credentials, device identifiers or calibration data are submitted. Development/source status is documented in Bluejay UPSTREAM, with historical bring-up isolated in mobile #565.

@derekross

Copy link
Copy Markdown
Owner

Thank you, Chris — the stranded tail is a real bug and the fix is small. Because every phone's USB link goes through f_ncm, I'd like two things before it leaves draft: the retry shouldn't fire while the port is suspended (eth_start_xmit returns busy there too and wakes the host, so this would rearm every 300 µs for as long as the laptop sleeps), and I'll run it on the Pixel 7 Pro once it's bounded. Could you also add the transfer test you used?

@derekross

Copy link
Copy Markdown
Owner

Thank you, Chris. Tracking suspend in f_ncm itself is the right fix, and it stops the retry storm I worried about. Because this now adds suspend and resume handling to every phone's USB link, I'll run it on the Pixel 7 Pro (including a laptop sleep with the phone attached) before it leaves draft. Could you move the selftests into a separate commit? The SSH one needs a phone, so it probably fits better in the omarchy-mobile tree.

Retry a timer flush when the USB request pool returns NETDEV_TX_BUSY.
Track bus and function suspend through the function callbacks so a busy
flush cannot rearm every 300 us while the host sleeps. Resume schedules
one flush so an aggregation tail stopped by suspend can make progress.

Assisted-by: LLM
Signed-off-by: Chris Gray <chrisgray70@gmail.com>
Extract the production callbacks into a host fixture to exercise success,
repeated BUSY, suspend, suspend during transmit, resume and disconnect.
Skip an installed selftest tree without sources unless KERNEL_SRC is set.
The attended SSH transfer profile belongs in omarchy-mobile tooling.

Assisted-by: LLM
Signed-off-by: Chris Gray <chrisgray70@gmail.com>
@latentoperator

Copy link
Copy Markdown
Contributor Author

November 13 runtime follow-up:

Tested signed integration: 720a495233734e4328a09c33c095d72a8291e1c4, based on fc7086a68fcaaed8960d09f1bdf6c51c9926c759; uname -r = 7.3.0-rc6-omamobile-bluejay-review-20261111, with its matching Image, stage DTs and modules. This is an integration result containing the submitted changes, rather than a boot of each PR in isolation.

The final tools/ncm-transfer from mobile #666 (8ca0de9) passed all sixteen exact 2 MiB SHA-256-checked reads over USB on the revised kernel's w0 restricted-pool boot. This adds a revised-kernel ordinary-transfer result to the earlier historical-kernel tool validation. It does not show that the request pool filled or that the BUSY/aggregation retry path executed; no USB replug, phone suspend or laptop-sleep qualification is claimed.

The maintainer's Pixel 7 Pro/laptop-sleep gate remains, so this stays draft. These were attended headless stages with storage guards, a PID-1-owned 20-second watchdog, host logging and fresh SSH postchecks. They do not qualify the revised desktop/GPU path, native panel modesetting, suspend, endurance or a release installer. The historical graphical desktop has been restored. No kernel commit or DCO metadata changed; AUTO_WRITE=no and masked automatic boot-success remain in force.

@derekross

Copy link
Copy Markdown
Owner

Thank you, Chris. Splitting the selftest into its own commit and moving the SSH transfer to omarchy-mobile #666 is what I asked for. Tracking suspend in f_ncm stops the retry storm: ncm_suspend() cancels the timer, and the callback checks the flag before and after the transmit. Our gate passes on today's omamobile (2db2bc3): a clean merge, your sign-offs, checkpatch --strict, and a W=1 build of f_ncm.c.

The Pixel 7 Pro run is mine, as promised. I'll test today's omamobile with this PR only: ordinary transfers checked by hash, an interactive SSH session, then the laptop asleep for two minutes and for fifteen with the phone attached (with a reboot timer armed on the phone first), and a replug. I'll post the results here. I'm leaving the phone's own sleep out of this run, because on the 7 Pro that means suspend with the modem up, which needs its own session.

Two small notes. Only f_ecm calls gether_suspend(), so port.is_suspend never changes for NCM; the check is harmless, but your own flag is what does the work. And the selftest compiles functions cut out of f_ncm.c as text. That's fine in our tree, but it would break on a reformat and isn't the shape upstream uses (KUnit). If this goes upstream, and the stranded tail does look like an upstream bug, it's worth a look at linux-next's f_ncm.c first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants