ARM64: DTS: Add rk3399-firefly uart4 device, node as /dev/ttyS1
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / arm / mali400 / mali / linux / mali_ukk_pp.c
1 /*
2  * Copyright (C) 2010, 2012-2014, 2016 ARM Limited. All rights reserved.
3  * 
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.
6  * 
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.
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
19 int pp_start_job_wrapper(struct mali_session_data *session_data, _mali_uk_pp_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_pp_start_job(session_data, uargs);
30         if (_MALI_OSK_ERR_OK != err) return map_errcode(err);
31
32         return 0;
33 }
34
35 int pp_and_gp_start_job_wrapper(struct mali_session_data *session_data, _mali_uk_pp_and_gp_start_job_s __user *uargs)
36 {
37         _mali_osk_errcode_t err;
38
39         /* If the jobs were started successfully, 0 is returned.  If there was an error, but the
40          * jobs were started, we return -ENOENT.  For anything else returned, the jobs were not
41          * started. */
42
43         MALI_CHECK_NON_NULL(uargs, -EINVAL);
44         MALI_CHECK_NON_NULL(session_data, -EINVAL);
45
46         err = _mali_ukk_pp_and_gp_start_job(session_data, uargs);
47         if (_MALI_OSK_ERR_OK != err) return map_errcode(err);
48
49         return 0;
50 }
51
52 int pp_get_number_of_cores_wrapper(struct mali_session_data *session_data, _mali_uk_get_pp_number_of_cores_s __user *uargs)
53 {
54         _mali_uk_get_pp_number_of_cores_s kargs;
55         _mali_osk_errcode_t err;
56
57         MALI_CHECK_NON_NULL(uargs, -EINVAL);
58         MALI_CHECK_NON_NULL(session_data, -EINVAL);
59
60         kargs.ctx = (uintptr_t)session_data;
61
62         err = _mali_ukk_get_pp_number_of_cores(&kargs);
63         if (_MALI_OSK_ERR_OK != err) {
64                 return map_errcode(err);
65         }
66
67         kargs.ctx = (uintptr_t)NULL; /* prevent kernel address to be returned to user space */
68         if (0 != copy_to_user(uargs, &kargs, sizeof(_mali_uk_get_pp_number_of_cores_s))) {
69                 return -EFAULT;
70         }
71
72         return 0;
73 }
74
75 int pp_get_core_version_wrapper(struct mali_session_data *session_data, _mali_uk_get_pp_core_version_s __user *uargs)
76 {
77         _mali_uk_get_pp_core_version_s kargs;
78         _mali_osk_errcode_t err;
79
80         MALI_CHECK_NON_NULL(uargs, -EINVAL);
81         MALI_CHECK_NON_NULL(session_data, -EINVAL);
82
83         kargs.ctx = (uintptr_t)session_data;
84         err = _mali_ukk_get_pp_core_version(&kargs);
85         if (_MALI_OSK_ERR_OK != err) return map_errcode(err);
86
87         if (0 != put_user(kargs.version, &uargs->version)) return -EFAULT;
88
89         return 0;
90 }
91
92 int pp_disable_wb_wrapper(struct mali_session_data *session_data, _mali_uk_pp_disable_wb_s __user *uargs)
93 {
94         _mali_uk_pp_disable_wb_s kargs;
95
96         MALI_CHECK_NON_NULL(uargs, -EINVAL);
97         MALI_CHECK_NON_NULL(session_data, -EINVAL);
98
99         if (0 != copy_from_user(&kargs, uargs, sizeof(_mali_uk_pp_disable_wb_s))) return -EFAULT;
100
101         kargs.ctx = (uintptr_t)session_data;
102         _mali_ukk_pp_job_disable_wb(&kargs);
103
104         return 0;
105 }