From 1b91c544f93edce551989778c34b4a717d7e2fae Mon Sep 17 00:00:00 2001 From: Sudeep Mohanty Date: Mon, 25 Aug 2025 10:41:22 +0200 Subject: [PATCH] fix(freertos-smp): Always take ISR locks in vTaskEnter/ExitCriticalFromISR --- tasks.c | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/tasks.c b/tasks.c index 43bb1ea76..23ccd6b8e 100644 --- a/tasks.c +++ b/tasks.c @@ -7582,10 +7582,18 @@ static void prvResetNextTaskUnblockTime( void ) { uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); - if( portGET_CRITICAL_NESTING_COUNT( xCoreID ) == 0U ) + #if ( portUSING_GRANULAR_LOCKS == 1 ) { kernelGET_ISR_LOCK( xCoreID ); } + #else /* portUSING_GRANULAR_LOCKS */ + { + if( portGET_CRITICAL_NESTING_COUNT( xCoreID ) == 0U ) + { + kernelGET_ISR_LOCK( xCoreID ); + } + } + #endif /* portUSING_GRANULAR_LOCKS */ portINCREMENT_CRITICAL_NESTING_COUNT( xCoreID ); } @@ -7775,17 +7783,28 @@ static void prvResetNextTaskUnblockTime( void ) if( portGET_CRITICAL_NESTING_COUNT( xCoreID ) > 0U ) { - portDECREMENT_CRITICAL_NESTING_COUNT( xCoreID ); - - if( portGET_CRITICAL_NESTING_COUNT( xCoreID ) == 0U ) + #if ( portUSING_GRANULAR_LOCKS == 1 ) { kernelRELEASE_ISR_LOCK( xCoreID ); - portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); + + portDECREMENT_CRITICAL_NESTING_COUNT( xCoreID ); + + if( portGET_CRITICAL_NESTING_COUNT( xCoreID ) == 0U ) + { + portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); + } } - else + #else /* portUSING_GRANULAR_LOCKS */ { - mtCOVERAGE_TEST_MARKER(); + portDECREMENT_CRITICAL_NESTING_COUNT( xCoreID ); + + if( portGET_CRITICAL_NESTING_COUNT( xCoreID ) == 0U ) + { + kernelRELEASE_ISR_LOCK( xCoreID ); + portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); + } } + #endif /* portUSING_GRANULAR_LOCKS */ } else {