1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28#ifndef _VMWGFX_FENCE_H_
29
30#include <linux/dma-fence.h>
31#include <linux/dma-fence-array.h>
32
33#define VMW_FENCE_WAIT_TIMEOUT (5*HZ)
34
35struct drm_device;
36struct drm_file;
37struct drm_pending_event;
38
39struct vmw_private;
40struct vmw_fence_manager;
41
42
43
44
45
46enum vmw_action_type {
47 VMW_ACTION_EVENT = 0,
48 VMW_ACTION_MAX
49};
50
51struct vmw_fence_action {
52 struct list_head head;
53 enum vmw_action_type type;
54 void (*seq_passed) (struct vmw_fence_action *action);
55 void (*cleanup) (struct vmw_fence_action *action);
56};
57
58struct vmw_fence_obj {
59 struct dma_fence base;
60
61 struct list_head head;
62 struct list_head seq_passed_actions;
63 void (*destroy)(struct vmw_fence_obj *fence);
64};
65
66extern struct vmw_fence_manager *
67vmw_fence_manager_init(struct vmw_private *dev_priv);
68
69extern void vmw_fence_manager_takedown(struct vmw_fence_manager *fman);
70
71static inline void
72vmw_fence_obj_unreference(struct vmw_fence_obj **fence_p)
73{
74 struct vmw_fence_obj *fence = *fence_p;
75
76 *fence_p = NULL;
77 if (fence)
78 dma_fence_put(&fence->base);
79}
80
81static inline struct vmw_fence_obj *
82vmw_fence_obj_reference(struct vmw_fence_obj *fence)
83{
84 if (fence)
85 dma_fence_get(&fence->base);
86 return fence;
87}
88
89extern void vmw_fences_update(struct vmw_fence_manager *fman);
90
91extern bool vmw_fence_obj_signaled(struct vmw_fence_obj *fence);
92
93extern int vmw_fence_obj_wait(struct vmw_fence_obj *fence,
94 bool lazy,
95 bool interruptible, unsigned long timeout);
96
97extern void vmw_fence_obj_flush(struct vmw_fence_obj *fence);
98
99extern int vmw_fence_create(struct vmw_fence_manager *fman,
100 uint32_t seqno,
101 struct vmw_fence_obj **p_fence);
102
103extern int vmw_user_fence_create(struct drm_file *file_priv,
104 struct vmw_fence_manager *fman,
105 uint32_t sequence,
106 struct vmw_fence_obj **p_fence,
107 uint32_t *p_handle);
108
109extern int vmw_wait_dma_fence(struct vmw_fence_manager *fman,
110 struct dma_fence *fence);
111
112extern void vmw_fence_fifo_up(struct vmw_fence_manager *fman);
113
114extern void vmw_fence_fifo_down(struct vmw_fence_manager *fman);
115
116extern int vmw_fence_obj_wait_ioctl(struct drm_device *dev, void *data,
117 struct drm_file *file_priv);
118
119extern int vmw_fence_obj_signaled_ioctl(struct drm_device *dev, void *data,
120 struct drm_file *file_priv);
121
122extern int vmw_fence_obj_unref_ioctl(struct drm_device *dev, void *data,
123 struct drm_file *file_priv);
124extern int vmw_fence_event_ioctl(struct drm_device *dev, void *data,
125 struct drm_file *file_priv);
126extern int vmw_event_fence_action_queue(struct drm_file *filee_priv,
127 struct vmw_fence_obj *fence,
128 struct drm_pending_event *event,
129 uint32_t *tv_sec,
130 uint32_t *tv_usec,
131 bool interruptible);
132#endif
133