[09/13] drm/i915: Compact Gen8 semaphore initialization
diff mbox

Message ID 1467036260-9252-10-git-send-email-tvrtko.ursulin@linux.intel.com
State New
Headers show

Commit Message

Tvrtko Ursulin June 27, 2016, 2:04 p.m. UTC
From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Replace the macro initializer with a programatic loop which
results in smaller code and hopefully just as clear.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 drivers/gpu/drm/i915/intel_ringbuffer.c | 16 +++++++++++++++-
 drivers/gpu/drm/i915/intel_ringbuffer.h | 12 ------------
 2 files changed, 15 insertions(+), 13 deletions(-)

Comments

Chris Wilson June 28, 2016, 12:05 p.m. UTC | #1
On Mon, Jun 27, 2016 at 03:04:16PM +0100, Tvrtko Ursulin wrote:
> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> 
> Replace the macro initializer with a programatic loop which
> results in smaller code and hopefully just as clear.
> 
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> ---
>  drivers/gpu/drm/i915/intel_ringbuffer.c | 16 +++++++++++++++-
>  drivers/gpu/drm/i915/intel_ringbuffer.h | 12 ------------
>  2 files changed, 15 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
> index 691f82199d3c..088d75397d1b 100644
> --- a/drivers/gpu/drm/i915/intel_ringbuffer.c
> +++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
> @@ -2876,13 +2876,27 @@ static int gen6_ring_flush(struct drm_i915_gem_request *req,
>  static void intel_ring_init_semaphores(struct drm_i915_private *dev_priv,
>  				       struct intel_engine_cs *engine)
>  {
> +	int i;
> +
>  	if (!i915_semaphore_is_enabled(dev_priv))
>  		return;
>  
>  	if (INTEL_GEN(dev_priv) >= 8) {
>  		engine->semaphore.sync_to = gen8_ring_sync;
>  		engine->semaphore.signal = gen8_xcs_signal;
> -		GEN8_RING_SEMAPHORE_INIT(engine);
> +
> +		if (dev_priv->semaphore_obj) {

Something is broken if we reach here without semaphore_obj and
semaphores enabled.

Hmm. Currently we create the semaphore_obj before creating initialising
the semaphore vfuncs on the render ring. Don't you need to do the same
here?

intel_ring_init_seamphores() {
	if (!semaphores_is_enabled(dev_priv))
		return;
	
	if (INTEL_GEN(dev_priv) >= 8 && !dev_priv->semaphore_obj) {
		semaphore_obj = i915_gem_object_create()
		if (!semaphore_obj)
			i915.enable_semaphores = 0;
		return;
	}

	if (INTEL_GEN(dev_priv) >= 8) {
	} else { /* semaphores_is_enabled() should not be true for < 6 */
	}
-Chris

Patch
diff mbox

diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index 691f82199d3c..088d75397d1b 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -2876,13 +2876,27 @@  static int gen6_ring_flush(struct drm_i915_gem_request *req,
 static void intel_ring_init_semaphores(struct drm_i915_private *dev_priv,
 				       struct intel_engine_cs *engine)
 {
+	int i;
+
 	if (!i915_semaphore_is_enabled(dev_priv))
 		return;
 
 	if (INTEL_GEN(dev_priv) >= 8) {
 		engine->semaphore.sync_to = gen8_ring_sync;
 		engine->semaphore.signal = gen8_xcs_signal;
-		GEN8_RING_SEMAPHORE_INIT(engine);
+
+		if (dev_priv->semaphore_obj) {
+			u64 offset = i915_gem_obj_ggtt_offset(dev_priv->semaphore_obj);
+
+			for (i = 0; i < I915_NUM_ENGINES; i++) {
+				u64 ring_offset = MI_SEMAPHORE_SYNC_INVALID;
+
+				if (i != engine->id)
+					ring_offset = offset + GEN8_SEMAPHORE_OFFSET(engine->id, i);
+
+				engine->semaphore.signal_ggtt[i] = ring_offset;
+			}
+		}
 	} else if (INTEL_GEN(dev_priv) >= 6) {
 		engine->semaphore.sync_to = gen6_ring_sync;
 		engine->semaphore.signal = gen6_signal;
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h
index b33c876fed20..113d5230a6de 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.h
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.h
@@ -62,18 +62,6 @@  struct  intel_hw_status_page {
 	(i915_gem_obj_ggtt_offset(dev_priv->semaphore_obj) + \
 	 GEN8_SEMAPHORE_OFFSET(from, (__ring)->id))
 
-#define GEN8_RING_SEMAPHORE_INIT(e) do { \
-	if (!dev_priv->semaphore_obj) { \
-		break; \
-	} \
-	(e)->semaphore.signal_ggtt[RCS] = GEN8_SIGNAL_OFFSET((e), RCS); \
-	(e)->semaphore.signal_ggtt[VCS] = GEN8_SIGNAL_OFFSET((e), VCS); \
-	(e)->semaphore.signal_ggtt[BCS] = GEN8_SIGNAL_OFFSET((e), BCS); \
-	(e)->semaphore.signal_ggtt[VECS] = GEN8_SIGNAL_OFFSET((e), VECS); \
-	(e)->semaphore.signal_ggtt[VCS2] = GEN8_SIGNAL_OFFSET((e), VCS2); \
-	(e)->semaphore.signal_ggtt[(e)->id] = MI_SEMAPHORE_SYNC_INVALID; \
-	} while(0)
-
 enum intel_ring_hangcheck_action {
 	HANGCHECK_IDLE = 0,
 	HANGCHECK_WAIT,