Merge tag 'lsk-v3.10-15.09-android'
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / arm / midgard / mali_kbase_sync.h
1 /*
2  *
3  * (C) COPYRIGHT 2012-2015 ARM Limited. All rights reserved.
4  *
5  * This program is free software and is provided to you under the terms of the
6  * GNU General Public License version 2 as published by the Free Software
7  * Foundation, and any use by you of this program is subject to the terms
8  * of such GNU licence.
9  *
10  * A copy of the licence is included with the program, and can also be obtained
11  * from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
12  * Boston, MA  02110-1301, USA.
13  *
14  */
15
16
17
18
19
20 /**
21  * @file mali_kbase_sync.h
22  *
23  */
24
25 #ifndef MALI_KBASE_SYNC_H
26 #define MALI_KBASE_SYNC_H
27
28 #include "sync.h"
29
30 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0)
31 /* For backwards compatiblility with kernels before 3.17. After 3.17
32  * sync_pt_parent is included in the kernel. */
33 static inline struct sync_timeline *sync_pt_parent(struct sync_pt *pt)
34 {
35         return pt->parent;
36 }
37 #endif
38
39 /*
40  * Create a stream object.
41  * Built on top of timeline object.
42  * Exposed as a file descriptor.
43  * Life-time controlled via the file descriptor:
44  * - dup to add a ref
45  * - close to remove a ref
46  */
47 int kbase_stream_create(const char *name, int *const out_fd);
48
49 /*
50  * Create a fence in a stream object
51  */
52 int kbase_stream_create_fence(int tl_fd);
53
54 /*
55  * Validate a fd to be a valid fence
56  * No reference is taken.
57  *
58  * This function is only usable to catch unintentional user errors early,
59  * it does not stop malicious code changing the fd after this function returns.
60  */
61 int kbase_fence_validate(int fd);
62
63 /* Returns true if the specified timeline is allocated by Mali */
64 int kbase_sync_timeline_is_ours(struct sync_timeline *timeline);
65
66 /* Allocates a timeline for Mali
67  *
68  * One timeline should be allocated per API context.
69  */
70 struct sync_timeline *kbase_sync_timeline_alloc(const char *name);
71
72 /* Allocates a sync point within the timeline.
73  *
74  * The timeline must be the one allocated by kbase_sync_timeline_alloc
75  *
76  * Sync points must be triggered in *exactly* the same order as they are allocated.
77  */
78 struct sync_pt *kbase_sync_pt_alloc(struct sync_timeline *parent);
79
80 /* Signals a particular sync point
81  *
82  * Sync points must be triggered in *exactly* the same order as they are allocated.
83  *
84  * If they are signalled in the wrong order then a message will be printed in debug
85  * builds and otherwise attempts to signal order sync_pts will be ignored.
86  *
87  * result can be negative to indicate error, any other value is interpreted as success.
88  */
89 void kbase_sync_signal_pt(struct sync_pt *pt, int result);
90
91 #endif