diff --git a/mm/mm_heap/mm.h b/mm/mm_heap/mm.h index 6c06f733db246..80e225afcb17d 100644 --- a/mm/mm_heap/mm.h +++ b/mm/mm_heap/mm.h @@ -282,6 +282,8 @@ typedef CODE void (*mm_node_handler_t)(FAR struct mm_allocnode_s *node, int mm_lock(FAR struct mm_heap_s *heap); void mm_unlock(FAR struct mm_heap_s *heap); +irqstate_t mm_lock_irq(FAR struct mm_heap_s *heap); +void mm_unlock_irq(FAR struct mm_heap_s *heap, irqstate_t state); /* Functions contained in mm_shrinkchunk.c **********************************/ diff --git a/mm/mm_heap/mm_free.c b/mm/mm_heap/mm_free.c index 19a8a744a1b8c..b1482ebba5876 100644 --- a/mm/mm_heap/mm_free.c +++ b/mm/mm_heap/mm_free.c @@ -49,7 +49,7 @@ static void add_delaylist(FAR struct mm_heap_s *heap, FAR void *mem) /* Delay the deallocation until a more appropriate time. */ - flags = up_irq_save(); + flags = mm_lock_irq(heap); # ifdef CONFIG_DEBUG_ASSERTIONS FAR struct mm_freenode_s *node; @@ -65,7 +65,7 @@ static void add_delaylist(FAR struct mm_heap_s *heap, FAR void *mem) heap->mm_delaycount[this_cpu()]++; #endif - up_irq_restore(flags); + mm_unlock_irq(heap, flags); #endif } diff --git a/mm/mm_heap/mm_lock.c b/mm/mm_heap/mm_lock.c index 862a4fc68ecad..eb9d8ddb18b79 100644 --- a/mm/mm_heap/mm_lock.c +++ b/mm/mm_heap/mm_lock.c @@ -117,3 +117,31 @@ void mm_unlock(FAR struct mm_heap_s *heap) DEBUGVERIFY(nxmutex_unlock(&heap->mm_lock)); } + +/**************************************************************************** + * Name: mm_lock_irq + * + * Description: + * Locking by pausing interruption + * + ****************************************************************************/ + +irqstate_t mm_lock_irq(FAR struct mm_heap_s *heap) +{ + UNUSED(heap); + return up_irq_save(); +} + +/**************************************************************************** + * Name: mm_unlock_irq + * + * Description: + * Release the lock by resuming the interrupt + * + ****************************************************************************/ + +void mm_unlock_irq(FAR struct mm_heap_s *heap, irqstate_t state) +{ + UNUSED(heap); + up_irq_restore(state); +} diff --git a/mm/mm_heap/mm_malloc.c b/mm/mm_heap/mm_malloc.c index dc201b16f5b65..d492b8225ff24 100644 --- a/mm/mm_heap/mm_malloc.c +++ b/mm/mm_heap/mm_malloc.c @@ -65,7 +65,7 @@ static bool free_delaylist(FAR struct mm_heap_s *heap, bool force) /* Move the delay list to local */ - flags = up_irq_save(); + flags = mm_lock_irq(heap); tmp = heap->mm_delaylist[this_cpu()]; @@ -74,7 +74,7 @@ static bool free_delaylist(FAR struct mm_heap_s *heap, bool force) (!force && heap->mm_delaycount[this_cpu()] < CONFIG_MM_FREE_DELAYCOUNT_MAX)) { - up_irq_restore(flags); + mm_unlock_irq(heap, flags); return false; } @@ -83,7 +83,7 @@ static bool free_delaylist(FAR struct mm_heap_s *heap, bool force) heap->mm_delaylist[this_cpu()] = NULL; - up_irq_restore(flags); + mm_unlock_irq(heap, flags); /* Test if the delayed is empty */ diff --git a/mm/tlsf/mm_tlsf.c b/mm/tlsf/mm_tlsf.c index 2774dc8c7fd76..e60ad13a87671 100644 --- a/mm/tlsf/mm_tlsf.c +++ b/mm/tlsf/mm_tlsf.c @@ -301,7 +301,7 @@ static void add_delaylist(FAR struct mm_heap_s *heap, FAR void *mem) /* Delay the deallocation until a more appropriate time. */ - flags = up_irq_save(); + flags = mm_lock_irq(heap); tmp->flink = heap->mm_delaylist[this_cpu()]; heap->mm_delaylist[this_cpu()] = tmp; @@ -310,7 +310,7 @@ static void add_delaylist(FAR struct mm_heap_s *heap, FAR void *mem) heap->mm_delaycount[this_cpu()]++; #endif - up_irq_restore(flags); + mm_unlock_irq(heap, flags); #endif } @@ -327,7 +327,7 @@ static bool free_delaylist(FAR struct mm_heap_s *heap, bool force) /* Move the delay list to local */ - flags = up_irq_save(); + flags = mm_unlock_irq(heap); tmp = heap->mm_delaylist[this_cpu()]; @@ -336,7 +336,7 @@ static bool free_delaylist(FAR struct mm_heap_s *heap, bool force) (!force && heap->mm_delaycount[this_cpu()] < CONFIG_MM_FREE_DELAYCOUNT_MAX)) { - up_irq_restore(flags); + mm_unlock_irq(heap, flags); return false; } @@ -345,7 +345,7 @@ static bool free_delaylist(FAR struct mm_heap_s *heap, bool force) heap->mm_delaylist[this_cpu()] = NULL; - up_irq_restore(flags); + mm_unlock_irq(heap, flags); /* Test if the delayed is empty */