import OT_8063_20170412 mali driver
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / misc / mediatek / gpu / mt8127 / mali / mali / linux / mali_ukk_timeline.c
1 /*
2 * This confidential and proprietary software may be used only as
3 * authorised by a licensing agreement from ARM Limited
4 * (C) COPYRIGHT 2013, 2015 ARM Limited
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
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 }