Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 1 | #ifndef _INTEL_RINGBUFFER_H_ |
| 2 | #define _INTEL_RINGBUFFER_H_ |
| 3 | |
| 4 | struct intel_hw_status_page { |
Chris Wilson | 78501ea | 2010-10-27 12:18:21 +0100 | [diff] [blame] | 5 | u32 __iomem *page_addr; |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 6 | unsigned int gfx_addr; |
| 7 | struct drm_gem_object *obj; |
| 8 | }; |
| 9 | |
Daniel Vetter | 870e86d | 2010-08-02 16:29:44 +0200 | [diff] [blame] | 10 | #define I915_READ_TAIL(ring) I915_READ(RING_TAIL(ring->mmio_base)) |
| 11 | #define I915_WRITE_TAIL(ring, val) I915_WRITE(RING_TAIL(ring->mmio_base), val) |
Daniel Vetter | 6c0e1c5 | 2010-08-02 16:33:33 +0200 | [diff] [blame] | 12 | #define I915_READ_START(ring) I915_READ(RING_START(ring->mmio_base)) |
| 13 | #define I915_WRITE_START(ring, val) I915_WRITE(RING_START(ring->mmio_base), val) |
Daniel Vetter | 570ef60 | 2010-08-02 17:06:23 +0200 | [diff] [blame] | 14 | #define I915_READ_HEAD(ring) I915_READ(RING_HEAD(ring->mmio_base)) |
| 15 | #define I915_WRITE_HEAD(ring, val) I915_WRITE(RING_HEAD(ring->mmio_base), val) |
Daniel Vetter | 7f2ab69 | 2010-08-02 17:06:59 +0200 | [diff] [blame] | 16 | #define I915_READ_CTL(ring) I915_READ(RING_CTL(ring->mmio_base)) |
| 17 | #define I915_WRITE_CTL(ring, val) I915_WRITE(RING_CTL(ring->mmio_base), val) |
Daniel Vetter | 870e86d | 2010-08-02 16:29:44 +0200 | [diff] [blame] | 18 | |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 19 | struct drm_i915_gem_execbuffer2; |
| 20 | struct intel_ring_buffer { |
| 21 | const char *name; |
Chris Wilson | 9220434 | 2010-09-18 11:02:01 +0100 | [diff] [blame] | 22 | enum intel_ring_id { |
| 23 | RING_RENDER = 0x1, |
| 24 | RING_BSD = 0x2, |
Chris Wilson | 549f736 | 2010-10-19 11:19:32 +0100 | [diff] [blame] | 25 | RING_BLT = 0x4, |
Chris Wilson | 9220434 | 2010-09-18 11:02:01 +0100 | [diff] [blame] | 26 | } id; |
Daniel Vetter | 333e9fe | 2010-08-02 16:24:01 +0200 | [diff] [blame] | 27 | u32 mmio_base; |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 28 | unsigned long size; |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 29 | void *virtual_start; |
| 30 | struct drm_device *dev; |
| 31 | struct drm_gem_object *gem_object; |
| 32 | |
| 33 | unsigned int head; |
| 34 | unsigned int tail; |
Chris Wilson | 780f0ca | 2010-09-23 17:45:39 +0100 | [diff] [blame] | 35 | int space; |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 36 | struct intel_hw_status_page status_page; |
| 37 | |
| 38 | u32 irq_gem_seqno; /* last seq seem at irq time */ |
| 39 | u32 waiting_gem_seqno; |
| 40 | int user_irq_refcount; |
Chris Wilson | 78501ea | 2010-10-27 12:18:21 +0100 | [diff] [blame] | 41 | void (*user_irq_get)(struct intel_ring_buffer *ring); |
| 42 | void (*user_irq_put)(struct intel_ring_buffer *ring); |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 43 | |
Chris Wilson | 78501ea | 2010-10-27 12:18:21 +0100 | [diff] [blame] | 44 | int (*init)(struct intel_ring_buffer *ring); |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 45 | |
Chris Wilson | 78501ea | 2010-10-27 12:18:21 +0100 | [diff] [blame] | 46 | void (*write_tail)(struct intel_ring_buffer *ring, |
Chris Wilson | 297b0c5 | 2010-10-22 17:02:41 +0100 | [diff] [blame] | 47 | u32 value); |
Chris Wilson | 78501ea | 2010-10-27 12:18:21 +0100 | [diff] [blame] | 48 | void (*flush)(struct intel_ring_buffer *ring, |
| 49 | u32 invalidate_domains, |
| 50 | u32 flush_domains); |
| 51 | u32 (*add_request)(struct intel_ring_buffer *ring, |
| 52 | u32 flush_domains); |
| 53 | u32 (*get_seqno)(struct intel_ring_buffer *ring); |
| 54 | int (*dispatch_execbuffer)(struct intel_ring_buffer *ring, |
| 55 | struct drm_i915_gem_execbuffer2 *exec, |
| 56 | struct drm_clip_rect *cliprects, |
| 57 | uint64_t exec_offset); |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 58 | |
| 59 | /** |
| 60 | * List of objects currently involved in rendering from the |
| 61 | * ringbuffer. |
| 62 | * |
| 63 | * Includes buffers having the contents of their GPU caches |
| 64 | * flushed, not necessarily primitives. last_rendering_seqno |
| 65 | * represents when the rendering involved will be completed. |
| 66 | * |
| 67 | * A reference is held on the buffer while on this list. |
| 68 | */ |
| 69 | struct list_head active_list; |
| 70 | |
| 71 | /** |
| 72 | * List of breadcrumbs associated with GPU requests currently |
| 73 | * outstanding. |
| 74 | */ |
| 75 | struct list_head request_list; |
| 76 | |
Chris Wilson | a56ba56 | 2010-09-28 10:07:56 +0100 | [diff] [blame] | 77 | /** |
Chris Wilson | 6419340 | 2010-10-24 12:38:05 +0100 | [diff] [blame] | 78 | * List of objects currently pending a GPU write flush. |
| 79 | * |
| 80 | * All elements on this list will belong to either the |
| 81 | * active_list or flushing_list, last_rendering_seqno can |
| 82 | * be used to differentiate between the two elements. |
| 83 | */ |
| 84 | struct list_head gpu_write_list; |
| 85 | |
| 86 | /** |
Chris Wilson | a56ba56 | 2010-09-28 10:07:56 +0100 | [diff] [blame] | 87 | * Do we have some not yet emitted requests outstanding? |
| 88 | */ |
| 89 | bool outstanding_lazy_request; |
| 90 | |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 91 | wait_queue_head_t irq_queue; |
| 92 | drm_local_map_t map; |
| 93 | }; |
| 94 | |
| 95 | static inline u32 |
| 96 | intel_read_status_page(struct intel_ring_buffer *ring, |
Chris Wilson | 78501ea | 2010-10-27 12:18:21 +0100 | [diff] [blame] | 97 | int reg) |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 98 | { |
Chris Wilson | 78501ea | 2010-10-27 12:18:21 +0100 | [diff] [blame] | 99 | return ioread32(ring->status_page.page_addr + reg); |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 100 | } |
| 101 | |
Chris Wilson | 78501ea | 2010-10-27 12:18:21 +0100 | [diff] [blame] | 102 | void intel_cleanup_ring_buffer(struct intel_ring_buffer *ring); |
Chris Wilson | e1f99ce | 2010-10-27 12:45:26 +0100 | [diff] [blame^] | 103 | int __must_check intel_wait_ring_buffer(struct intel_ring_buffer *ring, int n); |
| 104 | int __must_check intel_ring_begin(struct intel_ring_buffer *ring, int n); |
Chris Wilson | e898cd2 | 2010-08-04 15:18:14 +0100 | [diff] [blame] | 105 | |
Chris Wilson | 78501ea | 2010-10-27 12:18:21 +0100 | [diff] [blame] | 106 | static inline void intel_ring_emit(struct intel_ring_buffer *ring, |
| 107 | u32 data) |
Chris Wilson | e898cd2 | 2010-08-04 15:18:14 +0100 | [diff] [blame] | 108 | { |
Chris Wilson | 78501ea | 2010-10-27 12:18:21 +0100 | [diff] [blame] | 109 | iowrite32(data, ring->virtual_start + ring->tail); |
Chris Wilson | e898cd2 | 2010-08-04 15:18:14 +0100 | [diff] [blame] | 110 | ring->tail += 4; |
| 111 | } |
| 112 | |
Chris Wilson | 78501ea | 2010-10-27 12:18:21 +0100 | [diff] [blame] | 113 | void intel_ring_advance(struct intel_ring_buffer *ring); |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 114 | |
Chris Wilson | 78501ea | 2010-10-27 12:18:21 +0100 | [diff] [blame] | 115 | u32 intel_ring_get_seqno(struct intel_ring_buffer *ring); |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 116 | |
Xiang, Haihao | 5c1143b | 2010-09-16 10:43:11 +0800 | [diff] [blame] | 117 | int intel_init_render_ring_buffer(struct drm_device *dev); |
| 118 | int intel_init_bsd_ring_buffer(struct drm_device *dev); |
Chris Wilson | 549f736 | 2010-10-19 11:19:32 +0100 | [diff] [blame] | 119 | int intel_init_blt_ring_buffer(struct drm_device *dev); |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 120 | |
Chris Wilson | 78501ea | 2010-10-27 12:18:21 +0100 | [diff] [blame] | 121 | u32 intel_ring_get_active_head(struct intel_ring_buffer *ring); |
| 122 | void intel_ring_setup_status_page(struct intel_ring_buffer *ring); |
Daniel Vetter | 79f321b | 2010-09-24 21:20:10 +0200 | [diff] [blame] | 123 | |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 124 | #endif /* _INTEL_RINGBUFFER_H_ */ |