diff options
Diffstat (limited to 'drivers/gpu/drm/i915/intel_ringbuffer.h')
-rw-r--r-- | drivers/gpu/drm/i915/intel_ringbuffer.h | 151 |
1 files changed, 86 insertions, 65 deletions
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h index d2cd0f1efeed..5b0abfa881fc 100644 --- a/drivers/gpu/drm/i915/intel_ringbuffer.h +++ b/drivers/gpu/drm/i915/intel_ringbuffer.h | |||
@@ -1,22 +1,40 @@ | |||
1 | #ifndef _INTEL_RINGBUFFER_H_ | 1 | #ifndef _INTEL_RINGBUFFER_H_ |
2 | #define _INTEL_RINGBUFFER_H_ | 2 | #define _INTEL_RINGBUFFER_H_ |
3 | 3 | ||
4 | enum { | ||
5 | RCS = 0x0, | ||
6 | VCS, | ||
7 | BCS, | ||
8 | I915_NUM_RINGS, | ||
9 | }; | ||
10 | |||
4 | struct intel_hw_status_page { | 11 | struct intel_hw_status_page { |
5 | void *page_addr; | 12 | u32 __iomem *page_addr; |
6 | unsigned int gfx_addr; | 13 | unsigned int gfx_addr; |
7 | struct drm_gem_object *obj; | 14 | struct drm_i915_gem_object *obj; |
8 | }; | 15 | }; |
9 | 16 | ||
10 | #define I915_READ_TAIL(ring) I915_READ(RING_TAIL(ring->mmio_base)) | 17 | #define I915_RING_READ(reg) i915_safe_read(dev_priv, reg) |
11 | #define I915_WRITE_TAIL(ring, val) I915_WRITE(RING_TAIL(ring->mmio_base), val) | 18 | |
12 | #define I915_READ_START(ring) I915_READ(RING_START(ring->mmio_base)) | 19 | #define I915_READ_TAIL(ring) I915_RING_READ(RING_TAIL((ring)->mmio_base)) |
13 | #define I915_WRITE_START(ring, val) I915_WRITE(RING_START(ring->mmio_base), val) | 20 | #define I915_WRITE_TAIL(ring, val) I915_WRITE(RING_TAIL((ring)->mmio_base), val) |
14 | #define I915_READ_HEAD(ring) I915_READ(RING_HEAD(ring->mmio_base)) | 21 | |
15 | #define I915_WRITE_HEAD(ring, val) I915_WRITE(RING_HEAD(ring->mmio_base), val) | 22 | #define I915_READ_START(ring) I915_RING_READ(RING_START((ring)->mmio_base)) |
16 | #define I915_READ_CTL(ring) I915_READ(RING_CTL(ring->mmio_base)) | 23 | #define I915_WRITE_START(ring, val) I915_WRITE(RING_START((ring)->mmio_base), val) |
17 | #define I915_WRITE_CTL(ring, val) I915_WRITE(RING_CTL(ring->mmio_base), val) | 24 | |
25 | #define I915_READ_HEAD(ring) I915_RING_READ(RING_HEAD((ring)->mmio_base)) | ||
26 | #define I915_WRITE_HEAD(ring, val) I915_WRITE(RING_HEAD((ring)->mmio_base), val) | ||
27 | |||
28 | #define I915_READ_CTL(ring) I915_RING_READ(RING_CTL((ring)->mmio_base)) | ||
29 | #define I915_WRITE_CTL(ring, val) I915_WRITE(RING_CTL((ring)->mmio_base), val) | ||
30 | |||
31 | #define I915_WRITE_IMR(ring, val) I915_WRITE(RING_IMR((ring)->mmio_base), val) | ||
32 | #define I915_READ_IMR(ring) I915_RING_READ(RING_IMR((ring)->mmio_base)) | ||
33 | |||
34 | #define I915_READ_NOPID(ring) I915_RING_READ(RING_NOPID((ring)->mmio_base)) | ||
35 | #define I915_READ_SYNC_0(ring) I915_RING_READ(RING_SYNC_0((ring)->mmio_base)) | ||
36 | #define I915_READ_SYNC_1(ring) I915_RING_READ(RING_SYNC_1((ring)->mmio_base)) | ||
18 | 37 | ||
19 | struct drm_i915_gem_execbuffer2; | ||
20 | struct intel_ring_buffer { | 38 | struct intel_ring_buffer { |
21 | const char *name; | 39 | const char *name; |
22 | enum intel_ring_id { | 40 | enum intel_ring_id { |
@@ -25,45 +43,38 @@ struct intel_ring_buffer { | |||
25 | RING_BLT = 0x4, | 43 | RING_BLT = 0x4, |
26 | } id; | 44 | } id; |
27 | u32 mmio_base; | 45 | u32 mmio_base; |
28 | unsigned long size; | ||
29 | void *virtual_start; | 46 | void *virtual_start; |
30 | struct drm_device *dev; | 47 | struct drm_device *dev; |
31 | struct drm_gem_object *gem_object; | 48 | struct drm_i915_gem_object *obj; |
32 | 49 | ||
33 | u32 actual_head; | ||
34 | u32 head; | 50 | u32 head; |
35 | u32 tail; | 51 | u32 tail; |
36 | int space; | 52 | int space; |
53 | int size; | ||
54 | int effective_size; | ||
37 | struct intel_hw_status_page status_page; | 55 | struct intel_hw_status_page status_page; |
38 | 56 | ||
39 | u32 irq_gem_seqno; /* last seq seem at irq time */ | 57 | spinlock_t irq_lock; |
40 | u32 waiting_gem_seqno; | 58 | u32 irq_refcount; |
41 | int user_irq_refcount; | 59 | u32 irq_mask; |
42 | void (*user_irq_get)(struct drm_device *dev, | 60 | u32 irq_seqno; /* last seq seem at irq time */ |
43 | struct intel_ring_buffer *ring); | 61 | u32 waiting_seqno; |
44 | void (*user_irq_put)(struct drm_device *dev, | 62 | u32 sync_seqno[I915_NUM_RINGS-1]; |
45 | struct intel_ring_buffer *ring); | 63 | bool __must_check (*irq_get)(struct intel_ring_buffer *ring); |
64 | void (*irq_put)(struct intel_ring_buffer *ring); | ||
46 | 65 | ||
47 | int (*init)(struct drm_device *dev, | 66 | int (*init)(struct intel_ring_buffer *ring); |
48 | struct intel_ring_buffer *ring); | ||
49 | 67 | ||
50 | void (*write_tail)(struct drm_device *dev, | 68 | void (*write_tail)(struct intel_ring_buffer *ring, |
51 | struct intel_ring_buffer *ring, | ||
52 | u32 value); | 69 | u32 value); |
53 | void (*flush)(struct drm_device *dev, | 70 | int __must_check (*flush)(struct intel_ring_buffer *ring, |
54 | struct intel_ring_buffer *ring, | 71 | u32 invalidate_domains, |
55 | u32 invalidate_domains, | 72 | u32 flush_domains); |
56 | u32 flush_domains); | 73 | int (*add_request)(struct intel_ring_buffer *ring, |
57 | u32 (*add_request)(struct drm_device *dev, | 74 | u32 *seqno); |
58 | struct intel_ring_buffer *ring, | 75 | u32 (*get_seqno)(struct intel_ring_buffer *ring); |
59 | u32 flush_domains); | 76 | int (*dispatch_execbuffer)(struct intel_ring_buffer *ring, |
60 | u32 (*get_seqno)(struct drm_device *dev, | 77 | u32 offset, u32 length); |
61 | struct intel_ring_buffer *ring); | ||
62 | int (*dispatch_gem_execbuffer)(struct drm_device *dev, | ||
63 | struct intel_ring_buffer *ring, | ||
64 | struct drm_i915_gem_execbuffer2 *exec, | ||
65 | struct drm_clip_rect *cliprects, | ||
66 | uint64_t exec_offset); | ||
67 | void (*cleanup)(struct intel_ring_buffer *ring); | 78 | void (*cleanup)(struct intel_ring_buffer *ring); |
68 | 79 | ||
69 | /** | 80 | /** |
@@ -96,7 +107,7 @@ struct intel_ring_buffer { | |||
96 | /** | 107 | /** |
97 | * Do we have some not yet emitted requests outstanding? | 108 | * Do we have some not yet emitted requests outstanding? |
98 | */ | 109 | */ |
99 | bool outstanding_lazy_request; | 110 | u32 outstanding_lazy_request; |
100 | 111 | ||
101 | wait_queue_head_t irq_queue; | 112 | wait_queue_head_t irq_queue; |
102 | drm_local_map_t map; | 113 | drm_local_map_t map; |
@@ -105,44 +116,54 @@ struct intel_ring_buffer { | |||
105 | }; | 116 | }; |
106 | 117 | ||
107 | static inline u32 | 118 | static inline u32 |
119 | intel_ring_sync_index(struct intel_ring_buffer *ring, | ||
120 | struct intel_ring_buffer *other) | ||
121 | { | ||
122 | int idx; | ||
123 | |||
124 | /* | ||
125 | * cs -> 0 = vcs, 1 = bcs | ||
126 | * vcs -> 0 = bcs, 1 = cs, | ||
127 | * bcs -> 0 = cs, 1 = vcs. | ||
128 | */ | ||
129 | |||
130 | idx = (other - ring) - 1; | ||
131 | if (idx < 0) | ||
132 | idx += I915_NUM_RINGS; | ||
133 | |||
134 | return idx; | ||
135 | } | ||
136 | |||
137 | static inline u32 | ||
108 | intel_read_status_page(struct intel_ring_buffer *ring, | 138 | intel_read_status_page(struct intel_ring_buffer *ring, |
109 | int reg) | 139 | int reg) |
110 | { | 140 | { |
111 | u32 *regs = ring->status_page.page_addr; | 141 | return ioread32(ring->status_page.page_addr + reg); |
112 | return regs[reg]; | ||
113 | } | 142 | } |
114 | 143 | ||
115 | int intel_init_ring_buffer(struct drm_device *dev, | 144 | void intel_cleanup_ring_buffer(struct intel_ring_buffer *ring); |
116 | struct intel_ring_buffer *ring); | 145 | int __must_check intel_wait_ring_buffer(struct intel_ring_buffer *ring, int n); |
117 | void intel_cleanup_ring_buffer(struct drm_device *dev, | 146 | int __must_check intel_ring_begin(struct intel_ring_buffer *ring, int n); |
118 | struct intel_ring_buffer *ring); | 147 | |
119 | int intel_wait_ring_buffer(struct drm_device *dev, | 148 | static inline void intel_ring_emit(struct intel_ring_buffer *ring, |
120 | struct intel_ring_buffer *ring, int n); | 149 | u32 data) |
121 | void intel_ring_begin(struct drm_device *dev, | ||
122 | struct intel_ring_buffer *ring, int n); | ||
123 | |||
124 | static inline void intel_ring_emit(struct drm_device *dev, | ||
125 | struct intel_ring_buffer *ring, | ||
126 | unsigned int data) | ||
127 | { | 150 | { |
128 | unsigned int *virt = ring->virtual_start + ring->tail; | 151 | iowrite32(data, ring->virtual_start + ring->tail); |
129 | *virt = data; | ||
130 | ring->tail += 4; | 152 | ring->tail += 4; |
131 | } | 153 | } |
132 | 154 | ||
133 | void intel_ring_advance(struct drm_device *dev, | 155 | void intel_ring_advance(struct intel_ring_buffer *ring); |
134 | struct intel_ring_buffer *ring); | ||
135 | 156 | ||
136 | u32 intel_ring_get_seqno(struct drm_device *dev, | 157 | u32 intel_ring_get_seqno(struct intel_ring_buffer *ring); |
137 | struct intel_ring_buffer *ring); | 158 | int intel_ring_sync(struct intel_ring_buffer *ring, |
159 | struct intel_ring_buffer *to, | ||
160 | u32 seqno); | ||
138 | 161 | ||
139 | int intel_init_render_ring_buffer(struct drm_device *dev); | 162 | int intel_init_render_ring_buffer(struct drm_device *dev); |
140 | int intel_init_bsd_ring_buffer(struct drm_device *dev); | 163 | int intel_init_bsd_ring_buffer(struct drm_device *dev); |
141 | int intel_init_blt_ring_buffer(struct drm_device *dev); | 164 | int intel_init_blt_ring_buffer(struct drm_device *dev); |
142 | 165 | ||
143 | u32 intel_ring_get_active_head(struct drm_device *dev, | 166 | u32 intel_ring_get_active_head(struct intel_ring_buffer *ring); |
144 | struct intel_ring_buffer *ring); | 167 | void intel_ring_setup_status_page(struct intel_ring_buffer *ring); |
145 | void intel_ring_setup_status_page(struct drm_device *dev, | ||
146 | struct intel_ring_buffer *ring); | ||
147 | 168 | ||
148 | #endif /* _INTEL_RINGBUFFER_H_ */ | 169 | #endif /* _INTEL_RINGBUFFER_H_ */ |