vmwgfx_fence.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /* SPDX-License-Identifier: GPL-2.0 OR MIT */
  2. /**************************************************************************
  3. *
  4. * Copyright 2011-2012 VMware, Inc., Palo Alto, CA., USA
  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. #ifndef _VMWGFX_FENCE_H_
  28. #include <linux/dma-fence.h>
  29. #include <linux/dma-fence-array.h>
  30. #define VMW_FENCE_WAIT_TIMEOUT (5*HZ)
  31. struct drm_device;
  32. struct drm_file;
  33. struct drm_pending_event;
  34. struct vmw_private;
  35. struct vmw_fence_manager;
  36. struct vmw_fence_obj {
  37. struct dma_fence base;
  38. bool waiter_added;
  39. struct list_head head;
  40. void (*destroy)(struct vmw_fence_obj *fence);
  41. };
  42. extern struct vmw_fence_manager *
  43. vmw_fence_manager_init(struct vmw_private *dev_priv);
  44. extern void vmw_fence_manager_takedown(struct vmw_fence_manager *fman);
  45. static inline void
  46. vmw_fence_obj_unreference(struct vmw_fence_obj **fence_p)
  47. {
  48. struct vmw_fence_obj *fence = *fence_p;
  49. *fence_p = NULL;
  50. if (fence)
  51. dma_fence_put(&fence->base);
  52. }
  53. static inline struct vmw_fence_obj *
  54. vmw_fence_obj_reference(struct vmw_fence_obj *fence)
  55. {
  56. if (fence)
  57. dma_fence_get(&fence->base);
  58. return fence;
  59. }
  60. u32 vmw_fences_update(struct vmw_fence_manager *fman);
  61. extern bool vmw_fence_obj_signaled(struct vmw_fence_obj *fence);
  62. extern int vmw_fence_obj_wait(struct vmw_fence_obj *fence,
  63. bool lazy,
  64. bool interruptible, unsigned long timeout);
  65. extern int vmw_fence_create(struct vmw_fence_manager *fman,
  66. uint32_t seqno,
  67. struct vmw_fence_obj **p_fence);
  68. extern int vmw_user_fence_create(struct drm_file *file_priv,
  69. struct vmw_fence_manager *fman,
  70. uint32_t sequence,
  71. struct vmw_fence_obj **p_fence,
  72. uint32_t *p_handle);
  73. extern void vmw_fence_fifo_up(struct vmw_fence_manager *fman);
  74. extern void vmw_fence_fifo_down(struct vmw_fence_manager *fman);
  75. extern int vmw_fence_obj_wait_ioctl(struct drm_device *dev, void *data,
  76. struct drm_file *file_priv);
  77. extern int vmw_fence_obj_signaled_ioctl(struct drm_device *dev, void *data,
  78. struct drm_file *file_priv);
  79. extern int vmw_fence_obj_unref_ioctl(struct drm_device *dev, void *data,
  80. struct drm_file *file_priv);
  81. extern int vmw_fence_event_ioctl(struct drm_device *dev, void *data,
  82. struct drm_file *file_priv);
  83. extern int vmw_event_fence_action_queue(struct drm_file *filee_priv,
  84. struct vmw_fence_obj *fence,
  85. struct drm_pending_event *event,
  86. uint32_t *tv_sec,
  87. uint32_t *tv_usec,
  88. bool interruptible);
  89. #endif /* _VMWGFX_FENCE_H_ */