2 * This confidential and proprietary software may be used only as
3 * authorised by a licensing agreement from ARM Limited
4 * (C) COPYRIGHT 2013 ARM Limited
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.
10 #include <linux/fs.h> /* file system operations */
11 #include <asm/uaccess.h> /* user space access */
15 #include "mali_kernel_common.h"
16 #include "mali_session.h"
17 #include "mali_ukk_wrappers.h"
19 #include "mali_soft_job.h"
20 #include "mali_timeline.h"
22 int soft_job_start_wrapper(struct mali_session_data *session, _mali_uk_soft_job_start_s __user *uargs)
24 u32 type, user_job, point;
25 _mali_uk_fence_t uk_fence;
26 struct mali_timeline_fence fence;
27 struct mali_soft_job *job = NULL;
28 u32 __user *job_id_ptr = NULL;
30 /* If the job was started successfully, 0 is returned. If there was an error, but the job
31 * was started, we return -ENOENT. For anything else returned, the job was not started. */
33 MALI_CHECK_NON_NULL(uargs, -EINVAL);
34 MALI_CHECK_NON_NULL(session, -EINVAL);
36 MALI_DEBUG_ASSERT_POINTER(session->soft_job_system);
38 if (0 != get_user(type, &uargs->type)) return -EFAULT;
39 if (0 != get_user(user_job, &uargs->user_job)) return -EFAULT;
40 if (0 != get_user(job_id_ptr, &uargs->job_id_ptr)) return -EFAULT;
42 if (0 != copy_from_user(&uk_fence, &uargs->fence, sizeof(_mali_uk_fence_t))) return -EFAULT;
43 mali_timeline_fence_copy_uk_fence(&fence, &uk_fence);
45 if (MALI_SOFT_JOB_TYPE_USER_SIGNALED < type) {
46 MALI_DEBUG_PRINT_ERROR(("Invalid soft job type specified\n"));
50 /* Create soft job. */
51 job = mali_soft_job_create(session->soft_job_system, (enum mali_soft_job_type)type, user_job);
52 if (unlikely(NULL == job)) {
53 return map_errcode(_MALI_OSK_ERR_NOMEM);
56 /* Write job id back to user space. */
57 if (0 != put_user(job->id, job_id_ptr)) {
58 MALI_PRINT_ERROR(("Mali Soft Job: failed to put job id"));
59 mali_soft_job_destroy(job);
60 return map_errcode(_MALI_OSK_ERR_NOMEM);
64 point = mali_soft_job_start(job, &fence);
66 if (0 != put_user(point, &uargs->point)) {
67 /* Let user space know that something failed after the job was started. */
74 int soft_job_signal_wrapper(struct mali_session_data *session, _mali_uk_soft_job_signal_s __user *uargs)
77 _mali_osk_errcode_t err;
79 MALI_DEBUG_ASSERT_POINTER(session);
81 if (0 != get_user(job_id, &uargs->job_id)) return -EFAULT;
83 err = mali_soft_job_system_signal_job(session->soft_job_system, job_id);
85 return map_errcode(err);