Repository navigation
agent: a READY never extends a wait, so a lost command cannot hang the host - #152
Merged
Merged
Conversation
…e host `defib agent flash` sat 12 minutes on hi3536dv100 (Xiongmai NBD8010S-KL-V2) with nothing written. The process read ~100 bytes/s and wrote nothing after the upload. The agent sends READY only from its idle loop (agent/main.c: every ~2 s with no command in hand, never while one is handled). recv_response() restarted its deadline on every READY, and write_flash, read_memory, erase_flash and scan_flash waited with recv_packet() and `if cmd == RSP_READY: continue`. So when a command was lost, the idle agent's beacons kept every wait alive and the host never timed out. - recv_response() skips READY but keeps one deadline. READYs queued before the response are still read past (the case the old reset was for, from #20): they take microseconds, not the budget. - The five client waits use recv_response(), so each has its own fixed deadline (60 s per read packet, 30 s per erase or scan step, 120 s per stream sector and for the final ACK). A lost command is now a TransportTimeout instead of a hang. The "Bug 3" regression test re-implemented the old reset loop instead of calling recv_response. It now runs the real recv_response against an agent that beacons every 20 ms forever, and must time out within its deadline. Without this change it hangs until wait_for gives up at 3 s. Five queued READYs before an ACK still come through. On the board: agent upload --power-cycle, then write_flash of the board's own 16 MiB image (143 s, True), read_memory, a full-chip crc32 equal to the image, scan_flash, reboot; OpenIPC came back up. A second CLI-timed run (write_flash ~2 s after READY, as _agent_flash_async does) also succeeded, so the lost command itself is intermittent. The hang it caused is what this fixes. scan_flash's per-sector CRCs on this SoC repeat every 16 sectors: it reads through a window that wraps at 1 MiB, while CMD_READ and CMD_CRC32 are correct. That is a separate agent bug, not touched here.
PR Summary by QodoPrevent idle READY beacons from extending agent response waits
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can pick a display mode instead of tweaking every Display option by hand |
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.
defib agent flashsat 12 minutes on hi3536dv100 (Xiongmai NBD8010S-KL-V2)with nothing written. The process read ~100 bytes/s and wrote nothing
after the upload. The agent sends READY only from its idle loop
(agent/main.c: every ~2 s with no command in hand, never while one is
handled). recv_response() restarted its deadline on every READY, and
write_flash, read_memory, erase_flash and scan_flash waited with
recv_packet() and
if cmd == RSP_READY: continue. So when a commandwas lost, the idle agent's beacons kept every wait alive and the host
never timed out.
before the response are still read past (the case the old reset
was for, from Enable MMU + D-cache: fix sustained host→device WRITE #20): they take microseconds, not the budget.
deadline (60 s per read packet, 30 s per erase or scan step, 120 s
per stream sector and for the final ACK). A lost command is now a
TransportTimeout instead of a hang.
The "Bug 3" regression test re-implemented the old reset loop instead
of calling recv_response. It now runs the real recv_response against an
agent that beacons every 20 ms forever, and must time out within its
deadline. Without this change it hangs until wait_for gives up at 3 s.
Five queued READYs before an ACK still come through.
On the board: agent upload --power-cycle, then write_flash of the
board's own 16 MiB image (143 s, True), read_memory, a full-chip crc32
equal to the image, scan_flash, reboot; OpenIPC came back up. A second
CLI-timed run (write_flash ~2 s after READY, as _agent_flash_async
does) also succeeded, so the lost command itself is intermittent. The
hang it caused is what this fixes.
scan_flash's per-sector CRCs on this SoC repeat every 16 sectors: it
reads through a window that wraps at 1 MiB, while CMD_READ and CMD_CRC32
are correct. That is a separate agent bug, not touched here.