Skip to content

platform/chrome: cros_ec_proto: Harden query_all() and retries

Tzung-Bi Shih chrome-platform 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest9 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9platform/chrome: cros_ec_proto: Reset msg->result before sending commanddrivers/platform/chrome/cros_ec_proto.c+2 -00 replies
2/9platform/chrome: cros_ec_proto: Retry sending command on -EAGAINdrivers/platform/chrome/cros_ec_proto.c+15 -20 replies
3/9platform/chrome: KUnit: Add tests for retrying commands on -EAGAINdrivers/platform/chrome/cros_ec_proto_test.c+42 -00 replies
4/9platform/chrome: cros_ec_proto: Reallocate din/dout buffers atomicallydrivers/platform/chrome/cros_ec_proto.c+32 -260 replies
5/9platform/chrome: cros_ec_proto: Guard protocol v2 fallbackdrivers/platform/chrome/cros_ec_proto.c+40 -150 replies
6/9platform/chrome: KUnit: Update test cases for protocol v2drivers/platform/chrome/cros_ec_proto_test.c+4 -680 replies
7/9platform/chrome: KUnit: Add test cases for protocol fallbackdrivers/platform/chrome/cros_ec_proto_test.c+119 -40 replies
8/9platform/chrome: cros_ec_proto: Propagate feature probe errorsdrivers/platform/chrome/cros_ec_proto.c drivers/platform/chrome/cros_ec_proto_test.c+55 -430 replies
9/9platform/chrome: KUnit: Add feature probe unsupported testsdrivers/platform/chrome/cros_ec_proto_test.c+191 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/9] platform/chrome: cros_ec_proto: Harden query_all() and retries

This series hardens ChromeOS EC command transmission and cros_ec_query_all() against transient transport errors (such as -EAGAIN) and buffer reallocation hazards:

- Patches 1-2: Reset msg->result before each transfer and retry transient -EAGAIN errors in cros_ec_send_command() and EC_CMD_RESEND_RESPONSE polling.

- Patch 4: Reallocate din/dout safely with devm_krealloc() directly when protocol info arrives, preventing din_size/dout_size OOB mismatches, -ENOMEM dangling pointers, and runtime reallocation churn.

- Patch 5: Guard protocol v3-to-v2 fallback so transient errors, v3-only transports, or runtime re-queries on registered v3 devices do not downgrade the EC to v2.

- Patch 8: Distinguish -EOPNOTSUPP from real transport/protocol errors when probing MKBP, host sleep v1, and wake mask, propagating real errors and resetting proto_version so the next transfer re-queries.

New KUnit test cases and non-breaking test cleanups are kept in separate patches (patches 3, 6, 7, and 9). In patch 8, updates to existing KUnit tests are folded into the code change itself so that the test suite remains passing at every commit for bisectability.

Tzung-Bi Shih (9):
platform/chrome: cros_ec_proto: Reset msg->result before sending
command
platform/chrome: cros_ec_proto: Retry sending command on -EAGAIN platform/chrome: KUnit: Add tests for retrying commands on -EAGAIN platform/chrome: cros_ec_proto: Reallocate din/dout buffers atomically platform/chrome: cros_ec_proto: Guard protocol v2 fallback platform/chrome: KUnit: Update test cases for protocol v2 platform/chrome: KUnit: Add test cases for protocol fallback platform/chrome: cros_ec_proto: Propagate feature probe errors platform/chrome: KUnit: Add feature probe unsupported tests

 drivers/platform/chrome/cros_ec_proto.c      | 167 +++++---
 drivers/platform/chrome/cros_ec_proto_test.c | 429 +++++++++++++++----
 2 files changed, 469 insertions(+), 127 deletions(-)
Signature · 1 line
2.56.1.831.g720f3f5937-goog