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_timeline.c
1 /*
2  * Copyright (C) 2013, 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 #include "mali_timeline.h"
20 #include "mali_timeline_fence_wait.h"
21 #include "mali_timeline_sync_fence.h"
22
23 int timeline_get_latest_point_wrapper(struct mali_session_data *session, _mali_uk_timeline_get_latest_point_s __user *uargs)
24 {
25         u32 val;
26         mali_timeline_id timeline;
27         mali_timeline_point point;
28
29         MALI_DEBUG_ASSERT_POINTER(session);
30
31         if (0 != get_user(val, &uargs->timeline)) return -EFAULT;
32
33         if (MALI_UK_TIMELINE_MAX <= val) {
34                 return -EINVAL;
35         }
36
37         timeline = (mali_timeline_id)val;
38
39         point = mali_timeline_system_get_latest_point(session->timeline_system, timeline);
40
41         if (0 != put_user(point, &uargs->point)) return -EFAULT;
42
43         return 0;
44 }
45
46 int timeline_wait_wrapper(struct mali_session_data *session, _mali_uk_timeline_wait_s __user *uargs)
47 {
48         u32 timeout, status;
49         mali_bool ret;
50         _mali_uk_fence_t uk_fence;
51         struct mali_timeline_fence fence;
52
53         MALI_DEBUG_ASSERT_POINTER(session);
54
55         if (0 != copy_from_user(&uk_fence, &uargs->fence, sizeof(_mali_uk_fence_t))) return -EFAULT;
56         if (0 != get_user(timeout, &uargs->timeout)) return -EFAULT;
57
58         mali_timeline_fence_copy_uk_fence(&fence, &uk_fence);
59
60         ret = mali_timeline_fence_wait(session->timeline_system, &fence, timeout);
61         status = (MALI_TRUE == ret ? 1 : 0);
62
63         if (0 != put_user(status, &uargs->status)) return -EFAULT;
64
65         return 0;
66 }
67
68 int timeline_create_sync_fence_wrapper(struct mali_session_data *session, _mali_uk_timeline_create_sync_fence_s __user *uargs)
69 {
70         s32 sync_fd = -1;
71         _mali_uk_fence_t uk_fence;
72         struct mali_timeline_fence fence;
73
74         MALI_DEBUG_ASSERT_POINTER(session);
75
76         if (0 != copy_from_user(&uk_fence, &uargs->fence, sizeof(_mali_uk_fence_t))) return -EFAULT;
77         mali_timeline_fence_copy_uk_fence(&fence, &uk_fence);
78
79 #if defined(CONFIG_SYNC)
80         sync_fd = mali_timeline_sync_fence_create(session->timeline_system, &fence);
81 #else
82         sync_fd = -1;
83 #endif /* defined(CONFIG_SYNC) */
84
85         if (0 != put_user(sync_fd, &uargs->sync_fd)) return -EFAULT;
86
87         return 0;
88 }