xref: /OK3568_Linux_fs/kernel/drivers/gpu/arm/mali400/mali/linux/mali_ukk_gp.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Copyright (C) 2010, 2012-2014, 2016-2017 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 <linux/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 
gp_start_job_wrapper(struct mali_session_data * session_data,_mali_uk_gp_start_job_s __user * uargs)19 int 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 
gp_get_core_version_wrapper(struct mali_session_data * session_data,_mali_uk_get_gp_core_version_s __user * uargs)35 int 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 
43 	kargs.ctx = (uintptr_t)session_data;
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 
gp_suspend_response_wrapper(struct mali_session_data * session_data,_mali_uk_gp_suspend_response_s __user * uargs)54 int 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 
64 	kargs.ctx = (uintptr_t)session_data;
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 
gp_get_number_of_cores_wrapper(struct mali_session_data * session_data,_mali_uk_get_gp_number_of_cores_s __user * uargs)74 int 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 
82 	kargs.ctx = (uintptr_t)session_data;
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 }
92