mali_gp_job.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. #include "mali_gp_job.h"
  11. #include "mali_osk.h"
  12. #include "mali_osk_list.h"
  13. #include "mali_uk_types.h"
  14. static u32 gp_counter_src0 = MALI_HW_CORE_NO_COUNTER; /**< Performance counter 0, MALI_HW_CORE_NO_COUNTER for disabled */
  15. static u32 gp_counter_src1 = MALI_HW_CORE_NO_COUNTER; /**< Performance counter 1, MALI_HW_CORE_NO_COUNTER for disabled */
  16. 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)
  17. {
  18. struct mali_gp_job *job;
  19. u32 perf_counter_flag;
  20. job = _mali_osk_malloc(sizeof(struct mali_gp_job));
  21. if (NULL != job) {
  22. job->finished_notification = _mali_osk_notification_create(_MALI_NOTIFICATION_GP_FINISHED, sizeof(_mali_uk_gp_job_finished_s));
  23. if (NULL == job->finished_notification) {
  24. _mali_osk_free(job);
  25. return NULL;
  26. }
  27. job->oom_notification = _mali_osk_notification_create(_MALI_NOTIFICATION_GP_STALLED, sizeof(_mali_uk_gp_job_suspended_s));
  28. if (NULL == job->oom_notification) {
  29. _mali_osk_notification_delete(job->finished_notification);
  30. _mali_osk_free(job);
  31. return NULL;
  32. }
  33. if (0 != _mali_osk_copy_from_user(&job->uargs, uargs, sizeof(_mali_uk_gp_start_job_s))) {
  34. _mali_osk_notification_delete(job->finished_notification);
  35. _mali_osk_notification_delete(job->oom_notification);
  36. _mali_osk_free(job);
  37. return NULL;
  38. }
  39. perf_counter_flag = mali_gp_job_get_perf_counter_flag(job);
  40. /* case when no counters came from user space
  41. * so pass the debugfs / DS-5 provided global ones to the job object */
  42. if (!((perf_counter_flag & _MALI_PERFORMANCE_COUNTER_FLAG_SRC0_ENABLE) ||
  43. (perf_counter_flag & _MALI_PERFORMANCE_COUNTER_FLAG_SRC1_ENABLE))) {
  44. mali_gp_job_set_perf_counter_src0(job, mali_gp_job_get_gp_counter_src0());
  45. mali_gp_job_set_perf_counter_src1(job, mali_gp_job_get_gp_counter_src1());
  46. }
  47. _mali_osk_list_init(&job->list);
  48. job->session = session;
  49. job->id = id;
  50. job->heap_current_addr = job->uargs.frame_registers[4];
  51. job->perf_counter_value0 = 0;
  52. job->perf_counter_value1 = 0;
  53. job->pid = _mali_osk_get_pid();
  54. job->tid = _mali_osk_get_tid();
  55. job->pp_tracker = pp_tracker;
  56. if (NULL != job->pp_tracker) {
  57. /* Take a reference on PP job's tracker that will be released when the GP
  58. job is done. */
  59. mali_timeline_system_tracker_get(session->timeline_system, pp_tracker);
  60. }
  61. mali_timeline_tracker_init(&job->tracker, MALI_TIMELINE_TRACKER_GP, NULL, job);
  62. mali_timeline_fence_copy_uk_fence(&(job->tracker.fence), &(job->uargs.fence));
  63. return job;
  64. }
  65. return NULL;
  66. }
  67. void mali_gp_job_delete(struct mali_gp_job *job)
  68. {
  69. MALI_DEBUG_ASSERT_POINTER(job);
  70. MALI_DEBUG_ASSERT(NULL == job->pp_tracker);
  71. /* de-allocate the pre-allocated oom notifications */
  72. if (NULL != job->oom_notification) {
  73. _mali_osk_notification_delete(job->oom_notification);
  74. job->oom_notification = NULL;
  75. }
  76. if (NULL != job->finished_notification) {
  77. _mali_osk_notification_delete(job->finished_notification);
  78. job->finished_notification = NULL;
  79. }
  80. _mali_osk_free(job);
  81. }
  82. u32 mali_gp_job_get_gp_counter_src0(void)
  83. {
  84. return gp_counter_src0;
  85. }
  86. void mali_gp_job_set_gp_counter_src0(u32 counter)
  87. {
  88. gp_counter_src0 = counter;
  89. }
  90. u32 mali_gp_job_get_gp_counter_src1(void)
  91. {
  92. return gp_counter_src1;
  93. }
  94. void mali_gp_job_set_gp_counter_src1(u32 counter)
  95. {
  96. gp_counter_src1 = counter;
  97. }
  98. mali_scheduler_mask mali_gp_job_signal_pp_tracker(struct mali_gp_job *job, mali_bool success)
  99. {
  100. mali_scheduler_mask schedule_mask = MALI_SCHEDULER_MASK_EMPTY;
  101. MALI_DEBUG_ASSERT_POINTER(job);
  102. if (NULL != job->pp_tracker) {
  103. schedule_mask |= mali_timeline_system_tracker_put(job->session->timeline_system, job->pp_tracker, MALI_FALSE == success);
  104. job->pp_tracker = NULL;
  105. }
  106. return schedule_mask;
  107. }