2 * Copyright (C) 2013, 2015 ARM Limited. All rights reserved.
4 * This program is free software and is provided to you under the terms of the GNU General Public License version 2
5 * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
7 * A copy of the licence is included with the program, and can also be obtained from Free Software
8 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
11 #ifndef __MALI_SPINLOCK_REENTRANT_H__
12 #define __MALI_SPINLOCK_REENTRANT_H__
15 #include "mali_kernel_common.h"
20 struct mali_spinlock_reentrant {
21 _mali_osk_spinlock_irq_t *lock;
27 * Create a new reentrant spinlock.
29 * @param lock_order Lock order.
30 * @return New reentrant spinlock.
32 struct mali_spinlock_reentrant *mali_spinlock_reentrant_init(_mali_osk_lock_order_t lock_order);
35 * Terminate reentrant spinlock and free any associated resources.
37 * @param spinlock Reentrant spinlock to terminate.
39 void mali_spinlock_reentrant_term(struct mali_spinlock_reentrant *spinlock);
42 * Wait for reentrant spinlock to be signaled.
44 * @param spinlock Reentrant spinlock.
45 * @param tid Thread ID.
47 void mali_spinlock_reentrant_wait(struct mali_spinlock_reentrant *spinlock, u32 tid);
50 * Signal reentrant spinlock.
52 * @param spinlock Reentrant spinlock.
53 * @param tid Thread ID.
55 void mali_spinlock_reentrant_signal(struct mali_spinlock_reentrant *spinlock, u32 tid);
58 * Check if thread is holding reentrant spinlock.
60 * @param spinlock Reentrant spinlock.
61 * @param tid Thread ID.
62 * @return MALI_TRUE if thread is holding spinlock, MALI_FALSE if not.
64 MALI_STATIC_INLINE mali_bool mali_spinlock_reentrant_is_held(struct mali_spinlock_reentrant *spinlock, u32 tid)
66 MALI_DEBUG_ASSERT_POINTER(spinlock->lock);
67 return (tid == spinlock->owner && 0 < spinlock->counter);
70 #endif /* __MALI_SPINLOCK_REENTRANT_H__ */