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_gp_job.h"
13 #include "mali_osk_list.h"
14 #include "mali_uk_types.h"
16 static u32 gp_counter_src0 = MALI_HW_CORE_NO_COUNTER; /**< Performance counter 0, MALI_HW_CORE_NO_COUNTER for disabled */
17 static u32 gp_counter_src1 = MALI_HW_CORE_NO_COUNTER; /**< Performance counter 1, MALI_HW_CORE_NO_COUNTER for disabled */
19 struct mali_gp_job *mali_gp_job_create(struct mali_session_data *session, _mali_uk_gp_start_job_s *uargs, u32 id)
21 struct mali_gp_job *job;
22 u32 perf_counter_flag;
24 job = _mali_osk_malloc(sizeof(struct mali_gp_job));
27 job->finished_notification = _mali_osk_notification_create(_MALI_NOTIFICATION_GP_FINISHED, sizeof(_mali_uk_gp_job_finished_s));
28 if (NULL == job->finished_notification)
34 job->oom_notification = _mali_osk_notification_create(_MALI_NOTIFICATION_GP_STALLED, sizeof(_mali_uk_gp_job_suspended_s));
35 if (NULL == job->oom_notification)
37 _mali_osk_notification_delete(job->finished_notification);
42 if (0 != copy_from_user(&job->uargs, uargs, sizeof(_mali_uk_gp_start_job_s)))
44 _mali_osk_notification_delete(job->finished_notification);
45 _mali_osk_notification_delete(job->oom_notification);
50 perf_counter_flag = mali_gp_job_get_perf_counter_flag(job);
52 /* case when no counters came from user space
53 * so pass the debugfs / DS-5 provided global ones to the job object */
54 if (!((perf_counter_flag & _MALI_PERFORMANCE_COUNTER_FLAG_SRC0_ENABLE) ||
55 (perf_counter_flag & _MALI_PERFORMANCE_COUNTER_FLAG_SRC1_ENABLE)))
57 mali_gp_job_set_perf_counter_src0(job, mali_gp_job_get_gp_counter_src0());
58 mali_gp_job_set_perf_counter_src1(job, mali_gp_job_get_gp_counter_src1());
61 _mali_osk_list_init(&job->list);
62 job->session = session;
64 job->heap_current_addr = job->uargs.frame_registers[4];
65 job->perf_counter_value0 = 0;
66 job->perf_counter_value1 = 0;
67 job->pid = _mali_osk_get_pid();
68 job->tid = _mali_osk_get_tid();
76 void mali_gp_job_delete(struct mali_gp_job *job)
79 /* de-allocate the pre-allocated oom notifications */
80 if (NULL != job->oom_notification)
82 _mali_osk_notification_delete(job->oom_notification);
83 job->oom_notification = NULL;
85 if (NULL != job->finished_notification)
87 _mali_osk_notification_delete(job->finished_notification);
88 job->finished_notification = NULL;
94 u32 mali_gp_job_get_gp_counter_src0(void)
96 return gp_counter_src0;
99 mali_bool mali_gp_job_set_gp_counter_src0(u32 counter)
101 gp_counter_src0 = counter;
106 u32 mali_gp_job_get_gp_counter_src1(void)
108 return gp_counter_src1;
111 mali_bool mali_gp_job_set_gp_counter_src1(u32 counter)
113 gp_counter_src1 = counter;