diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2014-03-30 00:58:25 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2014-03-30 00:58:25 +0000 |
commit | 1de56eece1a4853bc929ac20737d5f1cb3c0b20f (patch) | |
tree | 679bde55ed768a22a393fd413a7e5ba24ad03c96 /sys | |
parent | b2769aa5008ddf91fc9b71b1bdb1c46b699dde45 (diff) |
drm/i915: Add intel_ring_cachline_align()
From Ville Syrjala
0320c449d2a820ed2a1972e23d8f20f8024a5872 in ubuntu 3.8
753b1ad4a281b0663329409d410243e91825c323 in mainline linux
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/pci/drm/i915/intel_ringbuffer.c | 23 | ||||
-rw-r--r-- | sys/dev/pci/drm/i915/intel_ringbuffer.h | 3 |
2 files changed, 24 insertions, 2 deletions
diff --git a/sys/dev/pci/drm/i915/intel_ringbuffer.c b/sys/dev/pci/drm/i915/intel_ringbuffer.c index 7c70127ea44..57ab540dd18 100644 --- a/sys/dev/pci/drm/i915/intel_ringbuffer.c +++ b/sys/dev/pci/drm/i915/intel_ringbuffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: intel_ringbuffer.c,v 1.19 2014/03/24 17:06:49 kettenis Exp $ */ +/* $OpenBSD: intel_ringbuffer.c,v 1.20 2014/03/30 00:58:24 jsg Exp $ */ /* * Copyright © 2008-2010 Intel Corporation * @@ -1483,6 +1483,27 @@ int intel_ring_begin(struct intel_ring_buffer *ring, 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_advance(struct intel_ring_buffer *ring) { struct drm_i915_private *dev_priv = ring->dev->dev_private; diff --git a/sys/dev/pci/drm/i915/intel_ringbuffer.h b/sys/dev/pci/drm/i915/intel_ringbuffer.h index b73a3c74ae8..6a90d3527cd 100644 --- a/sys/dev/pci/drm/i915/intel_ringbuffer.h +++ b/sys/dev/pci/drm/i915/intel_ringbuffer.h @@ -1,4 +1,4 @@ -/* $OpenBSD: intel_ringbuffer.h,v 1.2 2014/03/24 17:06:49 kettenis Exp $ */ +/* $OpenBSD: intel_ringbuffer.h,v 1.3 2014/03/30 00:58:24 jsg Exp $ */ #ifndef _INTEL_RINGBUFFER_H_ #define _INTEL_RINGBUFFER_H_ @@ -198,6 +198,7 @@ u32 intel_read_status_page(struct intel_ring_buffer *ring, int reg); 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); #ifdef notyet static inline void intel_ring_emit(struct intel_ring_buffer *ring, u32 data) |