intel_ringbuffer.h 3.8 KB

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