mali_gp_job.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /*
  2. * This confidential and proprietary software may be used only as
  3. * authorised by a licensing agreement from ARM Limited
  4. * (C) COPYRIGHT 2011-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_GP_JOB_H__
  11. #define __MALI_GP_JOB_H__
  12. #include "mali_osk.h"
  13. #include "mali_osk_list.h"
  14. #include "mali_uk_types.h"
  15. #include "mali_session.h"
  16. #include "mali_timeline.h"
  17. #include "mali_scheduler_types.h"
  18. /**
  19. * The structure represents a GP job, including all sub-jobs
  20. * (This struct unfortunately needs to be public because of how the _mali_osk_list_*
  21. * mechanism works)
  22. */
  23. struct mali_gp_job {
  24. _mali_osk_list_t list; /**< Used to link jobs together in the scheduler queue */
  25. struct mali_session_data *session; /**< Session which submitted this job */
  26. _mali_uk_gp_start_job_s uargs; /**< Arguments from user space */
  27. u32 id; /**< Identifier for this job in kernel space (sequential numbering) */
  28. u32 cache_order; /**< Cache order used for L2 cache flushing (sequential numbering) */
  29. u32 heap_current_addr; /**< Holds the current HEAP address when the job has completed */
  30. u32 perf_counter_value0; /**< Value of performance counter 0 (to be returned to user space) */
  31. u32 perf_counter_value1; /**< Value of performance counter 1 (to be returned to user space) */
  32. u32 pid; /**< Process ID of submitting process */
  33. u32 tid; /**< Thread ID of submitting thread */
  34. _mali_osk_notification_t *finished_notification; /**< Notification sent back to userspace on job complete */
  35. _mali_osk_notification_t *oom_notification; /**< Notification sent back to userspace on OOM */
  36. struct mali_timeline_tracker tracker; /**< Timeline tracker for this job */
  37. struct mali_timeline_tracker *pp_tracker; /**< Pointer to Timeline tracker for PP job that depends on this job. */
  38. };
  39. struct mali_gp_job *mali_gp_job_create(struct mali_session_data *session, _mali_uk_gp_start_job_s *uargs, u32 id, struct mali_timeline_tracker *pp_tracker);
  40. void mali_gp_job_delete(struct mali_gp_job *job);
  41. u32 mali_gp_job_get_gp_counter_src0(void);
  42. void mali_gp_job_set_gp_counter_src0(u32 counter);
  43. u32 mali_gp_job_get_gp_counter_src1(void);
  44. void mali_gp_job_set_gp_counter_src1(u32 counter);
  45. MALI_STATIC_INLINE u32 mali_gp_job_get_id(struct mali_gp_job *job)
  46. {
  47. return (NULL == job) ? 0 : job->id;
  48. }
  49. MALI_STATIC_INLINE u32 mali_gp_job_get_cache_order(struct mali_gp_job *job)
  50. {
  51. return (NULL == job) ? 0 : job->cache_order;
  52. }
  53. MALI_STATIC_INLINE u32 mali_gp_job_get_user_id(struct mali_gp_job *job)
  54. {
  55. return job->uargs.user_job_ptr;
  56. }
  57. MALI_STATIC_INLINE u32 mali_gp_job_get_frame_builder_id(struct mali_gp_job *job)
  58. {
  59. return job->uargs.frame_builder_id;
  60. }
  61. MALI_STATIC_INLINE u32 mali_gp_job_get_flush_id(struct mali_gp_job *job)
  62. {
  63. return job->uargs.flush_id;
  64. }
  65. MALI_STATIC_INLINE u32 mali_gp_job_get_pid(struct mali_gp_job *job)
  66. {
  67. return job->pid;
  68. }
  69. MALI_STATIC_INLINE u32 mali_gp_job_get_tid(struct mali_gp_job *job)
  70. {
  71. return job->tid;
  72. }
  73. MALI_STATIC_INLINE u32* mali_gp_job_get_frame_registers(struct mali_gp_job *job)
  74. {
  75. return job->uargs.frame_registers;
  76. }
  77. MALI_STATIC_INLINE struct mali_session_data *mali_gp_job_get_session(struct mali_gp_job *job)
  78. {
  79. return job->session;
  80. }
  81. MALI_STATIC_INLINE mali_bool mali_gp_job_has_vs_job(struct mali_gp_job *job)
  82. {
  83. return (job->uargs.frame_registers[0] != job->uargs.frame_registers[1]) ? MALI_TRUE : MALI_FALSE;
  84. }
  85. MALI_STATIC_INLINE mali_bool mali_gp_job_has_plbu_job(struct mali_gp_job *job)
  86. {
  87. return (job->uargs.frame_registers[2] != job->uargs.frame_registers[3]) ? MALI_TRUE : MALI_FALSE;
  88. }
  89. MALI_STATIC_INLINE u32 mali_gp_job_get_current_heap_addr(struct mali_gp_job *job)
  90. {
  91. return job->heap_current_addr;
  92. }
  93. MALI_STATIC_INLINE void mali_gp_job_set_current_heap_addr(struct mali_gp_job *job, u32 heap_addr)
  94. {
  95. job->heap_current_addr = heap_addr;
  96. }
  97. MALI_STATIC_INLINE u32 mali_gp_job_get_perf_counter_flag(struct mali_gp_job *job)
  98. {
  99. return job->uargs.perf_counter_flag;
  100. }
  101. MALI_STATIC_INLINE u32 mali_gp_job_get_perf_counter_src0(struct mali_gp_job *job)
  102. {
  103. return job->uargs.perf_counter_src0;
  104. }
  105. MALI_STATIC_INLINE u32 mali_gp_job_get_perf_counter_src1(struct mali_gp_job *job)
  106. {
  107. return job->uargs.perf_counter_src1;
  108. }
  109. MALI_STATIC_INLINE u32 mali_gp_job_get_perf_counter_value0(struct mali_gp_job *job)
  110. {
  111. return job->perf_counter_value0;
  112. }
  113. MALI_STATIC_INLINE u32 mali_gp_job_get_perf_counter_value1(struct mali_gp_job *job)
  114. {
  115. return job->perf_counter_value1;
  116. }
  117. MALI_STATIC_INLINE void mali_gp_job_set_perf_counter_src0(struct mali_gp_job *job, u32 src)
  118. {
  119. job->uargs.perf_counter_src0 = src;
  120. }
  121. MALI_STATIC_INLINE void mali_gp_job_set_perf_counter_src1(struct mali_gp_job *job, u32 src)
  122. {
  123. job->uargs.perf_counter_src1 = src;
  124. }
  125. MALI_STATIC_INLINE void mali_gp_job_set_perf_counter_value0(struct mali_gp_job *job, u32 value)
  126. {
  127. job->perf_counter_value0 = value;
  128. }
  129. MALI_STATIC_INLINE void mali_gp_job_set_perf_counter_value1(struct mali_gp_job *job, u32 value)
  130. {
  131. job->perf_counter_value1 = value;
  132. }
  133. /**
  134. * Returns MALI_TRUE if first job is after the second job, ordered by job ID.
  135. *
  136. * @param first First job.
  137. * @param second Second job.
  138. * @return MALI_TRUE if first job should be ordered after the second job, MALI_FALSE if not.
  139. */
  140. MALI_STATIC_INLINE mali_bool mali_gp_job_is_after(struct mali_gp_job *first, struct mali_gp_job *second)
  141. {
  142. /* A span is used to handle job ID wrapping. */
  143. return (mali_gp_job_get_id(first) - mali_gp_job_get_id(second)) < MALI_SCHEDULER_JOB_ID_SPAN;
  144. }
  145. /**
  146. * Release reference on tracker for PP job that depends on this GP job.
  147. *
  148. * @note If GP job has a reference on tracker, this function MUST be called before the GP job is
  149. * deleted.
  150. *
  151. * @param job GP job that is done.
  152. * @param success MALI_TRUE if job completed successfully, MALI_FALSE if not.
  153. * @return A scheduling bitmask indicating whether scheduling needs to be done.
  154. */
  155. mali_scheduler_mask mali_gp_job_signal_pp_tracker(struct mali_gp_job *job, mali_bool success);
  156. #endif /* __MALI_GP_JOB_H__ */