dri-devel Archive on 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 V2 01/23] drm/etnaviv: use bitmap to keep track of events
Date: Sat, 22 Jul 2017 11:53:01 +0200	[thread overview]
Message-ID: <20170722095323.9964-2-christian.gmeiner@gmail.com> (raw)
In-Reply-To: <20170722095323.9964-1-christian.gmeiner@gmail.com>

This is prep work to be able to allocate multiple events in one go.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
---
 drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 31 +++++++++++++------------------
 drivers/gpu/drm/etnaviv/etnaviv_gpu.h |  6 ++++--
 2 files changed, 17 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
index ada45fdd0eae..fa9c7bd98e9c 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
@@ -739,10 +739,9 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu)
 	/* Setup event management */
 	spin_lock_init(&gpu->event_spinlock);
 	init_completion(&gpu->event_free);
-	for (i = 0; i < ARRAY_SIZE(gpu->event); i++) {
-		gpu->event[i].used = false;
+	bitmap_zero(gpu->event_bitmap, ETNA_NR_EVENTS);
+	for (i = 0; i < ARRAY_SIZE(gpu->event); i++)
 		complete(&gpu->event_free);
-	}
 
 	/* Now program the hardware */
 	mutex_lock(&gpu->lock);
@@ -926,7 +925,7 @@ static void recover_worker(struct work_struct *work)
 	struct etnaviv_gpu *gpu = container_of(work, struct etnaviv_gpu,
 					       recover_work);
 	unsigned long flags;
-	unsigned int i;
+	unsigned int i = 0;
 
 	dev_err(gpu->dev, "hangcheck recover!\n");
 
@@ -945,14 +944,12 @@ static void recover_worker(struct work_struct *work)
 
 	/* complete all events, the GPU won't do it after the reset */
 	spin_lock_irqsave(&gpu->event_spinlock, flags);
