intel_ringbuffer.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #ifndef _INTEL_RINGBUFFER_H_
  2. #define _INTEL_RINGBUFFER_H_
  3. struct intel_hw_status_page {
  4. void *page_addr;
  5. unsigned int gfx_addr;
  6. struct drm_gem_object *obj;
  7. };
  8. struct drm_i915_gem_execbuffer2;
  9. struct intel_ring_buffer {
  10. const char *name;
  11. struct ring_regs {
  12. u32 ctl;
  13. u32 head;
  14. u32 tail;
  15. u32 start;
  16. } regs;
  17. unsigned int ring_flag;
  18. unsigned long size;
  19. unsigned int alignment;
  20. void *virtual_start;
  21. struct drm_device *dev;
  22. struct drm_gem_object *gem_object;
  23. unsigned int head;
  24. unsigned int tail;
  25. unsigned int space;
  26. struct intel_hw_status_page status_page;
  27. u32 irq_gem_seqno; /* last seq seem at irq time */
  28. u32 waiting_gem_seqno;
  29. int user_irq_refcount;
  30. void (*user_irq_get)(struct drm_device *dev,
  31. struct intel_ring_buffer *ring);
  32. void (*user_irq_put)(struct drm_device *dev,
  33. struct intel_ring_buffer *ring);
  34. void (*setup_status_page)(struct drm_device *dev,
  35. struct intel_ring_buffer *ring);
  36. int (*init)(struct drm_device *dev,
  37. struct intel_ring_buffer *ring);
  38. unsigned int (*get_head)(struct drm_device *dev,
  39. struct intel_ring_buffer *ring);
  40. unsigned int (*get_tail)(struct drm_device *dev,
  41. struct intel_ring_buffer *ring);
  42. unsigned int (*get_active_head)(struct drm_device *dev,
  43. struct intel_ring_buffer *ring);
  44. void (*advance_ring)(struct drm_device *dev,
  45. struct intel_ring_buffer *ring);
  46. void (*flush)(struct drm_device *dev,
  47. struct intel_ring_buffer *ring,
  48. u32 invalidate_domains,
  49. u32 flush_domains);
  50. u32 (*add_request)(struct drm_device *dev,
  51. struct intel_ring_buffer *ring,
  52. struct drm_file *file_priv,
  53. u32 flush_domains);
  54. u32 (*get_gem_seqno)(struct drm_device *dev,
  55. struct intel_ring_buffer *ring);
  56. int (*dispatch_gem_execbuffer)(struct drm_device *dev,
  57. struct intel_ring_buffer *ring,
  58. struct drm_i915_gem_execbuffer2 *exec,
  59. struct drm_clip_rect *cliprects,
  60. uint64_t exec_offset);
  61. /**
  62. * List of objects currently involved in rendering from the
  63. * ringbuffer.
  64. *
  65. * Includes buffers having the contents of their GPU caches
  66. * flushed, not necessarily primitives. last_rendering_seqno
  67. * represents when the rendering involved will be completed.
  68. *
  69. * A reference is held on the buffer while on this list.
  70. */
  71. struct list_head active_list;
  72. /**
  73. * List of breadcrumbs associated with GPU requests currently
  74. * outstanding.
  75. */
  76. struct list_head request_list;
  77. /**
  78. * Do we have some not yet emitted requests outstanding?
  79. */
  80. bool outstanding_lazy_request;
  81. wait_queue_head_t irq_queue;
  82. drm_local_map_t map;
  83. };
  84. static inline u32
  85. intel_read_status_page(struct intel_ring_buffer *ring,
  86. int reg)
  87. {
  88. u32 *regs = ring->status_page.page_addr;
  89. return regs[reg];
  90. }
  91. int intel_init_ring_buffer(struct drm_device *dev,
  92. struct intel_ring_buffer *ring);
  93. void intel_cleanup_ring_buffer(struct drm_device *dev,
  94. struct intel_ring_buffer *ring);
  95. int intel_wait_ring_buffer(struct drm_device *dev,
  96. struct intel_ring_buffer *ring, int n);
  97. int intel_wrap_ring_buffer(struct drm_device *dev,
  98. struct intel_ring_buffer *ring);
  99. void intel_ring_begin(struct drm_device *dev,
  100. struct intel_ring_buffer *ring, int n);
  101. static inline void intel_ring_emit(struct drm_device *dev,
  102. struct intel_ring_buffer *ring,
  103. unsigned int data)
  104. {
  105. unsigned int *virt = ring->virtual_start + ring->tail;
  106. *virt = data;
  107. ring->tail += 4;
  108. }
  109. void intel_fill_struct(struct drm_device *dev,
  110. struct intel_ring_buffer *ring,
  111. void *data,
  112. unsigned int len);
  113. void intel_ring_advance(struct drm_device *dev,
  114. struct intel_ring_buffer *ring);
  115. u32 intel_ring_get_seqno(struct drm_device *dev,
  116. struct intel_ring_buffer *ring);
  117. extern struct intel_ring_buffer render_ring;
  118. extern struct intel_ring_buffer bsd_ring;
  119. #endif /* _INTEL_RINGBUFFER_H_ */