2 * Copyright (C) 2013, 2016 ARM Limited. All rights reserved.
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.
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.
10 #include <linux/fs.h> /* file system operations */
11 #include <asm/uaccess.h> /* user space access */
15 #include "mali_kernel_common.h"
16 #include "mali_session.h"
17 #include "mali_ukk_wrappers.h"
19 #include "mali_timeline.h"
20 #include "mali_timeline_fence_wait.h"
21 #include "mali_timeline_sync_fence.h"
23 int timeline_get_latest_point_wrapper(struct mali_session_data *session, _mali_uk_timeline_get_latest_point_s __user *uargs)
26 mali_timeline_id timeline;
27 mali_timeline_point point;
29 MALI_DEBUG_ASSERT_POINTER(session);
31 if (0 != get_user(val, &uargs->timeline)) return -EFAULT;
33 if (MALI_UK_TIMELINE_MAX <= val) {
37 timeline = (mali_timeline_id)val;
39 point = mali_timeline_system_get_latest_point(session->timeline_system, timeline);
41 if (0 != put_user(point, &uargs->point)) return -EFAULT;
46 int timeline_wait_wrapper(struct mali_session_data *session, _mali_uk_timeline_wait_s __user *uargs)
50 _mali_uk_fence_t uk_fence;
51 struct mali_timeline_fence fence;
53 MALI_DEBUG_ASSERT_POINTER(session);
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;
58 mali_timeline_fence_copy_uk_fence(&fence, &uk_fence);
60 ret = mali_timeline_fence_wait(session->timeline_system, &fence, timeout);
61 status = (MALI_TRUE == ret ? 1 : 0);
63 if (0 != put_user(status, &uargs->status)) return -EFAULT;
68 int timeline_create_sync_fence_wrapper(struct mali_session_data *session, _mali_uk_timeline_create_sync_fence_s __user *uargs)
71 _mali_uk_fence_t uk_fence;
72 struct mali_timeline_fence fence;
74 MALI_DEBUG_ASSERT_POINTER(session);
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);
79 #if defined(CONFIG_SYNC)
80 sync_fd = mali_timeline_sync_fence_create(session->timeline_system, &fence);
83 #endif /* defined(CONFIG_SYNC) */
85 if (0 != put_user(sync_fd, &uargs->sync_fd)) return -EFAULT;