mali_spinlock_reentrant.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * This confidential and proprietary software may be used only as
  3. * authorised by a licensing agreement from ARM Limited
  4. * (C) COPYRIGHT 2013 ARM Limited
  5. * ALL RIGHTS RESERVED
  6. * The entire notice above must be reproduced on all authorised
  7. * copies and copies may only be made to the extent permitted
  8. * by a licensing agreement from ARM Limited.
  9. */
  10. #ifndef __MALI_SPINLOCK_REENTRANT_H__
  11. #define __MALI_SPINLOCK_REENTRANT_H__
  12. #include "mali_osk.h"
  13. #include "mali_kernel_common.h"
  14. /**
  15. * Reentrant spinlock.
  16. */
  17. struct mali_spinlock_reentrant {
  18. _mali_osk_spinlock_irq_t *lock;
  19. u32 owner;
  20. u32 counter;
  21. };
  22. /**
  23. * Create a new reentrant spinlock.
  24. *
  25. * @param lock_order Lock order.
  26. * @return New reentrant spinlock.
  27. */
  28. struct mali_spinlock_reentrant *mali_spinlock_reentrant_init(_mali_osk_lock_order_t lock_order);
  29. /**
  30. * Terminate reentrant spinlock and free any associated resources.
  31. *
  32. * @param spinlock Reentrant spinlock to terminate.
  33. */
  34. void mali_spinlock_reentrant_term(struct mali_spinlock_reentrant *spinlock);
  35. /**
  36. * Wait for reentrant spinlock to be signaled.
  37. *
  38. * @param spinlock Reentrant spinlock.
  39. * @param tid Thread ID.
  40. */
  41. void mali_spinlock_reentrant_wait(struct mali_spinlock_reentrant *spinlock, u32 tid);
  42. /**
  43. * Signal reentrant spinlock.
  44. *
  45. * @param spinlock Reentrant spinlock.
  46. * @param tid Thread ID.
  47. */
  48. void mali_spinlock_reentrant_signal(struct mali_spinlock_reentrant *spinlock, u32 tid);
  49. /**
  50. * Check if thread is holding reentrant spinlock.
  51. *
  52. * @param spinlock Reentrant spinlock.
  53. * @param tid Thread ID.
  54. * @return MALI_TRUE if thread is holding spinlock, MALI_FALSE if not.
  55. */
  56. MALI_STATIC_INLINE mali_bool mali_spinlock_reentrant_is_held(struct mali_spinlock_reentrant *spinlock, u32 tid)
  57. {
  58. MALI_DEBUG_ASSERT_POINTER(spinlock->lock);
  59. return (tid == spinlock->owner && 0 < spinlock->counter);
  60. }
  61. #endif /* __MALI_SPINLOCK_REENTRANT_H__ */