Merge remote-tracking branch 'origin/develop-3.10' into develop-3.10-next
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / arm / mali400 / mali / linux / mali_sync.h
1 /*
2  * This confidential and proprietary software may be used only as
3  * authorised by a licensing agreement from ARM Limited
4  * (C) COPYRIGHT 2012-2013 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
11 /**
12  * @file mali_sync.h
13  *
14  * Mali interface for Linux sync objects.
15  */
16
17 #ifndef _MALI_SYNC_H_
18 #define _MALI_SYNC_H_
19
20 #if defined(CONFIG_SYNC)
21
22 #include <linux/seq_file.h>
23 #include "sync.h"
24
25 #include "mali_osk.h"
26
27 struct mali_sync_flag;
28
29 /**
30  * Create a sync timeline.
31  *
32  * @param name Name of the sync timeline.
33  * @return The new sync timeline if successful, NULL if not.
34  */
35 struct sync_timeline *mali_sync_timeline_create(const char *name);
36
37 /**
38  * Check if sync timeline belongs to Mali.
39  *
40  * @param sync_tl Sync timeline to check.
41  * @return MALI_TRUE if sync timeline belongs to Mali, MALI_FALSE if not.
42  */
43 mali_bool mali_sync_timeline_is_ours(struct sync_timeline *sync_tl);
44
45 /**
46  * Creates a file descriptor representing the sync fence.  Will release sync fence if allocation of
47  * file descriptor fails.
48  *
49  * @param sync_fence Sync fence.
50  * @return File descriptor representing sync fence if successful, or -1 if not.
51  */
52 s32 mali_sync_fence_fd_alloc(struct sync_fence *sync_fence);
53
54 /**
55  * Merges two sync fences.  Both input sync fences will be released.
56  *
57  * @param sync_fence1 First sync fence.
58  * @param sync_fence2 Second sync fence.
59  * @return New sync fence that is the result of the merger if successful, or NULL if not.
60  */
61 struct sync_fence *mali_sync_fence_merge(struct sync_fence *sync_fence1, struct sync_fence *sync_fence2);
62
63 /**
64  * Create a sync fence that is already signaled.
65  *
66  * @param tl Sync timeline.
67  * @return New signaled sync fence if successful, NULL if not.
68  */
69 struct sync_fence *mali_sync_timeline_create_signaled_fence(struct sync_timeline *sync_tl);
70
71 /**
72  * Create a sync flag.
73  *
74  * @param sync_tl Sync timeline.
75  * @param point Point on Mali timeline.
76  * @return New sync flag if successful, NULL if not.
77  */
78 struct mali_sync_flag *mali_sync_flag_create(struct sync_timeline *sync_tl, u32 point);
79
80 /**
81  * Grab sync flag reference.
82  *
83  * @param flag Sync flag.
84  */
85 void mali_sync_flag_get(struct mali_sync_flag *flag);
86
87 /**
88  * Release sync flag reference.  If this was the last reference, the sync flag will be freed.
89  *
90  * @param flag Sync flag.
91  */
92 void mali_sync_flag_put(struct mali_sync_flag *flag);
93
94 /**
95  * Signal sync flag.  All sync fences created from this flag will be signaled.
96  *
97  * @param flag Sync flag to signal.
98  * @param error Negative error code, or 0 if no error.
99  */
100 void mali_sync_flag_signal(struct mali_sync_flag *flag, int error);
101
102 /**
103  * Create a sync fence attached to given sync flag.
104  *
105  * @param flag Sync flag.
106  * @return New sync fence if successful, NULL if not.
107  */
108 struct sync_fence *mali_sync_flag_create_fence(struct mali_sync_flag *flag);
109
110 #endif /* defined(CONFIG_SYNC) */
111
112 #endif /* _MALI_SYNC_H_ */