Repository navigation
hid-service: bring #984 and #990 fixes to main - #991
felipebalbi merged 10 commits into
Conversation
Refresh HID metadata for both HID and report descriptor reads while retaining cached metadata for input reports and commands. Invalidate the cache before refreshing so a failed or cancelled metadata read cannot leave stale metadata available for reuse. Replace the descriptor's async mutex with SyncCell. Descriptor is Copy, and cache accesses only copy, invalidate, or publish a complete value. No cache reference or guard is held across an await, so cache access does not need an async mutex. SyncCell uses critical sections on the host and the existing single-core thread-mode model on bare-metal ARM. Keep the async bus mutex because I2C transactions hold mutable access across await. SyncCell protects individual cache accesses, not the complete refresh sequence. Operations on a Device must remain serialized, as in the passthrough request loop; the old cache mutex did not serialize complete refreshes either. Document this requirement and the cache lifetime. While at that , also add inline behavioral tests for current descriptor bytes, refreshed registers and lengths, warm cache reuse, lazy initialization, and invalidation after errors, timeouts, and cancellation.
Add a literal application HID descriptor from the ELAN HC4909-20H5V0 I2C Programming Guide v1.0, section 2.1. Test the 1129-byte report length and the 1128/1129 storage boundary using sections 3.2 and 3.3. Follow the numeric input length and layout in section 4.2, not the conflicting prose annotation. Exercise the real Host, comms routing, and Device with a scripted version change and descriptor requests. Check actual upstream bytes after each request, including cached input and command handling. Only the physical I2C interfaces are doubled. Keep all tests inline and all production code unchanged. Cancel descriptor futures after partial metadata and report writes, then verify fresh command metadata, released software resources, and a complete report retry. Mutation checks confirm that truncating the length, returning cached HID metadata, or omitting invalidation breaks the new tests. The host sequence, updated version, and opaque report payloads are synthetic, not captured bootloader/application behavior. Paired mode descriptors and actual OS/update-tool re-enumeration ordering still need vendor or device/system evidence. Reset/interrupt timing from section 3.5.2 is not established by these tests. Cancellation exercises Rust futures and software state, not the deployed HAL or controller. STOP generation, DMA cleanup, and touchpad readiness for the next transfer still need HAL-specific and on-target validation. No touchpad hardware was available. Existing passthrough capacity and missing error-completion issues remain separate software follow-ups, not hardware-only uncertainties. Scoped tests pass: 83 unit tests and one doctest. Full workspace tests remain blocked on Windows/MSVC by existing debug-service defmt and espi-service ARM linker symbols.
Send explicit HID failure completions when a consumed request returns an error. Distinguish failures from successful commands with no response, preserve portable HID errors for the host, and retain original HAL/buffer errors for device-side logging. Validate completion destination and device ID before waking the host. Keep request processing serialized; do not introduce host timeouts that could confuse late, uncorrelated responses. Add compile-time device-buffer overrides to passthrough macros. Keep the legacy 512-byte allocation; integrations can select 1129 bytes for the ELAN HC4909-20H5V0 report descriptor documented in I2C Programming Guide v1.0, sections 2.1 and 3.3. The separate 128-byte host buffer is unchanged. Await interrupt-state requests in generated host tasks. Handle coalesced completion, idle reset, and notifications posted between consumption and state inspection without leaking them into the next interrupt exchange. Pin failure/retry behavior, routing, actual macro allocations, and interrupt output transitions with inline behavioral tests. Expand both composite macro forms in compile fixtures. MessageData gains a public Failure variant; downstream exhaustive matches may need updating. This is not a HID wire-format change. Cancellation and physical controller abort/resynchronization remain caller/HAL responsibilities. Validation: 89 scoped unit tests and one doctest pass; formatting, Clippy, workspace checking, and ARM Clippy pass. Full workspace tests remain blocked on Windows/MSVC by existing debug-service defmt and espi-service ARM linker failures. Refs: OpenDevicePartnership#987
Add an optional buffer_size to the generated host task and forward host_buffer_size independently through the composite macro. Keep the 128-byte legacy allocation and existing device-size option. The ELAN HC4909-20H5V0 I2C Programming Guide v1.0, sections 3.5 and 3.5.5 Figure 12, documents an IAP frame with length 0x0083. Let integrations select sufficient storage for that 131-byte example without treating it as the maximum for every possible command. Leave parser bounds checks and device response storage unchanged. Run the real composite-generated host task against a complete scripted IAP packet. Verify the forwarded feature request and all payload bytes, successful completion, and acceptance of the next command. Check rejection with 128/130-byte buffers and compile all four combinations of legacy, device, host, and combined options. Payload contents and the host sequence are synthetic. These tests establish software ingress capacity, not physical touchpad update success, actual OS sequencing, or controller recovery. No hardware corroboration is claimed and no OpenDevicePartnership#988 length adjustment is made. Validation: 89 scoped unit tests and one doctest pass. Formatting, Clippy, workspace checking, and ARM Clippy pass. Full workspace tests retain the existing Windows/MSVC linker failures in debug-service and espi-service. Refs: OpenDevicePartnership#989
Call the helper macros through their defining crate instead of importing them into the generated module. On main the imports are reported as unused when the deprecated service's composite macro expands in tests. Keep this main-specific integration adjustment separate from the original commits ported from OpenDevicePartnership#984 and OpenDevicePartnership#990. Assisted-by: OpenCode:gpt-6.1-sol
Make Copilot review verify that stable-* changes backport PRs already merged into main and that their fixes remain present there. Report missing main fixes as high-severity issues and require evidence when integration cannot be verified. Require original PR and commit references in stable review summaries. Allow necessary stable API adaptations and different cherry-pick SHAs. Validated behavior against an unmerged main PR, a valid adapted backport, unavailable history, a main-targeting PR, and a reverted fix. Assisted-by: OpenCode:gpt-6.1-sol
There was a problem hiding this comment.
🟡 Changes recommended
Critical error-recovery flaws can send input-report bytes during a pending descriptor read and lose a concurrent reset, leaving the interrupt asserted without notification.
2 open issues
What changed in this PR
Brings the HID passthrough fixes from #984 and #990 to main. The changes refresh descriptor metadata, improve request completion handling, and allow larger transfers without changing default buffer sizes.
Changes:
- Refresh metadata on descriptor requests while retaining cached metadata for input reports and commands.
- Add failure notifications, completion-routing checks, interrupt-race handling, and regression tests.
- Make host/device buffer capacities independently configurable and document main-first requirements for stable backports.
| File | Description |
|---|---|
hid-service/src/i2c/passthrough/mod.rs |
Adds configurable buffer capacities and awaits interrupt operations. |
hid-service/src/i2c/passthrough/interrupt.rs |
Updates interrupt completion handling and adds race regressions. |
hid-service/src/i2c/host.rs |
Handles device failures and validates completion destinations and device IDs. |
hid-service/src/i2c/device.rs |
Refreshes metadata, reports failures, and adds device/bridge regression tests. |
hid-service/Cargo.toml |
Adds host-test dependencies. |
embedded-service/src/hid/mod.rs |
Adds explicit failure messages and a sending API. |
Cargo.lock |
Records added HID test dependencies. |
.github/skills/code-review/SKILL.md |
Documents main-first verification for stable backports. |
Review effort: Balanced
Drive the forwarded interrupt high before allowing the generated host task to process or answer a request. A notification alone does not establish that ordering on a cooperative executor. Deprecate the notification-only deassert method without changing its signature. Add deassert_and_wait with explicit GPIO error reporting, and release the output mutex while the interrupt task waits. Retain successful pin-level confirmation so interrupt cleanup cannot repeat a fallible HIGH write and reassert LOW during a pending response. Pin ordering through the real generated host task with its interrupt task deliberately unpolled. Cover GPIO failure without forwarding or responding, consecutive exchanges, idle notifications, failed-write retry, and cleanup after an already-confirmed deassertion. This does not address the separate upstream transaction-recovery gap. Refs: OpenDevicePartnership#990, OpenDevicePartnership#991 Assisted-by: OpenCode:gpt-6.1-sol
Drive the forwarded interrupt high before allowing the generated host task to process or answer a request. A notification alone does not establish that ordering on a cooperative executor. Deprecate the notification-only deassert method without changing its signature. Add deassert_and_wait with explicit GPIO error reporting, and release the output mutex while the interrupt task waits. Retain successful pin-level confirmation so interrupt cleanup cannot repeat a fallible HIGH write and reassert LOW during a pending response. Pin ordering through the real generated host task with its interrupt task deliberately unpolled. Cover GPIO failure without forwarding or responding, consecutive exchanges, idle notifications, failed-write retry, and cleanup after an already-confirmed deassertion. This does not address the separate upstream transaction-recovery gap. Refs: OpenDevicePartnership#990, OpenDevicePartnership#991 Assisted-by: OpenCode:gpt-6.1-sol
|
Another thing to keep in mind: this PR retains the deassert() API deprecated in #990. Since this targets the next stable release, we have three options:
Which migration policy do we want? @RobertZ2011 @OpenDevicePartnership/ec-hid-team |
I'm fine with 2 if we really don't want to do a breaking change right now. |
done |
Pull in the comments from PR OpenDevicePartnership#991 explaining interrupt test polling phases and the deprecated deassert API migration window.

Bring the fixes from #984 and #990 to
main, preserving original commits and authors.Validated: workspace tests, formatting, Clippy, and affected-crate host/ARM feature checks.
Closes #987
Closes #989