From 3e0bb6734af1296e21af2716ebd12b8cbb718c29 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 9 May 2016 07:29:52 +0200 Subject: score: Ensure matching lock acquire and release Ensure matching lock acquire and release for SMP locks if RTEMS_DEBUG is defined. --- cpukit/score/include/rtems/score/smplock.h | 7 ++++--- cpukit/score/src/smplock.c | 13 ++++++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/cpukit/score/include/rtems/score/smplock.h b/cpukit/score/include/rtems/score/smplock.h index 0cefe38aa3..47797d3294 100644 --- a/cpukit/score/include/rtems/score/smplock.h +++ b/cpukit/score/include/rtems/score/smplock.h @@ -398,6 +398,9 @@ typedef struct { */ typedef struct { ISR_Level isr_level; +#if defined( RTEMS_DEBUG ) + SMP_lock_Control *lock_used_for_acquire; +#endif #if defined( RTEMS_PROFILING ) SMP_lock_Stats_context Stats_context; #endif @@ -578,11 +581,8 @@ void _SMP_lock_Release_and_ISR_enable( SMP_lock_Control *lock, SMP_lock_Context *context ); - -static inline void _SMP_lock_Release_and_ISR_enable_body( #else static inline void _SMP_lock_Release_and_ISR_enable( -#endif SMP_lock_Control *lock, SMP_lock_Context *context ) @@ -590,6 +590,7 @@ static inline void _SMP_lock_Release_and_ISR_enable( _SMP_lock_Release( lock, context ); _ISR_Enable_without_giant( context->isr_level ); } +#endif #if defined( RTEMS_DEBUG ) /** diff --git a/cpukit/score/src/smplock.c b/cpukit/score/src/smplock.c index 35b1930a1a..e426c2afbe 100644 --- a/cpukit/score/src/smplock.c +++ b/cpukit/score/src/smplock.c @@ -40,6 +40,9 @@ void _SMP_lock_Acquire( SMP_lock_Context *context ) { +#if defined(RTEMS_DEBUG) + context->lock_used_for_acquire = lock; +#endif _SMP_lock_Acquire_body( lock, context ); #if defined(RTEMS_DEBUG) lock->owner = _SMP_Get_current_processor(); @@ -52,6 +55,8 @@ void _SMP_lock_Release( ) { #if defined(RTEMS_DEBUG) + _Assert( context->lock_used_for_acquire == lock ); + context->lock_used_for_acquire = NULL; _Assert( lock->owner == _SMP_Get_current_processor() ); lock->owner = SMP_LOCK_NO_OWNER; #endif @@ -63,6 +68,9 @@ void _SMP_lock_ISR_disable_and_acquire( SMP_lock_Context *context ) { +#if defined(RTEMS_DEBUG) + context->lock_used_for_acquire = lock; +#endif _SMP_lock_ISR_disable_and_acquire_body( lock, context ); #if defined(RTEMS_DEBUG) lock->owner = _SMP_Get_current_processor(); @@ -75,10 +83,13 @@ void _SMP_lock_Release_and_ISR_enable( ) { #if defined(RTEMS_DEBUG) + _Assert( context->lock_used_for_acquire == lock ); + context->lock_used_for_acquire = NULL; _Assert( lock->owner == _SMP_Get_current_processor() ); lock->owner = SMP_LOCK_NO_OWNER; #endif - _SMP_lock_Release_and_ISR_enable_body( lock, context ); + _SMP_lock_Release_body( lock, context ); + _ISR_Enable_without_giant( context->isr_level ); } #if defined(RTEMS_DEBUG) -- cgit v1.2.3