vmwgfx_fence.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /**************************************************************************
  2. *
  3. * Copyright © 2011-2012 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. #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 vmw_private;
  32. struct vmw_fence_manager;
  33. /**
  34. *
  35. *
  36. */
  37. enum vmw_action_type {
  38. VMW_ACTION_EVENT = 0,
  39. VMW_ACTION_MAX
  40. };
  41. struct vmw_fence_action {
  42. struct list_head head;
  43. enum vmw_action_type type;
  44. void (*seq_passed) (struct vmw_fence_action *action);
  45. void (*cleanup) (struct vmw_fence_action *action);
  46. };
  47. struct vmw_fence_obj {
  48. struct dma_fence base;
  49. struct list_head head;
  50. struct list_head seq_passed_actions;
  51. void (*destroy)(struct vmw_fence_obj *fence);
  52. };
  53. extern struct vmw_fence_manager *
  54. vmw_fence_manager_init(struct vmw_private *dev_priv);
  55. extern void vmw_fence_manager_takedown(struct vmw_fence_manager *fman);
  56. static inline void
  57. vmw_fence_obj_unreference(struct vmw_fence_obj **fence_p)
  58. {
  59. struct vmw_fence_obj *fence = *fence_p;
  60. *fence_p = NULL;
  61. if (fence)
  62. dma_fence_put(&fence->base);
  63. }
  64. static inline struct vmw_fence_obj *
  65. vmw_fence_obj_reference(struct vmw_fence_obj *fence)
  66. {
  67. if (fence)
  68. dma_fence_get(&fence->base);
  69. return fence;
  70. }
  71. extern void vmw_fences_update(struct vmw_fence_manager *fman);
  72. extern bool vmw_fence_obj_signaled(struct vmw_fence_obj *fence);
  73. extern int vmw_fence_obj_wait(struct vmw_fence_obj *fence,
  74. bool lazy,
  75. bool interruptible, unsigned long timeout);
  76. extern void vmw_fence_obj_flush(struct vmw_fence_obj *fence);
  77. extern int vmw_fence_create(struct vmw_fence_manager *fman,
  78. uint32_t seqno,
  79. struct vmw_fence_obj **p_fence);
  80. extern int vmw_user_fence_create(struct drm_file *file_priv,
  81. struct vmw_fence_manager *fman,
  82. uint32_t sequence,
  83. struct vmw_fence_obj **p_fence,
  84. uint32_t *p_handle);
  85. extern int vmw_wait_dma_fence(struct vmw_fence_manager *fman,
  86. struct dma_fence *fence);
  87. extern void vmw_fence_fifo_up(struct vmw_fence_manager *fman);
  88. extern void vmw_fence_fifo_down(struct vmw_fence_manager *fman);
  89. extern int vmw_fence_obj_wait_ioctl(struct drm_device *dev, void *data,
  90. struct drm_file *file_priv);
  91. extern int vmw_fence_obj_signaled_ioctl(struct drm_device *dev, void *data,
  92. struct drm_file *file_priv);
  93. extern int vmw_fence_obj_unref_ioctl(struct drm_device *dev, void *data,
  94. struct drm_file *file_priv);
  95. extern int vmw_fence_event_ioctl(struct drm_device *dev, void *data,
  96. struct drm_file *file_priv);
  97. extern int vmw_event_fence_action_queue(struct drm_file *filee_priv,
  98. struct vmw_fence_obj *fence,
  99. struct drm_pending_event *event,
  100. uint32_t *tv_sec,
  101. uint32_t *tv_usec,
  102. bool interruptible);
  103. #endif /* _VMWGFX_FENCE_H_ */