hid-service: recover failed upstream passthrough exchanges

Open
#992 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
20/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
rust
Domain
embedded-iot

Research direction

Start at hid-service/src/i2c/mod.rs, where I2cSlaveAsync lacks recovery, and trace Host::process() through the upstream-read lifecycle; the MCXA HAL's recover() is the reference. Reproduce with the scripted upstream bus sequence in the issue and inspect the existing bridge recovery tests, which assume an aborted exchange. Done means a failed exchange is retired before the next request, a fresh request works after recovery, and a deterministic regression covers the retained pending read.

Written by the indexing model from the issue text.

Description

Problem

A downstream descriptor failure completes the internal request, but the upstream read can remain pending. The next host-loop iteration treats that read as a new input-report request and can send input-report bytes where the OS expects a descriptor.

The missing upstream recovery predates #990; its failure completions fix the hang and expose this sequence. The same gap is present in #991. This is separate from the interrupt-deassertion ordering fix.

Reproduction

Reproduced with the real Host and a scripted upstream bus on a single cooperative executor; no hardware was used:

  1. Upstream writes descriptor register [01 00], followed by a pending READ.
  2. Downstream descriptor request fails with Timeout.
  3. Host::process() returns the error without consuming or retiring the READ.
  4. The next Host::process() treats it as Request::InputReport.
  5. Input bytes [04 00 52 A5] are delivered on the descriptor read.

Existing bridge recovery tests assume the upstream exchange was aborted and do not retain this pending read.

Decision needed

The MCXA target HAL provides recover(), but the legacy hid-service/src/i2c/mod.rs::I2cSlaveAsync trait does not expose recovery. Obtain feedback from existing platform users before choosing the integration contract, including compatibility with stable-v0.1.y. A no-op or logging-only default does not establish recovery.

Acceptance criteria

  • Retire the failed upstream exchange before accepting another request; never reinterpret its pending read as an input-report request.
  • Permit a fresh request after successful recovery. Failed recovery must not allow stale phases to be reused.
  • Add a deterministic bridge regression retaining the pending read, checking that no input-report data is sent for it, and exercising a subsequent fresh request.
  • Document the platform recovery requirements and stable-branch compatibility approach. Keep software-only tests distinct from physical controller validation.

Deferred from the #991 review thread, as agreed with Robert.

Related: #990, #991, #987.

Dominant language
Rust
Stars
25
Forks
54
Avg merge
3d 9h
Merged PRs (30d)
7

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from OpenDevicePartnership/embedded-services

All issues in OpenDevicePartnership/embedded-services

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.