-	for (i = 0; i < ARRAY_SIZE(gpu->event); i++) {
-		if (!gpu->event[i].used)
-			continue;
+	for_each_set_bit_from(i, gpu->event_bitmap, ETNA_NR_EVENTS) {
 		dma_fence_signal(gpu->event[i].fence);
 		gpu->event[i].fence = NULL;
-		gpu->event[i].used = false;
 		complete(&gpu->event_free);
 	}
+	bitmap_zero(gpu->event_bitmap, ETNA_NR_EVENTS);
 	spin_unlock_irqrestore(&gpu->event_spinlock, flags);
 	gpu->completed_fence = gpu->active_fence;
 
@@ -1143,7 +1140,7 @@ int etnaviv_gpu_fence_sync_obj(struct etnaviv_gem_object *etnaviv_obj,
 static unsigned int event_alloc(struct etnaviv_gpu *gpu)
 {
 	unsigned long ret, flags;
-	unsigned int i, event = ~0U;
+	unsigned int event;
 
 	ret = wait_for_completion_timeout(&gpu->event_free,
 					  msecs_to_jiffies(10 * 10000));
@@ -1153,13 +1150,11 @@ static unsigned int event_alloc(struct etnaviv_gpu *gpu)
 	spin_lock_irqsave(&gpu->event_spinlock, flags);
 
 	/* find first free event */
-	for (i = 0; i < ARRAY_SIZE(gpu->event); i++) {
-		if (gpu->event[i].used == false) {
-			gpu->event[i].used = true;
-			event = i;
-			break;
-		}
-	}
+	event = find_first_zero_bit(gpu->event_bitmap, ETNA_NR_EVENTS);
+	if (event < ETNA_NR_EVENTS)
+		set_bit(event, gpu->event_bitmap);
+	else
+		event = ~0U;
 
 	spin_unlock_irqrestore(&gpu->event_spinlock, flags);
 
@@ -1172,12 +1167,12 @@ static void event_free(struct etnaviv_gpu *gpu, unsigned int event)
 
 	spin_lock_irqsave(&gpu->event_spinlock, flags);
 
-	if (gpu->event[event].used == false) {
+	if (!test_bit(event, gpu->event_bitmap)) {
 		dev_warn(gpu->dev, "event %u is already marked as free",
 			 event);
 		spin_unlock_irqrestore(&gpu->event_spinlock, flags);
 	} else {
-		gpu->event[event].used = false;
+		clear_bit(event, gpu->event_bitmap);
 		spin_unlock_irqrestore(&gpu->event_spinlock, flags);
 
 		complete(&gpu->event_free);
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.h b/drivers/gpu/drm/etnaviv/etnaviv_gpu.h
index 689cb8f3680c..70e6590aacdf 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.h
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.h
@@ -88,13 +88,14 @@ struct etnaviv_chip_identity {
 };
 
 struct etnaviv_event {
-	bool used;
 	struct dma_fence *fence;
 };
 
 struct etnaviv_cmdbuf_suballoc;
 struct etnaviv_cmdbuf;
 
+#define ETNA_NR_EVENTS 30
+
 struct etnaviv_gpu {
 	struct drm_device *drm;
 	struct thermal_cooling_device *cooling;
@@ -112,7 +113,8 @@ struct etnaviv_gpu {
 	u32 memory_base;
 
 	/* event management: */
-	struct etnaviv_event event[30];
+	DECLARE_BITMAP(event_bitmap, ETNA_NR_EVENTS);
+	struct etnaviv_event event[ETNA_NR_EVENTS];
 	struct completion event_free;
 	spinlock_t event_spinlock;
 
-- 
2.13.3

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

  reply	other threads:[~2017-07-22  9:53 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-22  9:53 [PATCH V2 00/23] drm/etnaviv: support performance counters Christian Gmeiner
2017-07-22  9:53 ` Christian Gmeiner [this message]
2017-07-22  9:53 ` [PATCH V2 02/23] drm/etnaviv: make it possible to allocate multiple events Christian Gmeiner
2017-08-08 10:00   ` Lucas Stach
2017-08-22  8:27     ` Christian Gmeiner
2017-08-22  8:39       ` Lucas Stach
2017-08-22  8:55         ` Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 03/23] drm/etnaviv: add infrastructure to query perf counter Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 04/23] drm/etnaviv: add uapi for perfmon feature Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 05/23] drm/etnaviv: add internal representation of perfmon_request Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 06/23] drm/etnaviv: extend etnaviv_gpu_cmdbuf_new(..) with nr_pmrs Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 07/23] drm/etnaviv: add performance monitor request validation Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 08/23] drm/etnaviv: copy pmrs from userspace Christian Gmeiner
2017-08-08 10:13   ` Lucas Stach
2017-08-22  8:34     ` Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 09/23] drm/etnaviv: add performance monitor request processing Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 10/23] drm/etnaviv: add 'sync point' support Christian Gmeiner
2017-08-08 10:34   ` Lucas Stach
2017-08-22  9:58     ` Christian Gmeiner
2017-08-22 10:17       ` Lucas Stach
2017-07-22  9:53 ` [PATCH V2 11/23] drm/etnaviv: clear alloced event Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 12/23] drm/etnaviv: use 'sync points' for performance monitor requests Christian Gmeiner
2017-08-08 10:49   ` Lucas Stach
2017-08-22  8:39     ` Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 13/23] drm/etnaviv: add HI perf domain Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 14/23] drm/etnaviv: add PE " Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 15/23] drm/etnaviv: add SH " Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 16/23] drm/etnaviv: add PA " Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 17/23] drm/etnaviv: add SE " Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 18/23] drm/etnaviv: add RA " Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 19/23] drm/etnaviv: add TX " Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 20/23] drm/etnaviv: add MC " Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 21/23] drm/etnaviv: need to disable clock gating when doing profiling Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 22/23] drm/etnaviv: enable debug registers on demand Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 23/23] drm/etnaviv: submit supports performance monitor requests 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=20170722095323.9964-2-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox