intel_ringbuffer.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. void (*set_tail)(struct drm_device *dev,
  46. u32 value);
  47. unsigned int (*get_active_head)(struct drm_device *dev,
  48. struct intel_ring_buffer *ring);
  49. void (*advance_ring)(struct drm_device *dev,
  50. struct intel_ring_buffer *ring);
  51. void (*flush)(struct drm_device *dev,
  52. struct intel_ring_buffer *ring,
  53. u32 invalidate_domains,
  54. u32 flush_domains);
  55. u32 (*add_request)(struct drm_device *dev,
  56. struct intel_ring_buffer *ring,
  57. struct drm_file *file_priv,
  58. u32 flush_domains);
  59. u32 (*get_gem_seqno)(struct drm_device *dev,
  60. struct intel_ring_buffer *ring);
  61. int (*dispatch_gem_execbuffer)(struct drm_device *dev,
  62. struct intel_ring_buffer *ring,
  63. struct drm_i915_gem_execbuffer2 *exec,
  64. struct drm_clip_rect *cliprects,
  65. uint64_t exec_offset);
  66. /**
  67. * List of objects currently involved in rendering from the
  68. * ringbuffer.
  69. *
  70. * Includes buffers having the contents of their GPU caches
  71. * flushed, not necessarily primitives. last_rendering_seqno
  72. * represents when the rendering involved will be completed.
  73. *
  74. * A reference is held on the buffer while on this list.
  75. */
  76. struct list_head active_list;
  77. /**
  78. * List of breadcrumbs associated with GPU requests currently
  79. * outstanding.
  80. */
  81. struct list_head request_list;
  82. /**
  83. * Do we have some not yet emitted requests outstanding?
  84. */
  85. bool outstanding_lazy_request;
  86. wait_queue_head_t irq_queue;
  87. drm_local_map_t map;
  88. };
  89. static inline u32
  90. intel_read_status_page(struct intel_ring_buffer *ring,
  91. int reg)
  92. {
  93. u32 *regs = ring->status_page.page_addr;
  94. return regs[reg];
  95. }
  96. int intel_init_ring_buffer(struct drm_device *dev,
  97. struct intel_ring_buffer *ring);
  98. void intel_cleanup_ring_buffer(struct drm_device *dev,
  99. struct intel_ring_buffer *ring);
  100. int intel_wait_ring_buffer(struct drm_device *dev,
  101. struct intel_ring_buffer *ring, int n);
  102. int intel_wrap_ring_buffer(struct drm_device *dev,
  103. struct intel_ring_buffer *ring);
  104. void intel_ring_begin(struct drm_device *dev,
  105. struct intel_ring_buffer *ring, int n);
  106. static inline void intel_ring_emit(struct drm_device *dev,
  107. struct intel_ring_buffer *ring,
  108. unsigned int data)
  109. {
  110. unsigned int *virt = ring->virtual_start + ring->tail;
  111. *virt = data;
  112. ring->tail += 4;
  113. }
  114. void intel_fill_struct(struct drm_device *dev,
  115. struct intel_ring_buffer *ring,
  116. void *data,
  117. unsigned int len);
  118. void intel_ring_advance(struct drm_device *dev,
  119. struct intel_ring_buffer *ring);
  120. u32 intel_ring_get_seqno(struct drm_device *dev,
  121. struct intel_ring_buffer *ring);
  122. int intel_init_render_ring_buffer(struct drm_device *dev);
  123. int intel_init_bsd_ring_buffer(struct drm_device *dev);
  124. #endif /* _INTEL_RINGBUFFER_H_ */