Skip to content

hid-service: fix passthrough failure handling and configure buffer sizes - #990

Merged
felipebalbi merged 4 commits into
OpenDevicePartnership:stable-v0.1.yfrom
felipebalbi:fix/hid-passthrough-recovery
Nov 21, 2026
Merged

felipebalbi merged 4 commits into
OpenDevicePartnership:stable-v0.1.yfrom
felipebalbi:fix/hid-passthrough-recovery

Conversation

@felipebalbi

@felipebalbi felipebalbi commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor
  • Complete failed HID passthrough requests instead of leaving the host waiting.
  • Fix interrupt completion races and validate completion routing.
  • Make host and device buffer capacities independently configurable, preserving defaults.
  • Add regression tests for failure recovery, interrupt handling, and buffer sizing.

Closes #987
Closes #989

@felipebalbi
felipebalbi changed the base branch from main to stable-v0.1.y November 19, 2026 17:36
@felipebalbi

Copy link
Copy Markdown
Contributor Author

This PR must wait for #984 to be merged!

@felipebalbi
felipebalbi marked this pull request as ready for review November 19, 2026 18:48
@felipebalbi
felipebalbi requested review from a team as code owners November 19, 2026 18:48
@felipebalbi
felipebalbi requested review from RobertZ2011, kurtjd, tullom, williampMSFT and wmmc88 and a balanced review from Copilot November 19, 2026 18:48
@felipebalbi
felipebalbi enabled auto-merge (squash) November 19, 2026 18:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The response can complete before the upstream interrupt pin is deasserted, risking a spurious host interrupt; a deassertion acknowledgement and an integration test verifying the ordering are needed.

1 open issue
What changed in this PR

Builds on #984’s descriptor-refresh work to improve HID-over-I2C passthrough failure handling and support larger descriptors and host commands, addressing the buffer limits described in #987 and #989.

Changes:

  • Adds explicit device-failure completions and validates completion routing before waking the host.
  • Updates interrupt completion handling and adds regression tests for recovery, scheduling, and buffer boundaries.
  • Makes device and host buffer capacities independently configurable while preserving the 512-byte and 128-byte defaults.
File Description
hid-service/​src/​i2c/​passthrough/​mod.rs Adds buffer-size options, awaits interrupt operations, and tests macro configurations.
hid-service/​src/​i2c/​passthrough/​interrupt.rs Handles coalesced completion signals and adds interrupt-state regression tests.
hid-service/​src/​i2c/​host.rs Accepts failure completions and validates destination and device identity.
hid-service/​src/​i2c/​device.rs Refreshes descriptor metadata, reports request failures, and adds bridge and capacity tests.
hid-service/​Cargo.toml Adds dependencies for host-side async tests.
embedded-service/​src/​hid/​mod.rs Introduces the shared HID failure message and sending API.
Cargo.lock Records the added HID-service test dependencies.

Review effort: Balanced

Comment thread hid-service/src/i2c/passthrough/mod.rs Resolved
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
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
felipebalbi added a commit to felipebalbi/embedded-services that referenced this pull request Nov 19, 2026
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
@felipebalbi
felipebalbi force-pushed the fix/hid-passthrough-recovery branch from 0053ae1 to f837fb2 Compare November 19, 2026 21:15
kurtjd
kurtjd previously approved these changes Nov 19, 2026
@RobertZ2011

Copy link
Copy Markdown
Contributor

What's the difference between this PR and #991? It looks like the commits here are the last three commits in that PR.

@felipebalbi

Copy link
Copy Markdown
Contributor Author

What's the difference between this PR and #991? It looks like the commits here are the last three commits in that PR.

target branch. #984 and #990 target stable-v0.1.y while #991 targets main. Glad to drop either and leave the bug in place.

Pull in the comments from PR OpenDevicePartnership#991 explaining interrupt test
polling phases and the deprecated deassert API migration window.
@felipebalbi
felipebalbi merged commit 995c234 into OpenDevicePartnership:stable-v0.1.y Nov 21, 2026
15 checks passed
@github-project-automation github-project-automation Bot moved this to Done in EC Nov 21, 2026
felipebalbi added a commit that referenced this pull request Nov 23, 2026
Bring the fixes from #984 and #990 to `main`, preserving original
commits and authors.

- Refresh HID metadata and fix passthrough failure, routing, and
interrupt handling.
- Make host/device buffer capacities configurable.
- Require main-first integration checks for stable backports.

Validated: workspace tests, formatting, Clippy, and affected-crate
host/ARM feature checks.

Closes #987
Closes #989

---------

Co-authored-by: Yourong Tang <yourongtang@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

5 participants