Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 OR MIT */
0002 /**************************************************************************
0003  *
0004  * Copyright 2011-2012 VMware, Inc., Palo Alto, CA., USA
0005  *
0006  * Permission is hereby granted, free of charge, to any person obtaining a
0007  * copy of this software and associated documentation files (the
0008  * "Software"), to deal in the Software without restriction, including
0009  * without limitation the rights to use, copy, modify, merge, publish,
0010  * distribute, sub license, and/or sell copies of the Software, and to
0011  * permit persons to whom the Software is furnished to do so, subject to
0012  * the following conditions:
0013  *
0014  * The above copyright notice and this permission notice (including the
0015  * next paragraph) shall be included in all copies or substantial portions
0016  * of the Software.
0017  *
0018  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0019  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0020  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
0021  * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
0022  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
0023  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
0024  * USE OR OTHER DEALINGS IN THE SOFTWARE.
0025  *
0026  **************************************************************************/
0027 
0028 #ifndef _VMWGFX_FENCE_H_
0029 
0030 #include <linux/dma-fence.h>
0031 #include <linux/dma-fence-array.h>
0032 
0033 #define VMW_FENCE_WAIT_TIMEOUT (5*HZ)
0034 
0035 struct drm_device;
0036 struct drm_file;
0037 struct drm_pending_event;
0038 
0039 struct vmw_private;
0040 struct vmw_fence_manager;
0041 
0042 /**
0043  *
0044  *
0045  */
0046 enum vmw_action_type {
0047     VMW_ACTION_EVENT = 0,
0048     VMW_ACTION_MAX
0049 };
0050 
0051 struct vmw_fence_action {
0052     struct list_head head;
0053     enum vmw_action_type type;
0054     void (*seq_passed) (struct vmw_fence_action *action);
0055     void (*cleanup) (struct vmw_fence_action *action);
0056 };
0057 
0058 struct vmw_fence_obj {
0059     struct dma_fence base;
0060 
0061     struct list_head head;
0062     struct list_head seq_passed_actions;
0063     void (*destroy)(struct vmw_fence_obj *fence);
0064 };
0065 
0066 extern struct vmw_fence_manager *
0067 vmw_fence_manager_init(struct vmw_private *dev_priv);
0068 
0069 extern void vmw_fence_manager_takedown(struct vmw_fence_manager *fman);
0070 
0071 static inline void
0072 vmw_fence_obj_unreference(struct vmw_fence_obj **fence_p)
0073 {
0074     struct vmw_fence_obj *fence = *fence_p;
0075 
0076     *fence_p = NULL;
0077     if (fence)
0078         dma_fence_put(&fence->base);
0079 }
0080 
0081 static inline struct vmw_fence_obj *
0082 vmw_fence_obj_reference(struct vmw_fence_obj *fence)
0083 {
0084     if (fence)
0085         dma_fence_get(&fence->base);
0086     return fence;
0087 }
0088 
0089 extern void vmw_fences_update(struct vmw_fence_manager *fman);
0090 
0091 extern bool vmw_fence_obj_signaled(struct vmw_fence_obj *fence);
0092 
0093 extern int vmw_fence_obj_wait(struct vmw_fence_obj *fence,
0094                   bool lazy,
0095                   bool interruptible, unsigned long timeout);
0096 
0097 extern int vmw_fence_create(struct vmw_fence_manager *fman,
0098                 uint32_t seqno,
0099                 struct vmw_fence_obj **p_fence);
0100 
0101 extern int vmw_user_fence_create(struct drm_file *file_priv,
0102                  struct vmw_fence_manager *fman,
0103                  uint32_t sequence,
0104                  struct vmw_fence_obj **p_fence,
0105                  uint32_t *p_handle);
0106 
0107 extern void vmw_fence_fifo_up(struct vmw_fence_manager *fman);
0108 
0109 extern void vmw_fence_fifo_down(struct vmw_fence_manager *fman);
0110 
0111 extern int vmw_fence_obj_wait_ioctl(struct drm_device *dev, void *data,
0112                     struct drm_file *file_priv);
0113 
0114 extern int vmw_fence_obj_signaled_ioctl(struct drm_device *dev, void *data,
0115                     struct drm_file *file_priv);
0116 
0117 extern int vmw_fence_obj_unref_ioctl(struct drm_device *dev, void *data,
0118                      struct drm_file *file_priv);
0119 extern int vmw_fence_event_ioctl(struct drm_device *dev, void *data,
0120                  struct drm_file *file_priv);
0121 extern int vmw_event_fence_action_queue(struct drm_file *filee_priv,
0122                     struct vmw_fence_obj *fence,
0123                     struct drm_pending_event *event,
0124                     uint32_t *tv_sec,
0125                     uint32_t *tv_usec,
0126                     bool interruptible);
0127 #endif /* _VMWGFX_FENCE_H_ */