i915_sw_fence.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * i915_sw_fence.h - library routines for N:M synchronisation points
  3. *
  4. * Copyright (C) 2016 Intel Corporation
  5. *
  6. * This file is released under the GPLv2.
  7. *
  8. */
  9. #ifndef _I915_SW_FENCE_H_
  10. #define _I915_SW_FENCE_H_
  11. #include <linux/gfp.h>
  12. #include <linux/kref.h>
  13. #include <linux/notifier.h> /* for NOTIFY_DONE */
  14. #include <linux/wait.h>
  15. struct completion;
  16. struct fence;
  17. struct fence_ops;
  18. struct reservation_object;
  19. struct i915_sw_fence {
  20. wait_queue_head_t wait;
  21. unsigned long flags;
  22. struct kref kref;
  23. atomic_t pending;
  24. };
  25. #define I915_SW_FENCE_CHECKED_BIT 0 /* used internally for DAG checking */
  26. #define I915_SW_FENCE_PRIVATE_BIT 1 /* available for use by owner */
  27. #define I915_SW_FENCE_MASK (~3)
  28. enum i915_sw_fence_notify {
  29. FENCE_COMPLETE,
  30. FENCE_FREE
  31. };
  32. typedef int (*i915_sw_fence_notify_t)(struct i915_sw_fence *,
  33. enum i915_sw_fence_notify state);
  34. #define __i915_sw_fence_call __aligned(4)
  35. void i915_sw_fence_init(struct i915_sw_fence *fence, i915_sw_fence_notify_t fn);
  36. void i915_sw_fence_commit(struct i915_sw_fence *fence);
  37. int i915_sw_fence_await_sw_fence(struct i915_sw_fence *fence,
  38. struct i915_sw_fence *after,
  39. wait_queue_t *wq);
  40. int i915_sw_fence_await_dma_fence(struct i915_sw_fence *fence,
  41. struct fence *dma,
  42. unsigned long timeout,
  43. gfp_t gfp);
  44. int i915_sw_fence_await_reservation(struct i915_sw_fence *fence,
  45. struct reservation_object *resv,
  46. const struct fence_ops *exclude,
  47. bool write,
  48. unsigned long timeout,
  49. gfp_t gfp);
  50. static inline bool i915_sw_fence_done(const struct i915_sw_fence *fence)
  51. {
  52. return atomic_read(&fence->pending) < 0;
  53. }
  54. #endif /* _I915_SW_FENCE_H_ */