All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Gmeiner <christian.gmeiner@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: linux+etnaviv@armlinux.org.uk, etnaviv@lists.freedesktop.org,
	cphealy@gmail.com
Subject: [PATCH V4 02/23] drm/etnaviv: make it possible to allocate multiple events
Date: Tue, 12 Sep 2017 17:11:34 +0200	[thread overview]
Message-ID: <20170912151155.4603-3-christian.gmeiner@gmail.com> (raw)
In-Reply-To: <20170912151155.4603-1-christian.gmeiner@gmail.com>

This makes it possible to allocate multiple events under the event
spinlock. This change is needed to support 'sync'-points.

Changes v2 -> v3:
- wait for the completion of all events
- use 10sec timeout regardless of the number of events
- removed validation if there are enough free events
- fixed return value evaluation of event_alloc(..) in etnaviv_gpu_submit(..)

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>

!fixup

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
---
 drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 47 +++++++++++++++++++++++------------
 1 file changed, 31 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
index fa9c7bd98e9c..d3b7e665eca9 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
@@ -1137,28 +1137,44 @@ int etnaviv_gpu_fence_sync_obj(struct etnaviv_gem_object *etnaviv_obj,
  * event management:
  */
 
-static unsigned int event_alloc(struct etnaviv_gpu *gpu)
+static int event_alloc(struct etnaviv_gpu *gpu, unsigned nr_events,
+	unsigned int *events)
 {
-	unsigned long ret, flags;
-	unsigned int event;
+	unsigned long flags, timeout = msecs_to_jiffies(10 * 10000);
+	unsigned i, acquired = 0;
 
-	ret = wait_for_completion_timeout(&gpu->event_free,
-					  msecs_to_jiffies(10 * 10000));
-	if (!ret)
-		dev_err(gpu->dev, "wait_for_completion_timeout failed");
+	for (i = 0; i < nr_events; i++) {
+		unsigned long ret;
+
+		ret = wait_for_completion_timeout(&gpu->event_free, timeout);
+
+		if (!ret) {
+			dev_err(gpu->dev, "wait_for_completion_timeout failed");
+			goto out;
+		}
+
+		acquired++;
+		timeout = ret;
+	}
 
 	spin_lock_irqsave(&gpu->event_spinlock, flags);
 
-	/* find first free event */
-	event = find_first_zero_bit(gpu->event_bitmap, ETNA_NR_EVENTS);
-	if (event < ETNA_NR_EVENTS)
+	for (i = 0; i < nr_events; i++) {
+		int event = find_first_zero_bit(gpu->event_bitmap, ETNA_NR_EVENTS);
+
+		events[i] = event;
 		set_bit(event, gpu->event_bitmap);
-	else
-		event = ~0U;
+	}
 
 	spin_unlock_irqrestore(&gpu->event_spinlock, flags);
 
-	return event;
+	return 0;
+
+out:
+	for (i = 0; i < acquired; i++)
+		complete(&gpu->event_free);
+
+	return -EBUSY;
 }
 
 static void event_free(struct etnaviv_gpu *gpu, unsigned int event)
@@ -1327,10 +1343,9 @@ int etnaviv_gpu_submit(struct etnaviv_gpu *gpu,
 	 *
 	 */
 
-	event = event_alloc(gpu);
-	if (unlikely(event == ~0U)) {
+	ret = event_alloc(gpu, 1, &event);
+	if (ret) {
 		DRM_ERROR("no free event\n");
-		ret = -EBUSY;
 		goto out_pm_put;
 	}
 
-- 
2.13.5

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2017-09-12 15:11 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-12 15:11 [PATCH 00/23] drm/etnaviv: support performance counters Christian Gmeiner
2017-09-12 15:11 ` [PATCH V4 01/23] drm/etnaviv: use bitmap to keep track of events Christian Gmeiner
2017-09-12 15:11 ` Christian Gmeiner [this message]
2017-09-12 15:11 ` [PATCH V4 03/23] drm/etnaviv: add infrastructure to query perf counter Christian Gmeiner
2017-09-12 15:11 ` [PATCH V4 04/23] drm/etnaviv: add uapi for perfmon feature Christian Gmeiner
2017-09-12 15:11 ` [PATCH V4 05/23] drm/etnaviv: add internal representation of perfmon_request Christian Gmeiner
2017-09-12 15:11 ` [PATCH V4 06/23] drm/etnaviv: extend etnaviv_gpu_cmdbuf_new(..) with nr_pmrs Christian Gmeiner
2017-09-12 15:11 ` [PATCH V4 07/23] drm/etnaviv: add performance monitor request validation Christian Gmeiner
2017-09-12 15:11 ` [PATCH V4 08/23] drm/etnaviv: copy pmrs from userspace Christian Gmeiner
2017-09-12 15:11 ` [PATCH V4 09/23] drm/etnaviv: add performance monitor request processing Christian Gmeiner
2017-09-12 15:11 ` [PATCH V4 10/23] drm/etnaviv: add 'sync point' support Christian Gmeiner
2017-09-12 15:11 ` [PATCH V4 11/23] drm/etnaviv: clear alloced event Christian Gmeiner
2017-09-12 15:11 ` [PATCH V4 12/23] drm/etnaviv: use 'sync points' for performance monitor requests Christian Gmeiner
2017-09-13 11:03   ` Lucas Stach
2017-09-13 14:35     ` Christian Gmeiner
2017-09-12 15:11 ` [PATCH V4 13/23] drm/etnaviv: add HI perf domain Christian Gmeiner
2017-09-12 15:11 ` [PATCH V4 14/23] drm/etnaviv: add PE " Christian Gmeiner
2017-09-12 15:11 ` [PATCH V4 15/23] drm/etnaviv: add SH " Christian Gmeiner
2017-09-12 15:11 ` [PATCH V4 16/23] drm/etnaviv: add PA " Christian Gmeiner
2017-09-12 15:11 ` [PATCH V4 17/23] drm/etnaviv: add SE " Christian Gmeiner
2017-09-12 15:11 ` [PATCH V4 18/23] drm/etnaviv: add RA " Christian Gmeiner
2017-09-12 15:11 ` [PATCH V4 19/23] drm/etnaviv: add TX " Christian Gmeiner
2017-09-12 15:11 ` [PATCH V4 20/23] drm/etnaviv: add MC " Christian Gmeiner
2017-09-12 15:11 ` [PATCH V4 21/23] drm/etnaviv: need to disable clock gating when doing profiling Christian Gmeiner
2017-09-13 11:05   ` Lucas Stach
2017-09-13 14:36     ` Christian Gmeiner
2017-09-12 15:11 ` [PATCH V4 22/23] drm/etnaviv: enable debug registers on demand Christian Gmeiner
2017-09-12 15:11 ` [PATCH V4 23/23] drm/etnaviv: submit supports performance monitor requests Christian Gmeiner
2017-09-13 11:01 ` [PATCH 00/23] drm/etnaviv: support performance counters Lucas Stach
2017-09-13 14:32   ` Christian Gmeiner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170912151155.4603-3-christian.gmeiner@gmail.com \
    --to=christian.gmeiner@gmail.com \
    --cc=cphealy@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=etnaviv@lists.freedesktop.org \
    --cc=linux+etnaviv@armlinux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.