mali_kbase_js_ctx_attr.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /*
  2. *
  3. * (C) COPYRIGHT 2012-2015 ARM Limited. All rights reserved.
  4. *
  5. * This program is free software and is provided to you under the terms of the
  6. * GNU General Public License version 2 as published by the Free Software
  7. * Foundation, and any use by you of this program is subject to the terms
  8. * of such GNU licence.
  9. *
  10. * A copy of the licence is included with the program, and can also be obtained
  11. * from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  12. * Boston, MA 02110-1301, USA.
  13. *
  14. */
  15. /**
  16. * @file mali_kbase_js_ctx_attr.h
  17. * Job Scheduler Context Attribute APIs
  18. */
  19. #ifndef _KBASE_JS_CTX_ATTR_H_
  20. #define _KBASE_JS_CTX_ATTR_H_
  21. /**
  22. * @addtogroup base_api
  23. * @{
  24. */
  25. /**
  26. * @addtogroup base_kbase_api
  27. * @{
  28. */
  29. /**
  30. * @addtogroup kbase_js
  31. * @{
  32. */
  33. /**
  34. * Set the initial attributes of a context (when context create flags are set)
  35. *
  36. * Requires:
  37. * - Hold the jsctx_mutex
  38. */
  39. void kbasep_js_ctx_attr_set_initial_attrs(struct kbase_device *kbdev, struct kbase_context *kctx);
  40. /**
  41. * Retain all attributes of a context
  42. *
  43. * This occurs on scheduling in the context on the runpool (but after
  44. * is_scheduled is set)
  45. *
  46. * Requires:
  47. * - jsctx mutex
  48. * - runpool_irq spinlock
  49. * - ctx->is_scheduled is true
  50. */
  51. void kbasep_js_ctx_attr_runpool_retain_ctx(struct kbase_device *kbdev, struct kbase_context *kctx);
  52. /**
  53. * Release all attributes of a context
  54. *
  55. * This occurs on scheduling out the context from the runpool (but before
  56. * is_scheduled is cleared)
  57. *
  58. * Requires:
  59. * - jsctx mutex
  60. * - runpool_irq spinlock
  61. * - ctx->is_scheduled is true
  62. *
  63. * @return true indicates a change in ctx attributes state of the runpool.
  64. * In this state, the scheduler might be able to submit more jobs than
  65. * previously, and so the caller should ensure kbasep_js_try_run_next_job_nolock()
  66. * or similar is called sometime later.
  67. * @return false indicates no change in ctx attributes state of the runpool.
  68. */
  69. bool kbasep_js_ctx_attr_runpool_release_ctx(struct kbase_device *kbdev, struct kbase_context *kctx);
  70. /**
  71. * Retain all attributes of an atom
  72. *
  73. * This occurs on adding an atom to a context
  74. *
  75. * Requires:
  76. * - jsctx mutex
  77. * - If the context is scheduled, then runpool_irq spinlock must also be held
  78. */
  79. void kbasep_js_ctx_attr_ctx_retain_atom(struct kbase_device *kbdev, struct kbase_context *kctx, struct kbase_jd_atom *katom);
  80. /**
  81. * Release all attributes of an atom, given its retained state.
  82. *
  83. * This occurs after (permanently) removing an atom from a context
  84. *
  85. * Requires:
  86. * - jsctx mutex
  87. * - If the context is scheduled, then runpool_irq spinlock must also be held
  88. *
  89. * This is a no-op when \a katom_retained_state is invalid.
  90. *
  91. * @return true indicates a change in ctx attributes state of the runpool.
  92. * In this state, the scheduler might be able to submit more jobs than
  93. * previously, and so the caller should ensure kbasep_js_try_run_next_job_nolock()
  94. * or similar is called sometime later.
  95. * @return false indicates no change in ctx attributes state of the runpool.
  96. */
  97. bool kbasep_js_ctx_attr_ctx_release_atom(struct kbase_device *kbdev, struct kbase_context *kctx, struct kbasep_js_atom_retained_state *katom_retained_state);
  98. /**
  99. * Requires:
  100. * - runpool_irq spinlock
  101. */
  102. static inline s8 kbasep_js_ctx_attr_count_on_runpool(struct kbase_device *kbdev, enum kbasep_js_ctx_attr attribute)
  103. {
  104. struct kbasep_js_device_data *js_devdata;
  105. KBASE_DEBUG_ASSERT(kbdev != NULL);
  106. KBASE_DEBUG_ASSERT(attribute < KBASEP_JS_CTX_ATTR_COUNT);
  107. js_devdata = &kbdev->js_data;
  108. return js_devdata->runpool_irq.ctx_attr_ref_count[attribute];
  109. }
  110. /**
  111. * Requires:
  112. * - runpool_irq spinlock
  113. */
  114. static inline bool kbasep_js_ctx_attr_is_attr_on_runpool(struct kbase_device *kbdev, enum kbasep_js_ctx_attr attribute)
  115. {
  116. /* In general, attributes are 'on' when they have a non-zero refcount (note: the refcount will never be < 0) */
  117. return (bool) kbasep_js_ctx_attr_count_on_runpool(kbdev, attribute);
  118. }
  119. /**
  120. * Requires:
  121. * - jsctx mutex
  122. */
  123. static inline bool kbasep_js_ctx_attr_is_attr_on_ctx(struct kbase_context *kctx, enum kbasep_js_ctx_attr attribute)
  124. {
  125. struct kbasep_js_kctx_info *js_kctx_info;
  126. KBASE_DEBUG_ASSERT(kctx != NULL);
  127. KBASE_DEBUG_ASSERT(attribute < KBASEP_JS_CTX_ATTR_COUNT);
  128. js_kctx_info = &kctx->jctx.sched_info;
  129. /* In general, attributes are 'on' when they have a refcount (which should never be < 0) */
  130. return (bool) (js_kctx_info->ctx.ctx_attr_ref_count[attribute]);
  131. }
  132. /** @} *//* end group kbase_js */
  133. /** @} *//* end group base_kbase_api */
  134. /** @} *//* end group base_api */
  135. #endif // ifndef _KBASE_JS_CTX_ATTR_H_