fix(registers): avoid widened xHCI MMIO accesses - #177
Open
ZR233 wants to merge 1 commit into
Open
Conversation
toku-sa-n
self-requested a review
July 25, 2026 05:40
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.
Problem
The aggregate volatile accessors for the Port Register Set and the Supported Protocol header expose 16-byte MMIO values. With Rust nightly 2026-07-15 on AArch64, those accesses can be lowered to widened transactions. The RK3588 DWC3 controller on OrangePi-5-Plus then stalls during xHCI initialization.
The xHCI 1.2c Requirements Specification Table 5-19 (§§5.4.8–5.4.11) defines the four port registers as Dwords at offsets
0x0,0x4,0x8, and0xcwith a0x10port stride. Figure 7-1 and Tables 7-6–7-9 (§7.2) define the Supported Protocol header as four Dwords.HCCPARAMS1.AC64(§5.3.6, Table 5-13) only says whether the high-order halves of 64-bit pointer/address fields are implemented; it does not change these 32-bit register sizes.Changes
port(index)andport_mut(index)handlers whose four fields are independent 32-bit accessorsHeaderAccessorthat reads four Dwords separately and reconstructs the existingHeadervalue in ordinary memoryRecordingMapperregression tests for both pathsThe common Supported Protocol call remains unchanged:
Port callers migrate from aggregate reads and updates:
to register-sized accessors:
Regression evidence
On the original implementation, both new tests failed with one 16-byte mapping:
Both tests pass after the change.
Validation
Passed locally:
cargo +stable fmt --all -- --checkcargo +stable testcargo +stable buildcargo +stable clippy --all-targetscargo +nightly-2026-07-15 testcargo +nightly-2026-07-15 check --target aarch64-unknown-none-softfloatcargo xtask clippy --package crab-usbcargo test -p crab-usb(33 tests)cargo xtask starry test board --board orangepi-5-plus(all 8 board groups passed, including xHCI enumeration and USB2lsusb)The requested strict Clippy command with
-D warnings -D clippy::pedantic -D clippy::allreports the same 39 pre-existing diagnostics on this branch and onupstream/main@f2254c86.RUSTDOCFLAGS="-D warnings" cargo +stable doc --no-depsis likewise blocked on the base commit by the renamedprivate_doc_testslint insrc/lib.rs. This change introduces no additional diagnostics in either check.This references #158 without closing it because the mapping-performance part remains unresolved. The broader capability-access audit is tracked in #176.