2 * Copyright (C) 2011-2012 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 #include "mali_pp_job.h"
13 #include "mali_osk_list.h"
14 #include "mali_kernel_common.h"
15 #include "mali_uk_types.h"
17 static u32 pp_counter_src0 = MALI_HW_CORE_NO_COUNTER; /**< Performance counter 0, MALI_HW_CORE_NO_COUNTER for disabled */
18 static u32 pp_counter_src1 = MALI_HW_CORE_NO_COUNTER; /**< Performance counter 1, MALI_HW_CORE_NO_COUNTER for disabled */
20 struct mali_pp_job *mali_pp_job_create(struct mali_session_data *session, _mali_uk_pp_start_job_s *uargs, u32 id)
22 struct mali_pp_job *job;
23 u32 perf_counter_flag;
25 job = _mali_osk_malloc(sizeof(struct mali_pp_job));
30 if (0 != _mali_osk_copy_from_user(&job->uargs, uargs, sizeof(_mali_uk_pp_start_job_s)))
36 if (job->uargs.num_cores > _MALI_PP_MAX_SUB_JOBS)
38 MALI_PRINT_ERROR(("Mali PP job: Too many sub jobs specified in job object\n"));
43 if (!mali_pp_job_use_no_notification(job))
45 job->finished_notification = _mali_osk_notification_create(_MALI_NOTIFICATION_PP_FINISHED, sizeof(_mali_uk_pp_job_finished_s));
46 if (NULL == job->finished_notification)
54 job->finished_notification = NULL;
57 perf_counter_flag = mali_pp_job_get_perf_counter_flag(job);
59 /* case when no counters came from user space
60 * so pass the debugfs / DS-5 provided global ones to the job object */
61 if (!((perf_counter_flag & _MALI_PERFORMANCE_COUNTER_FLAG_SRC0_ENABLE) ||
62 (perf_counter_flag & _MALI_PERFORMANCE_COUNTER_FLAG_SRC1_ENABLE)))
64 mali_pp_job_set_perf_counter_src0(job, mali_pp_job_get_pp_counter_src0());
65 mali_pp_job_set_perf_counter_src1(job, mali_pp_job_get_pp_counter_src1());
68 _mali_osk_list_init(&job->list);
69 job->session = session;
70 _mali_osk_list_init(&job->session_list);
73 for (i = 0; i < job->uargs.num_cores; i++)
75 job->perf_counter_value0[i] = 0;
76 job->perf_counter_value1[i] = 0;
78 job->sub_jobs_num = job->uargs.num_cores ? job->uargs.num_cores : 1;
79 job->sub_jobs_started = 0;
80 job->sub_jobs_completed = 0;
81 job->sub_job_errors = 0;
82 job->pid = _mali_osk_get_pid();
83 job->tid = _mali_osk_get_tid();
84 #if defined(CONFIG_SYNC)
86 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)
87 job->sync_point = NULL;
88 job->pre_fence = NULL;
89 job->sync_work = NULL;
99 void mali_pp_job_delete(struct mali_pp_job *job)
103 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)
104 if (NULL != job->pre_fence) sync_fence_put(job->pre_fence);
105 if (NULL != job->sync_point) sync_fence_put(job->sync_point->fence);
108 if (NULL != job->finished_notification)
110 _mali_osk_notification_delete(job->finished_notification);
115 u32 mali_pp_job_get_pp_counter_src0(void)
117 return pp_counter_src0;
120 mali_bool mali_pp_job_set_pp_counter_src0(u32 counter)
122 pp_counter_src0 = counter;
127 u32 mali_pp_job_get_pp_counter_src1(void)
129 return pp_counter_src1;
132 mali_bool mali_pp_job_set_pp_counter_src1(u32 counter)
134 pp_counter_src1 = counter;