diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2014-04-09 04:19:40 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2014-05-05 03:08:36 -0400 |
commit | 18393f6322ce523efa767e7ed9bd64fe0645e458 (patch) | |
tree | e7b6975c25580d25a3729c04218826f0feb96457 /drivers/gpu/drm/i915/intel_ringbuffer.c | |
parent | 93c9c19b3d259a76fc2efa4b8f2478dc9f339bee (diff) |
drm/i915: Replace hardcoded cacheline size with macro
For readibility and guess at the meaning behind the constants.
v2: Claim only the meagerest connections with reality.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Oscar Mateo <oscar.mateo@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/i915/intel_ringbuffer.c')
-rw-r--r-- | drivers/gpu/drm/i915/intel_ringbuffer.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c index eb3dd26b94de..890e0986edbe 100644 --- a/drivers/gpu/drm/i915/intel_ringbuffer.c +++ b/drivers/gpu/drm/i915/intel_ringbuffer.c | |||
@@ -33,6 +33,13 @@ | |||
33 | #include "i915_trace.h" | 33 | #include "i915_trace.h" |
34 | #include "intel_drv.h" | 34 | #include "intel_drv.h" |
35 | 35 | ||
36 | /* Early gen2 devices have a cacheline of just 32 bytes, using 64 is overkill, | ||
37 | * but keeps the logic simple. Indeed, the whole purpose of this macro is just | ||
38 | * to give some inclination as to some of the magic values used in the various | ||
39 | * workarounds! | ||
40 | */ | ||
41 | #define CACHELINE_BYTES 64 | ||
42 | |||
36 | static inline int ring_space(struct intel_ring_buffer *ring) | 43 | static inline int ring_space(struct intel_ring_buffer *ring) |
37 | { | 44 | { |
38 | int space = (ring->head & HEAD_ADDR) - (ring->tail + I915_RING_FREE_SPACE); | 45 | int space = (ring->head & HEAD_ADDR) - (ring->tail + I915_RING_FREE_SPACE); |
@@ -179,7 +186,7 @@ gen4_render_ring_flush(struct intel_ring_buffer *ring, | |||
179 | static int | 186 | static int |
180 | intel_emit_post_sync_nonzero_flush(struct intel_ring_buffer *ring) | 187 | intel_emit_post_sync_nonzero_flush(struct intel_ring_buffer *ring) |
181 | { | 188 | { |
182 | u32 scratch_addr = ring->scratch.gtt_offset + 128; | 189 | u32 scratch_addr = ring->scratch.gtt_offset + 2 * CACHELINE_BYTES; |
183 | int ret; | 190 | int ret; |
184 | 191 | ||
185 | 192 | ||
@@ -216,7 +223,7 @@ gen6_render_ring_flush(struct intel_ring_buffer *ring, | |||
216 | u32 invalidate_domains, u32 flush_domains) | 223 | u32 invalidate_domains, u32 flush_domains) |
217 | { | 224 | { |
218 | u32 flags = 0; | 225 | u32 flags = 0; |
219 | u32 scratch_addr = ring->scratch.gtt_offset + 128; | 226 | u32 scratch_addr = ring->scratch.gtt_offset + 2 * CACHELINE_BYTES; |
220 | int ret; | 227 | int ret; |
221 | 228 | ||
222 | /* Force SNB workarounds for PIPE_CONTROL flushes */ | 229 | /* Force SNB workarounds for PIPE_CONTROL flushes */ |
@@ -310,7 +317,7 @@ gen7_render_ring_flush(struct intel_ring_buffer *ring, | |||
310 | u32 invalidate_domains, u32 flush_domains) | 317 | u32 invalidate_domains, u32 flush_domains) |
311 | { | 318 | { |
312 | u32 flags = 0; | 319 | u32 flags = 0; |
313 | u32 scratch_addr = ring->scratch.gtt_offset + 128; | 320 | u32 scratch_addr = ring->scratch.gtt_offset + 2 * CACHELINE_BYTES; |
314 | int ret; | 321 | int ret; |
315 | 322 | ||
316 | /* | 323 | /* |
@@ -371,7 +378,7 @@ gen8_render_ring_flush(struct intel_ring_buffer *ring, | |||
371 | u32 invalidate_domains, u32 flush_domains) | 378 | u32 invalidate_domains, u32 flush_domains) |
372 | { | 379 | { |
373 | u32 flags = 0; | 380 | u32 flags = 0; |
374 | u32 scratch_addr = ring->scratch.gtt_offset + 128; | 381 | u32 scratch_addr = ring->scratch.gtt_offset + 2 * CACHELINE_BYTES; |
375 | int ret; | 382 | int ret; |
376 | 383 | ||
377 | flags |= PIPE_CONTROL_CS_STALL; | 384 | flags |= PIPE_CONTROL_CS_STALL; |
@@ -783,7 +790,7 @@ do { \ | |||
783 | static int | 790 | static int |
784 | pc_render_add_request(struct intel_ring_buffer *ring) | 791 | pc_render_add_request(struct intel_ring_buffer *ring) |
785 | { | 792 | { |
786 | u32 scratch_addr = ring->scratch.gtt_offset + 128; | 793 | u32 scratch_addr = ring->scratch.gtt_offset + 2 * CACHELINE_BYTES; |
787 | int ret; | 794 | int ret; |
788 | 795 | ||
789 | /* For Ironlake, MI_USER_INTERRUPT was deprecated and apparently | 796 | /* For Ironlake, MI_USER_INTERRUPT was deprecated and apparently |
@@ -805,15 +812,15 @@ pc_render_add_request(struct intel_ring_buffer *ring) | |||
805 | intel_ring_emit(ring, ring->outstanding_lazy_seqno); | 812 | intel_ring_emit(ring, ring->outstanding_lazy_seqno); |
806 | intel_ring_emit(ring, 0); | 813 | intel_ring_emit(ring, 0); |
807 | PIPE_CONTROL_FLUSH(ring, scratch_addr); | 814 | PIPE_CONTROL_FLUSH(ring, scratch_addr); |
808 | scratch_addr += 128; /* write to separate cachelines */ | 815 | scratch_addr += 2 * CACHELINE_BYTES; /* write to separate cachelines */ |
809 | PIPE_CONTROL_FLUSH(ring, scratch_addr); | 816 | PIPE_CONTROL_FLUSH(ring, scratch_addr); |
810 | scratch_addr += 128; | 817 | scratch_addr += 2 * CACHELINE_BYTES; |
811 | PIPE_CONTROL_FLUSH(ring, scratch_addr); | 818 | PIPE_CONTROL_FLUSH(ring, scratch_addr); |
812 | scratch_addr += 128; | 819 | scratch_addr += 2 * CACHELINE_BYTES; |
813 | PIPE_CONTROL_FLUSH(ring, scratch_addr); | 820 | PIPE_CONTROL_FLUSH(ring, scratch_addr); |
814 | scratch_addr += 128; | 821 | scratch_addr += 2 * CACHELINE_BYTES; |
815 | PIPE_CONTROL_FLUSH(ring, scratch_addr); | 822 | PIPE_CONTROL_FLUSH(ring, scratch_addr); |
816 | scratch_addr += 128; | 823 | scratch_addr += 2 * CACHELINE_BYTES; |
817 | PIPE_CONTROL_FLUSH(ring, scratch_addr); | 824 | PIPE_CONTROL_FLUSH(ring, scratch_addr); |
818 | 825 | ||
819 | intel_ring_emit(ring, GFX_OP_PIPE_CONTROL(4) | PIPE_CONTROL_QW_WRITE | | 826 | intel_ring_emit(ring, GFX_OP_PIPE_CONTROL(4) | PIPE_CONTROL_QW_WRITE | |
@@ -1422,7 +1429,7 @@ static int intel_init_ring_buffer(struct drm_device *dev, | |||
1422 | */ | 1429 | */ |
1423 | ring->effective_size = ring->size; | 1430 | ring->effective_size = ring->size; |
1424 | if (IS_I830(ring->dev) || IS_845G(ring->dev)) | 1431 | if (IS_I830(ring->dev) || IS_845G(ring->dev)) |
1425 | ring->effective_size -= 128; | 1432 | ring->effective_size -= 2 * CACHELINE_BYTES; |
1426 | 1433 | ||
1427 | i915_cmd_parser_init_ring(ring); | 1434 | i915_cmd_parser_init_ring(ring); |
1428 | 1435 | ||
@@ -1683,12 +1690,13 @@ int intel_ring_begin(struct intel_ring_buffer *ring, | |||
1683 | /* Align the ring tail to a cacheline boundary */ | 1690 | /* Align the ring tail to a cacheline boundary */ |
1684 | int intel_ring_cacheline_align(struct intel_ring_buffer *ring) | 1691 | int intel_ring_cacheline_align(struct intel_ring_buffer *ring) |
1685 | { | 1692 | { |
1686 | int num_dwords = (64 - (ring->tail & 63)) / sizeof(uint32_t); | 1693 | int num_dwords = (ring->tail & (CACHELINE_BYTES - 1)) / sizeof(uint32_t); |
1687 | int ret; | 1694 | int ret; |
1688 | 1695 | ||
1689 | if (num_dwords == 0) | 1696 | if (num_dwords == 0) |
1690 | return 0; | 1697 | return 0; |
1691 | 1698 | ||
1699 | num_dwords = CACHELINE_BYTES / sizeof(uint32_t) - num_dwords; | ||
1692 | ret = intel_ring_begin(ring, num_dwords); | 1700 | ret = intel_ring_begin(ring, num_dwords); |
1693 | if (ret) | 1701 | if (ret) |
1694 | return ret; | 1702 | return ret; |
@@ -2045,7 +2053,7 @@ int intel_render_ring_init_dri(struct drm_device *dev, u64 start, u32 size) | |||
2045 | ring->size = size; | 2053 | ring->size = size; |
2046 | ring->effective_size = ring->size; | 2054 | ring->effective_size = ring->size; |
2047 | if (IS_I830(ring->dev) || IS_845G(ring->dev)) | 2055 | if (IS_I830(ring->dev) || IS_845G(ring->dev)) |
2048 | ring->effective_size -= 128; | 2056 | ring->effective_size -= 2 * CACHELINE_BYTES; |
2049 | 2057 | ||
2050 | ring->virtual_start = ioremap_wc(start, size); | 2058 | ring->virtual_start = ioremap_wc(start, size); |
2051 | if (ring->virtual_start == NULL) { | 2059 | if (ring->virtual_start == NULL) { |