blob: 8c18d32bd1c3cca19c86d669ecec9f76e5b03de8 [file] [log] [blame]
Thomas Hellstromae2a1042011-09-01 20:18:44 +00001/**************************************************************************
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
30#define VMW_FENCE_WAIT_TIMEOUT (5*HZ)
31
32struct vmw_private;
33
34struct vmw_fence_manager;
35
36/**
37 *
38 *
39 */
Thomas Hellstrom57c5ee72011-10-10 12:23:26 +020040enum vmw_action_type {
41 VMW_ACTION_EVENT = 0,
42 VMW_ACTION_MAX
43};
44
Thomas Hellstromae2a1042011-09-01 20:18:44 +000045struct vmw_fence_action {
46 struct list_head head;
Thomas Hellstrom57c5ee72011-10-10 12:23:26 +020047 enum vmw_action_type type;
Thomas Hellstromae2a1042011-09-01 20:18:44 +000048 void (*seq_passed) (struct vmw_fence_action *action);
49 void (*cleanup) (struct vmw_fence_action *action);
50};
51
52struct vmw_fence_obj {
53 struct kref kref;
54 u32 seqno;
55
56 struct vmw_fence_manager *fman;
57 struct list_head head;
58 uint32_t signaled;
Thomas Hellstromae2a1042011-09-01 20:18:44 +000059 struct list_head seq_passed_actions;
60 void (*destroy)(struct vmw_fence_obj *fence);
61 wait_queue_head_t queue;
62};
63
64extern struct vmw_fence_manager *
65vmw_fence_manager_init(struct vmw_private *dev_priv);
66
67extern void vmw_fence_manager_takedown(struct vmw_fence_manager *fman);
68
69extern void vmw_fence_obj_unreference(struct vmw_fence_obj **fence_p);
70
71extern struct vmw_fence_obj *
72vmw_fence_obj_reference(struct vmw_fence_obj *fence);
73
Thomas Hellstrom57c5ee72011-10-10 12:23:26 +020074extern void vmw_fences_update(struct vmw_fence_manager *fman);
Thomas Hellstromae2a1042011-09-01 20:18:44 +000075
Maarten Lankhorstc060a4e2014-03-26 13:06:24 +010076extern bool vmw_fence_obj_signaled(struct vmw_fence_obj *fence);
Thomas Hellstromae2a1042011-09-01 20:18:44 +000077
Maarten Lankhorstc060a4e2014-03-26 13:06:24 +010078extern int vmw_fence_obj_wait(struct vmw_fence_obj *fence,
Thomas Hellstromae2a1042011-09-01 20:18:44 +000079 bool lazy,
80 bool interruptible, unsigned long timeout);
81
82extern void vmw_fence_obj_flush(struct vmw_fence_obj *fence);
83
84extern int vmw_fence_create(struct vmw_fence_manager *fman,
85 uint32_t seqno,
Thomas Hellstromae2a1042011-09-01 20:18:44 +000086 struct vmw_fence_obj **p_fence);
87
88extern int vmw_user_fence_create(struct drm_file *file_priv,
89 struct vmw_fence_manager *fman,
90 uint32_t sequence,
Thomas Hellstromae2a1042011-09-01 20:18:44 +000091 struct vmw_fence_obj **p_fence,
92 uint32_t *p_handle);
93
94extern void vmw_fence_fifo_up(struct vmw_fence_manager *fman);
95
96extern void vmw_fence_fifo_down(struct vmw_fence_manager *fman);
97
98extern int vmw_fence_obj_wait_ioctl(struct drm_device *dev, void *data,
99 struct drm_file *file_priv);
100
101extern int vmw_fence_obj_signaled_ioctl(struct drm_device *dev, void *data,
102 struct drm_file *file_priv);
103
104extern int vmw_fence_obj_unref_ioctl(struct drm_device *dev, void *data,
105 struct drm_file *file_priv);
Thomas Hellstrom57c5ee72011-10-10 12:23:26 +0200106extern int vmw_fence_event_ioctl(struct drm_device *dev, void *data,
107 struct drm_file *file_priv);
Thomas Hellstrom6b82ef52012-02-09 16:56:42 +0100108extern void vmw_event_fence_fpriv_gone(struct vmw_fence_manager *fman,
109 struct list_head *event_list);
Thomas Hellstromf9cd8ec2012-02-09 16:56:48 +0100110extern int vmw_event_fence_action_queue(struct drm_file *filee_priv,
111 struct vmw_fence_obj *fence,
112 struct drm_pending_event *event,
113 uint32_t *tv_sec,
114 uint32_t *tv_usec,
115 bool interruptible);
Thomas Hellstromae2a1042011-09-01 20:18:44 +0000116#endif /* _VMWGFX_FENCE_H_ */