2 * Copyright (C) 2010-2012 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.
11 #include <linux/fs.h> /* file system operations */
12 #include <asm/uaccess.h> /* user space access */
16 #include "mali_kernel_common.h"
17 #include "mali_session.h"
18 #include "mali_ukk_wrappers.h"
20 #include "mali_timeline.h"
21 #include "mali_timeline_fence_wait.h"
22 #include "mali_timeline_sync_fence.h"
24 int timeline_get_latest_point_wrapper(struct mali_session_data *session, _mali_uk_timeline_get_latest_point_s __user *uargs)
27 mali_timeline_id timeline;
28 mali_timeline_point point;
30 MALI_DEBUG_ASSERT_POINTER(session);
32 if (0 != get_user(val, &uargs->timeline)) return -EFAULT;
34 if (MALI_UK_TIMELINE_MAX <= val) {
38 timeline = (mali_timeline_id)val;
40 point = mali_timeline_system_get_latest_point(session->timeline_system, timeline);
42 if (0 != put_user(point, &uargs->point)) return -EFAULT;
47 int timeline_wait_wrapper(struct mali_session_data *session, _mali_uk_timeline_wait_s __user *uargs)
51 _mali_uk_fence_t uk_fence;
52 struct mali_timeline_fence fence;
54 MALI_DEBUG_ASSERT_POINTER(session);
56 if (0 != copy_from_user(&uk_fence, &uargs->fence, sizeof(_mali_uk_fence_t))) return -EFAULT;
57 if (0 != get_user(timeout, &uargs->timeout)) return -EFAULT;
59 mali_timeline_fence_copy_uk_fence(&fence, &uk_fence);
61 ret = mali_timeline_fence_wait(session->timeline_system, &fence, timeout);
62 status = (MALI_TRUE == ret ? 1 : 0);
64 if (0 != put_user(status, &uargs->status)) return -EFAULT;
69 int timeline_create_sync_fence_wrapper(struct mali_session_data *session, _mali_uk_timeline_create_sync_fence_s __user *uargs)
72 _mali_uk_fence_t uk_fence;
73 struct mali_timeline_fence fence;
75 MALI_DEBUG_ASSERT_POINTER(session);
77 if (0 != copy_from_user(&uk_fence, &uargs->fence, sizeof(_mali_uk_fence_t))) return -EFAULT;
78 mali_timeline_fence_copy_uk_fence(&fence, &uk_fence);
80 #if defined(CONFIG_SYNC)
81 sync_fd = mali_timeline_sync_fence_create(session->timeline_system, &fence);
84 #endif /* defined(CONFIG_SYNC) */
86 if (0 != put_user(sync_fd, &uargs->sync_fd)) return -EFAULT;