mali mess
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / misc / mediatek / gpu / mt8127 / mali / mali / linux / mali_ukk_gp.c
CommitLineData
6fa3eb70
S
1/*
2 * This confidential and proprietary software may be used only as
3 * authorised by a licensing agreement from ARM Limited
02af6beb 4 * (C) COPYRIGHT 2008-2010, 2012-2015 ARM Limited
6fa3eb70
S
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 <linux/fs.h> /* file system operations */
11#include <asm/uaccess.h> /* user space access */
12
13#include "mali_ukk.h"
14#include "mali_osk.h"
15#include "mali_kernel_common.h"
16#include "mali_session.h"
17#include "mali_ukk_wrappers.h"
18
19int gp_start_job_wrapper(struct mali_session_data *session_data, _mali_uk_gp_start_job_s __user *uargs)
20{
21 _mali_osk_errcode_t err;
22
23 /* If the job was started successfully, 0 is returned. If there was an error, but the job
24 * was started, we return -ENOENT. For anything else returned, the job was not started. */
25
26 MALI_CHECK_NON_NULL(uargs, -EINVAL);
27 MALI_CHECK_NON_NULL(session_data, -EINVAL);
28
29 err = _mali_ukk_gp_start_job(session_data, uargs);
30 if (_MALI_OSK_ERR_OK != err) return map_errcode(err);
31
32 return 0;
33}
34
35int gp_get_core_version_wrapper(struct mali_session_data *session_data, _mali_uk_get_gp_core_version_s __user *uargs)
36{
37 _mali_uk_get_gp_core_version_s kargs;
38 _mali_osk_errcode_t err;
39
40 MALI_CHECK_NON_NULL(uargs, -EINVAL);
41 MALI_CHECK_NON_NULL(session_data, -EINVAL);
42
02af6beb 43 kargs.ctx = (uintptr_t)session_data;
6fa3eb70
S
44 err = _mali_ukk_get_gp_core_version(&kargs);
45 if (_MALI_OSK_ERR_OK != err) return map_errcode(err);
46
47 /* no known transactions to roll-back */
48
49 if (0 != put_user(kargs.version, &uargs->version)) return -EFAULT;
50
51 return 0;
52}
53
54int gp_suspend_response_wrapper(struct mali_session_data *session_data, _mali_uk_gp_suspend_response_s __user *uargs)
55{
56 _mali_uk_gp_suspend_response_s kargs;
57 _mali_osk_errcode_t err;
58
59 MALI_CHECK_NON_NULL(uargs, -EINVAL);
60 MALI_CHECK_NON_NULL(session_data, -EINVAL);
61
62 if (0 != copy_from_user(&kargs, uargs, sizeof(_mali_uk_gp_suspend_response_s))) return -EFAULT;
63
02af6beb 64 kargs.ctx = (uintptr_t)session_data;
6fa3eb70
S
65 err = _mali_ukk_gp_suspend_response(&kargs);
66 if (_MALI_OSK_ERR_OK != err) return map_errcode(err);
67
68 if (0 != put_user(kargs.cookie, &uargs->cookie)) return -EFAULT;
69
70 /* no known transactions to roll-back */
71 return 0;
72}
73
74int gp_get_number_of_cores_wrapper(struct mali_session_data *session_data, _mali_uk_get_gp_number_of_cores_s __user *uargs)
75{
76 _mali_uk_get_gp_number_of_cores_s kargs;
77 _mali_osk_errcode_t err;
78
79 MALI_CHECK_NON_NULL(uargs, -EINVAL);
80 MALI_CHECK_NON_NULL(session_data, -EINVAL);
81
02af6beb 82 kargs.ctx = (uintptr_t)session_data;
6fa3eb70
S
83 err = _mali_ukk_get_gp_number_of_cores(&kargs);
84 if (_MALI_OSK_ERR_OK != err) return map_errcode(err);
85
86 /* no known transactions to roll-back */
87
88 if (0 != put_user(kargs.number_of_cores, &uargs->number_of_cores)) return -EFAULT;
89
90 return 0;
91}