| From 753b1ad4a281b0663329409d410243e91825c323 Mon Sep 17 00:00:00 2001 |
| From: Ville Syrjälä <ville.syrjala@linux.intel.com> |
| Date: Tue, 11 Feb 2014 19:52:05 +0200 |
| Subject: drm/i915: Add intel_ring_cachline_align() |
| MIME-Version: 1.0 |
| Content-Type: text/plain; charset=UTF-8 |
| Content-Transfer-Encoding: 8bit |
| |
| From: Ville Syrjälä <ville.syrjala@linux.intel.com> |
| |
| commit 753b1ad4a281b0663329409d410243e91825c323 upstream. |
| |
| intel_ring_cachline_align() emits MI_NOOPs until the ring tail is |
| aligned to a cacheline boundary. |
| |
| Cc: Bjoern C <lkml@call-home.ch> |
| Cc: Alexandru DAMIAN <alexandru.damian@intel.com> |
| Cc: Enrico Tagliavini <enrico.tagliavini@gmail.com> |
| Suggested-by: Chris Wilson <chris@chris-wilson.co.uk> |
| Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> |
| Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> |
| Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> |
| Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
| |
| --- |
| drivers/gpu/drm/i915/intel_ringbuffer.c | 21 +++++++++++++++++++++ |
| drivers/gpu/drm/i915/intel_ringbuffer.h | 1 + |
| 2 files changed, 22 insertions(+) |
| |
| --- a/drivers/gpu/drm/i915/intel_ringbuffer.c |
| +++ b/drivers/gpu/drm/i915/intel_ringbuffer.c |
| @@ -1655,6 +1655,27 @@ int intel_ring_begin(struct intel_ring_b |
| return 0; |
| } |
| |
| +/* Align the ring tail to a cacheline boundary */ |
| +int intel_ring_cacheline_align(struct intel_ring_buffer *ring) |
| +{ |
| + int num_dwords = (64 - (ring->tail & 63)) / sizeof(uint32_t); |
| + int ret; |
| + |
| + if (num_dwords == 0) |
| + return 0; |
| + |
| + ret = intel_ring_begin(ring, num_dwords); |
| + if (ret) |
| + return ret; |
| + |
| + while (num_dwords--) |
| + intel_ring_emit(ring, MI_NOOP); |
| + |
| + intel_ring_advance(ring); |
| + |
| + return 0; |
| +} |
| + |
| void intel_ring_init_seqno(struct intel_ring_buffer *ring, u32 seqno) |
| { |
| struct drm_i915_private *dev_priv = ring->dev->dev_private; |
| --- a/drivers/gpu/drm/i915/intel_ringbuffer.h |
| +++ b/drivers/gpu/drm/i915/intel_ringbuffer.h |
| @@ -233,6 +233,7 @@ intel_write_status_page(struct intel_rin |
| void intel_cleanup_ring_buffer(struct intel_ring_buffer *ring); |
| |
| int __must_check intel_ring_begin(struct intel_ring_buffer *ring, int n); |
| +int __must_check intel_ring_cacheline_align(struct intel_ring_buffer *ring); |
| static inline void intel_ring_emit(struct intel_ring_buffer *ring, |
| u32 data) |
| { |