From 730310e227604240468b5c51771c23061a4dbd94 Mon Sep 17 00:00:00 2001 From: Gaurav Aggarwal Date: Mon, 30 Dec 2024 06:45:18 +0000 Subject: [PATCH] Code review suggestions Signed-off-by: Gaurav Aggarwal --- portable/CCRH/F1Kx/portmacro.h | 8 ++++---- portable/ThirdParty/GCC/RP2040/include/portmacro.h | 8 ++++---- portable/ThirdParty/xClang/XCOREAI/portmacro.h | 8 ++++---- tasks.c | 5 +++++ 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/portable/CCRH/F1Kx/portmacro.h b/portable/CCRH/F1Kx/portmacro.h index c2b499f247..a665ad23d2 100644 --- a/portable/CCRH/F1Kx/portmacro.h +++ b/portable/CCRH/F1Kx/portmacro.h @@ -149,10 +149,10 @@ extern void vPortRecursiveLockAcquire( BaseType_t xCoreID, BaseType_t xFromIsr ); extern void vPortRecursiveLockRelease( BaseType_t xCoreID, BaseType_t xFromIsr ); - #define portGET_ISR_LOCK( xCoreID ) vPortRecursiveLockAcquire( xCoreID, pdTRUE ) - #define portRELEASE_ISR_LOCK( xCoreID ) vPortRecursiveLockRelease( xCoreID, pdTRUE ) - #define portGET_TASK_LOCK( xCoreID ) vPortRecursiveLockAcquire( xCoreID, pdFALSE ) - #define portRELEASE_TASK_LOCK( xCoreID ) vPortRecursiveLockRelease( xCoreID, pdFALSE ) + #define portGET_ISR_LOCK( xCoreID ) vPortRecursiveLockAcquire( ( xCoreID ), pdTRUE ) + #define portRELEASE_ISR_LOCK( xCoreID ) vPortRecursiveLockRelease( ( xCoreID ), pdTRUE ) + #define portGET_TASK_LOCK( xCoreID ) vPortRecursiveLockAcquire( ( xCoreID ), pdFALSE ) + #define portRELEASE_TASK_LOCK( xCoreID ) vPortRecursiveLockRelease( ( xCoreID ), pdFALSE ) #endif /* if ( configNUMBER_OF_CORES == 1 ) */ /*-----------------------------------------------------------*/ diff --git a/portable/ThirdParty/GCC/RP2040/include/portmacro.h b/portable/ThirdParty/GCC/RP2040/include/portmacro.h index 7dc48c0746..802470e33f 100644 --- a/portable/ThirdParty/GCC/RP2040/include/portmacro.h +++ b/portable/ThirdParty/GCC/RP2040/include/portmacro.h @@ -255,10 +255,10 @@ static inline void vPortRecursiveLock( BaseType_t xCoreID, #define portGET_TASK_LOCK( xCoreID ) #define portRELEASE_TASK_LOCK( xCoreID ) #else - #define portGET_ISR_LOCK( xCoreID ) vPortRecursiveLock( xCoreID, 0, spin_lock_instance( configSMP_SPINLOCK_0 ), pdTRUE ) - #define portRELEASE_ISR_LOCK( xCoreID ) vPortRecursiveLock( xCoreID, 0, spin_lock_instance( configSMP_SPINLOCK_0 ), pdFALSE ) - #define portGET_TASK_LOCK( xCoreID ) vPortRecursiveLock( xCoreID, 1, spin_lock_instance( configSMP_SPINLOCK_1 ), pdTRUE ) - #define portRELEASE_TASK_LOCK( xCoreID ) vPortRecursiveLock( xCoreID, 1, spin_lock_instance( configSMP_SPINLOCK_1 ), pdFALSE ) + #define portGET_ISR_LOCK( xCoreID ) vPortRecursiveLock( ( xCoreID ), 0, spin_lock_instance( configSMP_SPINLOCK_0 ), pdTRUE ) + #define portRELEASE_ISR_LOCK( xCoreID ) vPortRecursiveLock( ( xCoreID ), 0, spin_lock_instance( configSMP_SPINLOCK_0 ), pdFALSE ) + #define portGET_TASK_LOCK( xCoreID ) vPortRecursiveLock( ( xCoreID ), 1, spin_lock_instance( configSMP_SPINLOCK_1 ), pdTRUE ) + #define portRELEASE_TASK_LOCK( xCoreID ) vPortRecursiveLock( ( xCoreID ), 1, spin_lock_instance( configSMP_SPINLOCK_1 ), pdFALSE ) #endif /*-----------------------------------------------------------*/ diff --git a/portable/ThirdParty/xClang/XCOREAI/portmacro.h b/portable/ThirdParty/xClang/XCOREAI/portmacro.h index 3602e8b167..0881333148 100644 --- a/portable/ThirdParty/xClang/XCOREAI/portmacro.h +++ b/portable/ThirdParty/xClang/XCOREAI/portmacro.h @@ -152,10 +152,10 @@ #define portASSERT_IF_IN_ISR() configASSERT( portCHECK_IF_IN_ISR() == 0 ) - #define portGET_ISR_LOCK( xCoreID ) do{ ( void )( xCoreID ); rtos_lock_acquire( 0 ) ); } while( 0 ) - #define portRELEASE_ISR_LOCK( xCoreID ) do{ ( void )( xCoreID ); rtos_lock_release( 0 ) ); } while( 0 ) - #define portGET_TASK_LOCK( xCoreID ) do{ ( void )( xCoreID ); rtos_lock_acquire( 1 ) ); } while( 0 ) - #define portRELEASE_TASK_LOCK( xCoreID ) do{ ( void )( xCoreID ); rtos_lock_release( 1 ) ); } while( 0 ) + #define portGET_ISR_LOCK( xCoreID ) do{ ( void )( xCoreID ); rtos_lock_acquire( 0 ); } while( 0 ) + #define portRELEASE_ISR_LOCK( xCoreID ) do{ ( void )( xCoreID ); rtos_lock_release( 0 ); } while( 0 ) + #define portGET_TASK_LOCK( xCoreID ) do{ ( void )( xCoreID ); rtos_lock_acquire( 1 ); } while( 0 ) + #define portRELEASE_TASK_LOCK( xCoreID ) do{ ( void )( xCoreID ); rtos_lock_release( 1 ); } while( 0 ) void vTaskEnterCritical( void ); diff --git a/tasks.c b/tasks.c index 4090f445b7..d7153f680e 100644 --- a/tasks.c +++ b/tasks.c @@ -3892,6 +3892,11 @@ void vTaskSuspendAll( void ) mtCOVERAGE_TEST_MARKER(); } + /* Query the coreID again as prvCheckForRunStateChange may have + * caused the task to get scheduled on a different core. The correct + * task lock for the core is acquired in prvCheckForRunStateChange. */ + xCoreID = ( BaseType_t ) portGET_CORE_ID(); + portGET_ISR_LOCK( xCoreID ); /* The scheduler is suspended if uxSchedulerSuspended is non-zero. An increment