From 9d0dccfd6c0415e03e547c0c54d630ef521f21eb Mon Sep 17 00:00:00 2001 From: Michael Pham <61564344+Mikefly123@users.noreply.github.com> Date: Thu, 23 Jul 2026 18:40:51 -0700 Subject: [PATCH] fix(radio_planner): exempt UNLOCK_RADIO_ACCESS from the failsafe panic The rp_callback() failsafe panics/reboots any task that has been RUNNING for more than 128 s, with an explicit exemption for RP_TASK_TYPE_LOCK_RADIO_ACCESS so a client holding the radio lock open indefinitely doesn't trip it. RP_TASK_TYPE_UNLOCK_RADIO_ACCESS was missing the same exemption. A lock task held open longer than the failsafe window (e.g. continuous RX under the raw RAC) keeps its original start_time_ms. When the client releases the lock, unlock_radio_access() retypes the still-RUNNING task from LOCK to UNLOCK before the engine processes it. The very next rp_callback() then evaluates the failsafe against that stale start_time_ms and panics at the exact moment the client releases the lock, causing a silent reboot after any lock held past 128 s. Add the same task-type exemption for RP_TASK_TYPE_UNLOCK_RADIO_ACCESS so the retype-on-release path is no longer misclassified as a hung task. --- smtc_rac_lib/radio_planner/src/radio_planner.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/smtc_rac_lib/radio_planner/src/radio_planner.c b/smtc_rac_lib/radio_planner/src/radio_planner.c index 2c44c68..a4c99d6 100644 --- a/smtc_rac_lib/radio_planner/src/radio_planner.c +++ b/smtc_rac_lib/radio_planner/src/radio_planner.c @@ -444,8 +444,15 @@ rp_stats_t rp_get_stats( const radio_planner_t* rp ) void rp_callback( radio_planner_t* rp ) { + // UNLOCK_RADIO_ACCESS must be exempt like LOCK_RADIO_ACCESS: a lock task + // held open longer than the failsafe window (e.g. continuous RX under the + // raw RAC) keeps its original start_time_ms, and unlock_radio_access + // retypes the still-RUNNING task to UNLOCK before the engine processes + // it — the very next rp_callback would evaluate the failsafe against the + // stale start time and panic at the moment the client releases the lock. if( ( rp->tasks[rp->radio_task_id].state == RP_TASK_STATE_RUNNING ) && ( rp->tasks[rp->radio_task_id].type != RP_TASK_TYPE_LOCK_RADIO_ACCESS ) && + ( rp->tasks[rp->radio_task_id].type != RP_TASK_TYPE_UNLOCK_RADIO_ACCESS ) && ( rp->disable_failsafe != RP_DISABLE_FAILSAFE_KEY ) && ( ( int32_t ) ( rp->tasks[rp->radio_task_id].start_time_ms + 128000 - smtc_modem_hal_get_time_in_ms( ) ) < 0 ) ) {