Skip to content

Commit 903a8c3

Browse files
snokvistclaude
andauthored
fix(star6e): settle between RGN detach and destroy in debug_osd_destroy (#79)
The OSD overlay region is attached to the live VPE channel (MI_RGN_AttachToChn on vpe_bind). debug_osd_destroy() called MI_RGN_DetachFromChn immediately followed by MI_RGN_Destroy, freeing the canvas while a VPE frame already mid-composite was still reading it. The VPE compositor (MMU client 0x15, IsWrite=0) then read the freed canvas → MMU read-fault storm → hardware watchdog reset on rapid same-mode respawn (3-157 faults/respawn, ~33% wedge rate observed on Star6E imx335). Add a usleep settle (default 50ms ≈ 3 frame intervals @ 60fps, overridable via VENC_OSD_DESTROY_SETTLE_US) between detach and destroy so the in-flight composite finishes before the canvas is freed. Device-validated on 192.168.1.13 (imx335): 14 consecutive same-mode /api/v1/restart respawns, 0 client-0x15 faults each, 0 wedges, RTP egress confirmed flowing after the respawn batch. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 5c552df commit 903a8c3

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

src/debug_osd.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@
1616
#include <stdlib.h>
1717
#include <string.h>
1818
#include <time.h>
19+
#include <unistd.h>
20+
21+
/* Settle between MI_RGN_DetachFromChn and MI_RGN_Destroy in
22+
* debug_osd_destroy(). The detach removes the region from the VPE
23+
* compositor's list, but a frame already mid-composite can still be reading
24+
* the RGN canvas; freeing it immediately races that read → MMU read-fault
25+
* (ClientId=0x15, IsWrite=0) that storms to a HW watchdog reset on rapid
26+
* respawn. ~3 frame intervals at 60fps covers the in-flight composite.
27+
* Overridable at build time for tuning. */
28+
#ifndef VENC_OSD_DESTROY_SETTLE_US
29+
#define VENC_OSD_DESTROY_SETTLE_US 50000
30+
#endif
1931

2032
/* ── MI_RGN types ──────────────────────────────────────────────────────
2133
* Defined locally because the SDK headers (sdk/ssc338q/include/i6_rgn.h)
@@ -327,6 +339,10 @@ void debug_osd_destroy(DebugOsdState *osd)
327339
{
328340
if (!osd) return;
329341
osd->fnDetachChannel(RGN_HANDLE, &osd->vpe_bind);
342+
/* Let any in-flight VPE composite finish reading the canvas before the
343+
* destroy frees it — closes the client-0x15 MMU read-fault race that
344+
* wedges rapid respawn (see VENC_OSD_DESTROY_SETTLE_US above). */
345+
usleep(VENC_OSD_DESTROY_SETTLE_US);
330346
osd->fnDestroyRegion(RGN_HANDLE);
331347
osd->fnDeinit();
332348
if (osd->lib)

0 commit comments

Comments
 (0)