Re: [PATCH 2/5] drm/i915: Allow asynchronous waits on the i915_active barriers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 06/04/2020 10:12, Chris Wilson wrote:
Allow the caller to also wait upon the barriers stored in i915_active.

Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
---
  drivers/gpu/drm/i915/i915_active.c | 60 ++++++++++++++++++++++++++++++
  drivers/gpu/drm/i915/i915_active.h |  1 +
  2 files changed, 61 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_active.c b/drivers/gpu/drm/i915/i915_active.c
index d5e24be759f7..048ab9edd2c2 100644
--- a/drivers/gpu/drm/i915/i915_active.c
+++ b/drivers/gpu/drm/i915/i915_active.c
@@ -542,6 +542,55 @@ static int __await_active(struct i915_active_fence *active,
  	return 0;
  }
+struct wait_barrier {
+	struct wait_queue_entry base;
+	struct i915_active *ref;
+};
+
+static int
+barrier_wake(wait_queue_entry_t *wq, unsigned int mode, int flags, void *key)
+{
+	struct wait_barrier *wb = container_of(wq, typeof(*wb), base);
+
+	if (i915_active_is_idle(wb->ref)) { /* shared waitqueue, must check! */

Who shares it?

+		list_del(&wq->entry);
+		i915_sw_fence_complete(wq->private);
+		kfree(wq);
+	}
+
+	return 0;
+}
+
+static int __await_barrier(struct i915_active *ref, struct i915_sw_fence *fence)
+{
+	struct wait_barrier *wb;
+
+	wb = kmalloc(sizeof(*wb), GFP_KERNEL);
+	if (unlikely(!wb))
+		return -ENOMEM;
+
+	if (!i915_active_acquire_if_busy(ref)) {
+		kfree(wb);
+		return 0;
+	}
+
+	if (!i915_sw_fence_await(fence)) {
+		kfree(wb);
+		i915_active_release(ref);
+		return -EINVAL;
+	}
+
+	wb->base.flags = 0;
+	wb->base.func = barrier_wake;
+	wb->base.private = fence;
+	wb->ref = ref;
+
+	add_wait_queue(__var_waitqueue(ref), &wb->base);
+
+	i915_active_release(ref);
+	return 0;
+}
+
  static int await_active(struct i915_active *ref,
  			unsigned int flags,
  			int (*fn)(void *arg, struct dma_fence *fence),
@@ -570,6 +619,16 @@ static int await_active(struct i915_active *ref,
  			return err;
  	}
+ if (flags & I915_ACTIVE_AWAIT_BARRIER) {
+		err = flush_lazy_signals(ref);
+		if (err)
+			return err;
+
+		err = __await_barrier(ref, arg);
+		if (err)
+			return err;


Could have a single set of active_acquire_if_busy/release over the previous and this new block. Not sure if that would help with any atomicity concerns, or if there are such.

 +	}
+
  	return 0;
  }
@@ -582,6 +641,7 @@ int i915_request_await_active(struct i915_request *rq,
  			      struct i915_active *ref,
  			      unsigned int flags)
  {
+	GEM_BUG_ON(flags & I915_ACTIVE_AWAIT_BARRIER);

Why is this an error?

  	return await_active(ref, flags, rq_await_fence, rq);
  }
diff --git a/drivers/gpu/drm/i915/i915_active.h b/drivers/gpu/drm/i915/i915_active.h
index ffafaa78c494..cf4058150966 100644
--- a/drivers/gpu/drm/i915/i915_active.h
+++ b/drivers/gpu/drm/i915/i915_active.h
@@ -195,6 +195,7 @@ int i915_request_await_active(struct i915_request *rq,
  			      unsigned int flags);
  #define I915_ACTIVE_AWAIT_EXCL BIT(0)
  #define I915_ACTIVE_AWAIT_ACTIVE BIT(1)
+#define I915_ACTIVE_AWAIT_BARRIER BIT(2)
int i915_active_acquire(struct i915_active *ref);
  bool i915_active_acquire_if_busy(struct i915_active *ref);


Regards,

Tvrtko
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx



[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux