Commit | Line | Data |
---|---|---|
ae2a1040 TH |
1 | /************************************************************************** |
2 | * | |
3 | * Copyright © 2011 VMware, Inc., Palo Alto, CA., USA | |
4 | * All Rights Reserved. | |
5 | * | |
6 | * Permission is hereby granted, free of charge, to any person obtaining a | |
7 | * copy of this software and associated documentation files (the | |
8 | * "Software"), to deal in the Software without restriction, including | |
9 | * without limitation the rights to use, copy, modify, merge, publish, | |
10 | * distribute, sub license, and/or sell copies of the Software, and to | |
11 | * permit persons to whom the Software is furnished to do so, subject to | |
12 | * the following conditions: | |
13 | * | |
14 | * The above copyright notice and this permission notice (including the | |
15 | * next paragraph) shall be included in all copies or substantial portions | |
16 | * of the Software. | |
17 | * | |
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL | |
21 | * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, | |
22 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | |
23 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | |
24 | * USE OR OTHER DEALINGS IN THE SOFTWARE. | |
25 | * | |
26 | **************************************************************************/ | |
27 | ||
28 | #ifndef _VMWGFX_FENCE_H_ | |
29 | ||
2298e804 ML |
30 | #include <linux/fence.h> |
31 | ||
ae2a1040 TH |
32 | #define VMW_FENCE_WAIT_TIMEOUT (5*HZ) |
33 | ||
34 | struct vmw_private; | |
35 | ||
36 | struct vmw_fence_manager; | |
37 | ||
38 | /** | |
39 | * | |
40 | * | |
41 | */ | |
57c5ee79 TH |
42 | enum vmw_action_type { |
43 | VMW_ACTION_EVENT = 0, | |
44 | VMW_ACTION_MAX | |
45 | }; | |
46 | ||
ae2a1040 TH |
47 | struct vmw_fence_action { |
48 | struct list_head head; | |
57c5ee79 | 49 | enum vmw_action_type type; |
ae2a1040 TH |
50 | void (*seq_passed) (struct vmw_fence_action *action); |
51 | void (*cleanup) (struct vmw_fence_action *action); | |
52 | }; | |
53 | ||
54 | struct vmw_fence_obj { | |
2298e804 | 55 | struct fence base; |
ae2a1040 | 56 | |
ae2a1040 | 57 | struct list_head head; |
ae2a1040 TH |
58 | struct list_head seq_passed_actions; |
59 | void (*destroy)(struct vmw_fence_obj *fence); | |
ae2a1040 TH |
60 | }; |
61 | ||
62 | extern struct vmw_fence_manager * | |
63 | vmw_fence_manager_init(struct vmw_private *dev_priv); | |
64 | ||
65 | extern void vmw_fence_manager_takedown(struct vmw_fence_manager *fman); | |
66 | ||
2298e804 ML |
67 | static inline void |
68 | vmw_fence_obj_unreference(struct vmw_fence_obj **fence_p) | |
69 | { | |
70 | struct vmw_fence_obj *fence = *fence_p; | |
71 | ||
72 | *fence_p = NULL; | |
73 | if (fence) | |
74 | fence_put(&fence->base); | |
75 | } | |
76 | ||
77 | static inline struct vmw_fence_obj * | |
78 | vmw_fence_obj_reference(struct vmw_fence_obj *fence) | |
79 | { | |
80 | if (fence) | |
81 | fence_get(&fence->base); | |
82 | return fence; | |
83 | } | |
ae2a1040 | 84 | |
57c5ee79 | 85 | extern void vmw_fences_update(struct vmw_fence_manager *fman); |
ae2a1040 | 86 | |
c060a4e1 | 87 | extern bool vmw_fence_obj_signaled(struct vmw_fence_obj *fence); |
ae2a1040 | 88 | |
c060a4e1 | 89 | extern int vmw_fence_obj_wait(struct vmw_fence_obj *fence, |
ae2a1040 TH |
90 | bool lazy, |
91 | bool interruptible, unsigned long timeout); | |
92 | ||
93 | extern void vmw_fence_obj_flush(struct vmw_fence_obj *fence); | |
94 | ||
95 | extern int vmw_fence_create(struct vmw_fence_manager *fman, | |
96 | uint32_t seqno, | |
ae2a1040 TH |
97 | struct vmw_fence_obj **p_fence); |
98 | ||
99 | extern int vmw_user_fence_create(struct drm_file *file_priv, | |
100 | struct vmw_fence_manager *fman, | |
101 | uint32_t sequence, | |
ae2a1040 TH |
102 | struct vmw_fence_obj **p_fence, |
103 | uint32_t *p_handle); | |
104 | ||
105 | extern void vmw_fence_fifo_up(struct vmw_fence_manager *fman); | |
106 | ||
107 | extern void vmw_fence_fifo_down(struct vmw_fence_manager *fman); | |
108 | ||
109 | extern int vmw_fence_obj_wait_ioctl(struct drm_device *dev, void *data, | |
110 | struct drm_file *file_priv); | |
111 | ||
112 | extern int vmw_fence_obj_signaled_ioctl(struct drm_device *dev, void *data, | |
113 | struct drm_file *file_priv); | |
114 | ||
115 | extern int vmw_fence_obj_unref_ioctl(struct drm_device *dev, void *data, | |
116 | struct drm_file *file_priv); | |
57c5ee79 TH |
117 | extern int vmw_fence_event_ioctl(struct drm_device *dev, void *data, |
118 | struct drm_file *file_priv); | |
6b82ef50 TH |
119 | extern void vmw_event_fence_fpriv_gone(struct vmw_fence_manager *fman, |
120 | struct list_head *event_list); | |
f9cd8ec3 TH |
121 | extern int vmw_event_fence_action_queue(struct drm_file *filee_priv, |
122 | struct vmw_fence_obj *fence, | |
123 | struct drm_pending_event *event, | |
124 | uint32_t *tv_sec, | |
125 | uint32_t *tv_usec, | |
126 | bool interruptible); | |
ae2a1040 | 127 | #endif /* _VMWGFX_FENCE_H_ */ |