Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / gpu / drm / vmwgfx / vmwgfx_fence.h
blob50e9fdd7acf1d42400c6ea700b4485df53836716
1 /* SPDX-License-Identifier: GPL-2.0 OR MIT */
2 /**************************************************************************
4 * Copyright 2011-2012 VMware, Inc., Palo Alto, CA., USA
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:
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.
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.
26 **************************************************************************/
28 #ifndef _VMWGFX_FENCE_H_
30 #include <linux/dma-fence.h>
31 #include <linux/dma-fence-array.h>
33 #define VMW_FENCE_WAIT_TIMEOUT (5*HZ)
35 struct drm_device;
36 struct drm_file;
37 struct drm_pending_event;
39 struct vmw_private;
40 struct vmw_fence_manager;
42 /**
46 enum vmw_action_type {
47 VMW_ACTION_EVENT = 0,
48 VMW_ACTION_MAX
51 struct 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);
58 struct vmw_fence_obj {
59 struct dma_fence base;
61 struct list_head head;
62 struct list_head seq_passed_actions;
63 void (*destroy)(struct vmw_fence_obj *fence);
66 extern struct vmw_fence_manager *
67 vmw_fence_manager_init(struct vmw_private *dev_priv);
69 extern void vmw_fence_manager_takedown(struct vmw_fence_manager *fman);
71 static inline void
72 vmw_fence_obj_unreference(struct vmw_fence_obj **fence_p)
74 struct vmw_fence_obj *fence = *fence_p;
76 *fence_p = NULL;
77 if (fence)
78 dma_fence_put(&fence->base);
81 static inline struct vmw_fence_obj *
82 vmw_fence_obj_reference(struct vmw_fence_obj *fence)
84 if (fence)
85 dma_fence_get(&fence->base);
86 return fence;
89 extern void vmw_fences_update(struct vmw_fence_manager *fman);
91 extern bool vmw_fence_obj_signaled(struct vmw_fence_obj *fence);
93 extern int vmw_fence_obj_wait(struct vmw_fence_obj *fence,
94 bool lazy,
95 bool interruptible, unsigned long timeout);
97 extern void vmw_fence_obj_flush(struct vmw_fence_obj *fence);
99 extern int vmw_fence_create(struct vmw_fence_manager *fman,
100 uint32_t seqno,
101 struct vmw_fence_obj **p_fence);
103 extern 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);
109 extern int vmw_wait_dma_fence(struct vmw_fence_manager *fman,
110 struct dma_fence *fence);
112 extern void vmw_fence_fifo_up(struct vmw_fence_manager *fman);
114 extern void vmw_fence_fifo_down(struct vmw_fence_manager *fman);
116 extern int vmw_fence_obj_wait_ioctl(struct drm_device *dev, void *data,
117 struct drm_file *file_priv);
119 extern int vmw_fence_obj_signaled_ioctl(struct drm_device *dev, void *data,
120 struct drm_file *file_priv);
122 extern int vmw_fence_obj_unref_ioctl(struct drm_device *dev, void *data,
123 struct drm_file *file_priv);
124 extern int vmw_fence_event_ioctl(struct drm_device *dev, void *data,
125 struct drm_file *file_priv);
126 extern 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 /* _VMWGFX_FENCE_H_ */