[prev in list] [next in list] [prev in thread] [next in thread] 

List:       dri-patches
Subject:    drm: Branch 'master' - 4 commits
From:       robclark () kemper ! freedesktop ! org (Rob Clark)
Date:       2015-08-17 18:40:52
Message-ID: 20150817184052.8160C761E3 () kemper ! freedesktop ! org
[Download RAW message or body]

 freedreno/freedreno_drmif.h    |    3 
 freedreno/freedreno_pipe.c     |    8 +-
 freedreno/freedreno_priv.h     |    2 
 freedreno/kgsl/kgsl_pipe.c     |    3 
 freedreno/msm/msm_bo.c         |    6 -
 freedreno/msm/msm_pipe.c       |    5 -
 freedreno/msm/msm_priv.h       |   21 ++++-
 freedreno/msm/msm_ringbuffer.c |  155 ++++++++++++++++++++++++++---------------
 8 files changed, 133 insertions(+), 70 deletions(-)

New commits:
commit 15ba8768f7002d220002d424790ff2e89310c07f
Author: Rob Clark <robclark@freedesktop.org>
Date:   Mon Aug 17 10:33:59 2015 -0400

    freedreno: add fd_pipe_wait_timeout()
    
    We need to pass through a timeout parameter to implement
    pipe->fence_finish() properly.
    
    Signed-off-by: Rob Clark <robclark@freedesktop.org>

diff --git a/freedreno/freedreno_drmif.h b/freedreno/freedreno_drmif.h
index 88fc03d..81a14b4 100644
--- a/freedreno/freedreno_drmif.h
+++ b/freedreno/freedreno_drmif.h
@@ -86,6 +86,9 @@ void fd_pipe_del(struct fd_pipe *pipe);
 int fd_pipe_get_param(struct fd_pipe *pipe, enum fd_param_id param,
 		uint64_t *value);
 int fd_pipe_wait(struct fd_pipe *pipe, uint32_t timestamp);
+/* timeout in nanosec */
+int fd_pipe_wait_timeout(struct fd_pipe *pipe, uint32_t timestamp,
+		uint64_t timeout);
 
 
 /* buffer-object functions:
diff --git a/freedreno/freedreno_pipe.c b/freedreno/freedreno_pipe.c
index b6fed0a..4a756d7 100644
--- a/freedreno/freedreno_pipe.c
+++ b/freedreno/freedreno_pipe.c
@@ -72,5 +72,11 @@ int fd_pipe_get_param(struct fd_pipe *pipe,
 
 int fd_pipe_wait(struct fd_pipe *pipe, uint32_t timestamp)
 {
-	return pipe->funcs->wait(pipe, timestamp);
+	return fd_pipe_wait_timeout(pipe, timestamp, ~0);
+}
+
+int fd_pipe_wait_timeout(struct fd_pipe *pipe, uint32_t timestamp,
+		uint64_t timeout)
+{
+	return pipe->funcs->wait(pipe, timestamp, timeout);
 }
diff --git a/freedreno/freedreno_priv.h b/freedreno/freedreno_priv.h
index cb24780..1dddcc3 100644
--- a/freedreno/freedreno_priv.h
+++ b/freedreno/freedreno_priv.h
@@ -100,7 +100,7 @@ drm_private void fd_device_del_locked(struct fd_device *dev);
 struct fd_pipe_funcs {
 	struct fd_ringbuffer * (*ringbuffer_new)(struct fd_pipe *pipe, uint32_t size);
 	int (*get_param)(struct fd_pipe *pipe, enum fd_param_id param, uint64_t *value);
-	int (*wait)(struct fd_pipe *pipe, uint32_t timestamp);
+	int (*wait)(struct fd_pipe *pipe, uint32_t timestamp, uint64_t timeout);
 	void (*destroy)(struct fd_pipe *pipe);
 };
 
diff --git a/freedreno/kgsl/kgsl_pipe.c b/freedreno/kgsl/kgsl_pipe.c
index 08c87a6..e2fd65c 100644
--- a/freedreno/kgsl/kgsl_pipe.c
+++ b/freedreno/kgsl/kgsl_pipe.c
@@ -56,7 +56,8 @@ static int kgsl_pipe_get_param(struct fd_pipe *pipe,
 	}
 }
 
-static int kgsl_pipe_wait(struct fd_pipe *pipe, uint32_t timestamp)
+static int kgsl_pipe_wait(struct fd_pipe *pipe, uint32_t timestamp,
+		uint64_t timeout)
 {
 	struct kgsl_pipe *kgsl_pipe = to_kgsl_pipe(pipe);
 	struct kgsl_device_waittimestamp req = {
diff --git a/freedreno/msm/msm_bo.c b/freedreno/msm/msm_bo.c
index 6dc3776..fd94413 100644
--- a/freedreno/msm/msm_bo.c
+++ b/freedreno/msm/msm_bo.c
@@ -75,7 +75,7 @@ static int msm_bo_cpu_prep(struct fd_bo *bo, struct fd_pipe *pipe, uint32_t op)
 			.op = op,
 	};
 
-	get_abs_timeout(&req.timeout, 5000);
+	get_abs_timeout(&req.timeout, 5000000000);
 
 	return drmCommandWrite(bo->dev->fd, DRM_MSM_GEM_CPU_PREP, &req, sizeof(req));
 }
diff --git a/freedreno/msm/msm_pipe.c b/freedreno/msm/msm_pipe.c
index ddc975e..e1edffe 100644
--- a/freedreno/msm/msm_pipe.c
+++ b/freedreno/msm/msm_pipe.c
@@ -54,7 +54,8 @@ static int msm_pipe_get_param(struct fd_pipe *pipe,
 	}
 }
 
-static int msm_pipe_wait(struct fd_pipe *pipe, uint32_t timestamp)
+static int msm_pipe_wait(struct fd_pipe *pipe, uint32_t timestamp,
+		uint64_t timeout)
 {
 	struct fd_device *dev = pipe->dev;
 	struct drm_msm_wait_fence req = {
@@ -62,7 +63,7 @@ static int msm_pipe_wait(struct fd_pipe *pipe, uint32_t timestamp)
 	};
 	int ret;
 
-	get_abs_timeout(&req.timeout, 5000);
+	get_abs_timeout(&req.timeout, timeout);
 
 	ret = drmCommandWrite(dev->fd, DRM_MSM_WAIT_FENCE, &req, sizeof(req));
 	if (ret) {
diff --git a/freedreno/msm/msm_priv.h b/freedreno/msm/msm_priv.h
index 637cb52..e499b3b 100644
--- a/freedreno/msm/msm_priv.h
+++ b/freedreno/msm/msm_priv.h
@@ -96,13 +96,13 @@ drm_private int msm_bo_new_handle(struct fd_device *dev,
 drm_private struct fd_bo * msm_bo_from_handle(struct fd_device *dev,
 		uint32_t size, uint32_t handle);
 
-static inline void get_abs_timeout(struct drm_msm_timespec *tv, uint32_t ms)
+static inline void get_abs_timeout(struct drm_msm_timespec *tv, uint64_t ns)
 {
 	struct timespec t;
-	uint32_t s = ms / 1000;
+	uint32_t s = ns / 1000000000;
 	clock_gettime(CLOCK_MONOTONIC, &t);
 	tv->tv_sec = t.tv_sec + s;
-	tv->tv_nsec = t.tv_nsec + ((ms - (s * 1000)) * 1000000);
+	tv->tv_nsec = t.tv_nsec + ns - (s * 1000000000);
 }
 
 #endif /* MSM_PRIV_H_ */
commit 4413f191a051847c53a6150df199d35a106b6cf4
Author: Rob Clark <robclark@freedesktop.org>
Date:   Tue Jul 21 12:55:29 2015 -0400

    freedreno/msm: dump out submit info on error
    
    User should only see these with LIBGL_DEBUG=verbose.  But in case you
    are hitting issues like "handle X at index Y already on submit list"
    errors from the kernel, this gives some useful visibility for debug.
    
    Signed-off-by: Rob Clark <robclark@freedesktop.org>

diff --git a/freedreno/msm/msm_ringbuffer.c b/freedreno/msm/msm_ringbuffer.c
index 842574e..5ddea57 100644
--- a/freedreno/msm/msm_ringbuffer.c
+++ b/freedreno/msm/msm_ringbuffer.c
@@ -31,6 +31,7 @@
 #endif
 
 #include <assert.h>
+#include <inttypes.h>
 
 #include "freedreno_ringbuffer.h"
 #include "msm_priv.h"
@@ -228,7 +229,7 @@ static int msm_ringbuffer_flush(struct fd_ringbuffer *ring, uint32_t *last_start
 	struct drm_msm_gem_submit req = {
 			.pipe = to_msm_pipe(ring->pipe)->pipe,
 	};
-	uint32_t i, submit_offset, size;
+	uint32_t i, j, submit_offset, size;
 	int ret;
 
 	submit_offset = offset_bytes(last_start, ring->start);
@@ -258,6 +259,23 @@ static int msm_ringbuffer_flush(struct fd_ringbuffer *ring, uint32_t *last_start
 			&req, sizeof(req));
 	if (ret) {
 		ERROR_MSG("submit failed: %d (%s)", ret, strerror(errno));
+		ERROR_MSG("  pipe:  %u", req.pipe);
+		for (i = 0; i < msm_ring->submit.nr_bos; i++) {
+			struct drm_msm_gem_submit_bo *bo = &msm_ring->submit.bos[i];
+			ERROR_MSG("  bos[%d]: handle=%u, flags=%x", i, bo->handle, bo->flags);
+		}
+		for (i = 0; i < msm_ring->submit.nr_cmds; i++) {
+			struct drm_msm_gem_submit_cmd *cmd = &msm_ring->submit.cmds[i];
+			struct drm_msm_gem_submit_reloc *relocs = U642VOID(cmd->relocs);
+			ERROR_MSG("  cmd[%d]: type=%u, submit_idx=%u, submit_offset=%u, size=%u\n",
+					i, cmd->type, cmd->submit_idx, cmd->submit_offset, cmd->size);
+			for (j = 0; j < cmd->nr_relocs; j++) {
+				struct drm_msm_gem_submit_reloc *r = &relocs[j];
+				ERROR_MSG("    reloc[%d]: submit_offset=%u, or=%08x, shift=%d, reloc_idx=%u"
+						", reloc_offset=%"PRIu64, j, r->submit_offset, r->or, r->shift,
+						r->reloc_idx, r->reloc_offset);
+			}
+		}
 	} else {
 		/* update timestamp on all rings associated with submit: */
 		for (i = 0; i < msm_ring->submit.nr_cmds; i++) {
commit 9e34ee4f75ef559ff3a3c6d4b8f285453eea1f29
Author: Rob Clark <robclark@freedesktop.org>
Date:   Tue Jul 21 11:57:00 2015 -0400

    freedreno/msm: fix issue where same bo is on multiple rings
    
    It should be a less common case, but it is possible for a single bo to
    be on multiple rings, for example when sharing a buffer across multiple
    pipe_context's created from same pipe_screen.
    
    So rather than completely fall over in this case, fallback to slow-path
    of looping over all bo's in the ring's bo-table (but retain the fast-
    path of constant-lookup for the first ring the buffer is on).
    
    Signed-off-by: Rob Clark <robclark@freedesktop.org>

diff --git a/freedreno/msm/msm_bo.c b/freedreno/msm/msm_bo.c
index 3f5b6d0..6dc3776 100644
--- a/freedreno/msm/msm_bo.c
+++ b/freedreno/msm/msm_bo.c
@@ -129,7 +129,6 @@ drm_private struct fd_bo * msm_bo_from_handle(struct fd_device *dev,
 {
 	struct msm_bo *msm_bo;
 	struct fd_bo *bo;
-	unsigned i;
 
 	msm_bo = calloc(1, sizeof(*msm_bo));
 	if (!msm_bo)
@@ -139,8 +138,5 @@ drm_private struct fd_bo * msm_bo_from_handle(struct fd_device *dev,
 	bo->funcs = &funcs;
 	bo->fd = -1;
 
-	for (i = 0; i < ARRAY_SIZE(msm_bo->list); i++)
-		list_inithead(&msm_bo->list[i]);
-
 	return bo;
 }
diff --git a/freedreno/msm/msm_priv.h b/freedreno/msm/msm_priv.h
index 94d2357..637cb52 100644
--- a/freedreno/msm/msm_priv.h
+++ b/freedreno/msm/msm_priv.h
@@ -71,8 +71,19 @@ struct msm_bo {
 	struct fd_bo base;
 	uint64_t offset;
 	uint64_t presumed;
-	uint32_t indexp1[FD_PIPE_MAX]; /* index plus 1 */
-	struct list_head list[FD_PIPE_MAX];
+	/* in the common case, a bo won't be referenced by more than a single
+	 * (parent) ring[*].  So to avoid looping over all the bo's in the
+	 * reloc table to find the idx of a bo that might already be in the
+	 * table, we cache the idx in the bo.  But in order to detect the
+	 * slow-path where bo is ref'd in multiple rb's, we also must track
+	 * the current_ring for which the idx is valid.  See bo2idx().
+	 *
+	 * [*] in case multiple ringbuffers, ie. one toplevel and other rb(s)
+	 *     used for IB target(s), the toplevel rb is the parent which is
+	 *     tracking bo's for the submit
+	 */
+	struct fd_ringbuffer *current_ring;
+	uint32_t idx;
 };
 
 static inline struct msm_bo * to_msm_bo(struct fd_bo *x)
diff --git a/freedreno/msm/msm_ringbuffer.c b/freedreno/msm/msm_ringbuffer.c
index 2798c3f..842574e 100644
--- a/freedreno/msm/msm_ringbuffer.c
+++ b/freedreno/msm/msm_ringbuffer.c
@@ -39,8 +39,6 @@ struct msm_ringbuffer {
 	struct fd_ringbuffer base;
 	struct fd_bo *ring_bo;
 
-	struct list_head submit_list;
-
 	/* submit ioctl related tables: */
 	struct {
 		/* bo's table: */
@@ -56,11 +54,17 @@ struct msm_ringbuffer {
 		uint32_t nr_relocs, max_relocs;
 	} submit;
 
+	/* should have matching entries in submit.bos: */
+	struct fd_bo **bos;
+	uint32_t nr_bos, max_bos;
+
 	/* should have matching entries in submit.cmds: */
 	struct fd_ringbuffer **rings;
 	uint32_t nr_rings, max_rings;
 };
 
+static pthread_mutex_t idx_lock = PTHREAD_MUTEX_INITIALIZER;
+
 static void *grow(void *ptr, uint32_t nr, uint32_t *max, uint32_t sz)
 {
 	if ((nr + 1) > *max) {
@@ -83,27 +87,47 @@ static inline struct msm_ringbuffer * to_msm_ringbuffer(struct fd_ringbuffer *x)
 	return (struct msm_ringbuffer *)x;
 }
 
+static uint32_t append_bo(struct fd_ringbuffer *ring, struct fd_bo *bo)
+{
+	struct msm_ringbuffer *msm_ring = to_msm_ringbuffer(ring);
+	uint32_t idx;
+
+	idx = APPEND(&msm_ring->submit, bos);
+	idx = APPEND(msm_ring, bos);
+
+	msm_ring->submit.bos[idx].flags = 0;
+	msm_ring->submit.bos[idx].handle = bo->handle;
+	msm_ring->submit.bos[idx].presumed = to_msm_bo(bo)->presumed;
+
+	msm_ring->bos[idx] = fd_bo_ref(bo);
+
+	return idx;
+}
+
 /* add (if needed) bo, return idx: */
 static uint32_t bo2idx(struct fd_ringbuffer *ring, struct fd_bo *bo, uint32_t flags)
 {
 	struct msm_ringbuffer *msm_ring = to_msm_ringbuffer(ring);
 	struct msm_bo *msm_bo = to_msm_bo(bo);
-	int id = ring->pipe->id;
 	uint32_t idx;
-	if (!msm_bo->indexp1[id]) {
-		struct list_head *list = &msm_bo->list[id];
-		idx = APPEND(&msm_ring->submit, bos);
-		msm_ring->submit.bos[idx].flags = 0;
-		msm_ring->submit.bos[idx].handle = bo->handle;
-		msm_ring->submit.bos[idx].presumed = msm_bo->presumed;
-		msm_bo->indexp1[id] = idx + 1;
-
-		assert(LIST_IS_EMPTY(list));
-		fd_bo_ref(bo);
-		list_addtail(list, &msm_ring->submit_list);
+	pthread_mutex_lock(&idx_lock);
+	if (!msm_bo->current_ring) {
+		idx = append_bo(ring, bo);
+		msm_bo->current_ring = ring;
+		msm_bo->idx = idx;
+	} else if (msm_bo->current_ring == ring) {
+		idx = msm_bo->idx;
 	} else {
-		idx = msm_bo->indexp1[id] - 1;
+		/* slow-path: */
+		for (idx = 0; idx < msm_ring->nr_bos; idx++)
+			if (msm_ring->bos[idx] == bo)
+				break;
+		if (idx == msm_ring->nr_bos) {
+			/* not found */
+			idx = append_bo(ring, bo);
+		}
 	}
+	pthread_mutex_unlock(&idx_lock);
 	if (flags & FD_RELOC_READ)
 		msm_ring->submit.bos[idx].flags |= MSM_SUBMIT_BO_READ;
 	if (flags & FD_RELOC_WRITE)
@@ -193,6 +217,8 @@ static void flush_reset(struct fd_ringbuffer *ring)
 	msm_ring->submit.nr_relocs = 0;
 	msm_ring->submit.nr_cmds = 0;
 	msm_ring->submit.nr_bos = 0;
+	msm_ring->nr_rings = 0;
+	msm_ring->nr_bos = 0;
 }
 
 static int msm_ringbuffer_flush(struct fd_ringbuffer *ring, uint32_t *last_start)
@@ -202,9 +228,8 @@ static int msm_ringbuffer_flush(struct fd_ringbuffer *ring, uint32_t *last_start
 	struct drm_msm_gem_submit req = {
 			.pipe = to_msm_pipe(ring->pipe)->pipe,
 	};
-	struct msm_bo *msm_bo = NULL, *tmp;
 	uint32_t i, submit_offset, size;
-	int ret, id = ring->pipe->id;
+	int ret;
 
 	submit_offset = offset_bytes(last_start, ring->start);
 	size = offset_bytes(ring->cur, last_start);
@@ -242,10 +267,9 @@ static int msm_ringbuffer_flush(struct fd_ringbuffer *ring, uint32_t *last_start
 		}
 	}
 
-	LIST_FOR_EACH_ENTRY_SAFE(msm_bo, tmp, &msm_ring->submit_list, list[id]) {
-		struct list_head *list = &msm_bo->list[id];
-		list_delinit(list);
-		msm_bo->indexp1[id] = 0;
+	for (i = 0; i < msm_ring->nr_bos; i++) {
+		struct msm_bo *msm_bo = to_msm_bo(msm_ring->bos[i]);
+		msm_bo->current_ring = NULL;
 		fd_bo_del(&msm_bo->base);
 	}
 
@@ -338,8 +362,6 @@ drm_private struct fd_ringbuffer * msm_ringbuffer_new(struct fd_pipe *pipe,
 	ring = &msm_ring->base;
 	ring->funcs = &funcs;
 
-	list_inithead(&msm_ring->submit_list);
-
 	msm_ring->ring_bo = fd_bo_new(pipe->dev, size, 0);
 	if (!msm_ring->ring_bo) {
 		ERROR_MSG("ringbuffer allocation failed");
commit 2fa58ef8f43b41a6d12396ff637f09860665072f
Author: Rob Clark <robclark@freedesktop.org>
Date:   Tue Jul 21 12:11:36 2015 -0400

    freedreno/msm: reorg ringbuffer struct
    
    Group the parts related to building out submit ioctl into their own
    sub-struct.  Split out from next commit since it is just boring churn.
    
    Signed-off-by: Rob Clark <robclark@freedesktop.org>

diff --git a/freedreno/msm/msm_ringbuffer.c b/freedreno/msm/msm_ringbuffer.c
index 6ee85bd..2798c3f 100644
--- a/freedreno/msm/msm_ringbuffer.c
+++ b/freedreno/msm/msm_ringbuffer.c
@@ -41,19 +41,24 @@ struct msm_ringbuffer {
 
 	struct list_head submit_list;
 
-	/* bo's table: */
-	struct drm_msm_gem_submit_bo *bos;
-	uint32_t nr_bos, max_bos;
-
-	/* cmd's table: */
-	struct drm_msm_gem_submit_cmd *cmds;
-	uint32_t nr_cmds, max_cmds;
+	/* submit ioctl related tables: */
+	struct {
+		/* bo's table: */
+		struct drm_msm_gem_submit_bo *bos;
+		uint32_t nr_bos, max_bos;
+
+		/* cmd's table: */
+		struct drm_msm_gem_submit_cmd *cmds;
+		uint32_t nr_cmds, max_cmds;
+
+		/* reloc's table: */
+		struct drm_msm_gem_submit_reloc *relocs;
+		uint32_t nr_relocs, max_relocs;
+	} submit;
+
+	/* should have matching entries in submit.cmds: */
 	struct fd_ringbuffer **rings;
 	uint32_t nr_rings, max_rings;
-
-	/* reloc's table: */
-	struct drm_msm_gem_submit_reloc *relocs;
-	uint32_t nr_relocs, max_relocs;
 };
 
 static void *grow(void *ptr, uint32_t nr, uint32_t *max, uint32_t sz)
@@ -87,10 +92,10 @@ static uint32_t bo2idx(struct fd_ringbuffer *ring, struct fd_bo *bo, uint32_t fl
 	uint32_t idx;
 	if (!msm_bo->indexp1[id]) {
 		struct list_head *list = &msm_bo->list[id];
-		idx = APPEND(msm_ring, bos);
-		msm_ring->bos[idx].flags = 0;
-		msm_ring->bos[idx].handle = bo->handle;
-		msm_ring->bos[idx].presumed = msm_bo->presumed;
+		idx = APPEND(&msm_ring->submit, bos);
+		msm_ring->submit.bos[idx].flags = 0;
+		msm_ring->submit.bos[idx].handle = bo->handle;
+		msm_ring->submit.bos[idx].presumed = msm_bo->presumed;
 		msm_bo->indexp1[id] = idx + 1;
 
 		assert(LIST_IS_EMPTY(list));
@@ -100,9 +105,9 @@ static uint32_t bo2idx(struct fd_ringbuffer *ring, struct fd_bo *bo, uint32_t fl
 		idx = msm_bo->indexp1[id] - 1;
 	}
 	if (flags & FD_RELOC_READ)
-		msm_ring->bos[idx].flags |= MSM_SUBMIT_BO_READ;
+		msm_ring->submit.bos[idx].flags |= MSM_SUBMIT_BO_READ;
 	if (flags & FD_RELOC_WRITE)
-		msm_ring->bos[idx].flags |= MSM_SUBMIT_BO_WRITE;
+		msm_ring->submit.bos[idx].flags |= MSM_SUBMIT_BO_WRITE;
 	return idx;
 }
 
@@ -110,7 +115,7 @@ static int check_cmd_bo(struct fd_ringbuffer *ring,
 		struct drm_msm_gem_submit_cmd *cmd, struct fd_bo *bo)
 {
 	struct msm_ringbuffer *msm_ring = to_msm_ringbuffer(ring);
-	return msm_ring->bos[cmd->submit_idx].handle == bo->handle;
+	return msm_ring->submit.bos[cmd->submit_idx].handle == bo->handle;
 }
 
 static uint32_t offset_bytes(void *end, void *start)
@@ -127,8 +132,8 @@ static struct drm_msm_gem_submit_cmd * get_cmd(struct fd_ringbuffer *ring,
 	uint32_t i;
 
 	/* figure out if we already have a cmd buf: */
-	for (i = 0; i < msm_ring->nr_cmds; i++) {
-		cmd = &msm_ring->cmds[i];
+	for (i = 0; i < msm_ring->submit.nr_cmds; i++) {
+		cmd = &msm_ring->submit.cmds[i];
 		if ((cmd->submit_offset == submit_offset) &&
 				(cmd->size == size) &&
 				(cmd->type == type) &&
@@ -139,10 +144,10 @@ static struct drm_msm_gem_submit_cmd * get_cmd(struct fd_ringbuffer *ring,
 
 	/* create cmd buf if not: */
 	if (!cmd) {
-		uint32_t idx = APPEND(msm_ring, cmds);
+		uint32_t idx = APPEND(&msm_ring->submit, cmds);
 		APPEND(msm_ring, rings);
 		msm_ring->rings[idx] = target_ring;
-		cmd = &msm_ring->cmds[idx];
+		cmd = &msm_ring->submit.cmds[idx];
 		cmd->type = type;
 		cmd->submit_idx = bo2idx(ring, target_bo, FD_RELOC_READ);
 		cmd->submit_offset = submit_offset;
@@ -165,8 +170,8 @@ static uint32_t find_next_reloc_idx(struct msm_ringbuffer *msm_ring,
 	uint32_t i;
 
 	/* a binary search would be more clever.. */
-	for (i = start; i < msm_ring->nr_relocs; i++) {
-		struct drm_msm_gem_submit_reloc *reloc = &msm_ring->relocs[i];
+	for (i = start; i < msm_ring->submit.nr_relocs; i++) {
+		struct drm_msm_gem_submit_reloc *reloc = &msm_ring->submit.relocs[i];
 		if (reloc->submit_offset >= offset)
 			return i;
 	}
@@ -180,14 +185,14 @@ static void flush_reset(struct fd_ringbuffer *ring)
 	unsigned i;
 
 	/* for each of the cmd buffers, clear their reloc's: */
-	for (i = 0; i < msm_ring->nr_cmds; i++) {
+	for (i = 0; i < msm_ring->submit.nr_cmds; i++) {
 		struct msm_ringbuffer *target_ring = to_msm_ringbuffer(msm_ring->rings[i]);
-		target_ring->nr_relocs = 0;
+		target_ring->submit.nr_relocs = 0;
 	}
 
-	msm_ring->nr_relocs = 0;
-	msm_ring->nr_cmds = 0;
-	msm_ring->nr_bos = 0;
+	msm_ring->submit.nr_relocs = 0;
+	msm_ring->submit.nr_cmds = 0;
+	msm_ring->submit.nr_bos = 0;
 }
 
 static int msm_ringbuffer_flush(struct fd_ringbuffer *ring, uint32_t *last_start)
@@ -207,18 +212,18 @@ static int msm_ringbuffer_flush(struct fd_ringbuffer *ring, uint32_t *last_start
 	get_cmd(ring, ring, ring_bo, submit_offset, size, MSM_SUBMIT_CMD_BUF);
 
 	/* needs to be after get_cmd() as that could create bos/cmds table: */
-	req.bos = VOID2U64(msm_ring->bos),
-	req.nr_bos = msm_ring->nr_bos;
-	req.cmds = VOID2U64(msm_ring->cmds),
-	req.nr_cmds = msm_ring->nr_cmds;
+	req.bos = VOID2U64(msm_ring->submit.bos),
+	req.nr_bos = msm_ring->submit.nr_bos;
+	req.cmds = VOID2U64(msm_ring->submit.cmds),
+	req.nr_cmds = msm_ring->submit.nr_cmds;
 
 	/* for each of the cmd's fix up their reloc's: */
-	for (i = 0; i < msm_ring->nr_cmds; i++) {
-		struct drm_msm_gem_submit_cmd *cmd = &msm_ring->cmds[i];
+	for (i = 0; i < msm_ring->submit.nr_cmds; i++) {
+		struct drm_msm_gem_submit_cmd *cmd = &msm_ring->submit.cmds[i];
 		struct msm_ringbuffer *target_ring = to_msm_ringbuffer(msm_ring->rings[i]);
 		uint32_t a = find_next_reloc_idx(target_ring, 0, cmd->submit_offset);
 		uint32_t b = find_next_reloc_idx(target_ring, a, cmd->submit_offset + cmd->size);
-		cmd->relocs = VOID2U64(&target_ring->relocs[a]);
+		cmd->relocs = VOID2U64(&target_ring->submit.relocs[a]);
 		cmd->nr_relocs = (b > a) ? b - a : 0;
 	}
 
@@ -230,7 +235,7 @@ static int msm_ringbuffer_flush(struct fd_ringbuffer *ring, uint32_t *last_start
 		ERROR_MSG("submit failed: %d (%s)", ret, strerror(errno));
 	} else {
 		/* update timestamp on all rings associated with submit: */
-		for (i = 0; i < msm_ring->nr_cmds; i++) {
+		for (i = 0; i < msm_ring->submit.nr_cmds; i++) {
 			struct fd_ringbuffer *target_ring = msm_ring->rings[i];
 			if (!ret)
 				target_ring->last_timestamp = req.fence;
@@ -261,10 +266,10 @@ static void msm_ringbuffer_emit_reloc(struct fd_ringbuffer *ring,
 	struct fd_ringbuffer *parent = ring->parent ? ring->parent : ring;
 	struct msm_bo *msm_bo = to_msm_bo(r->bo);
 	struct drm_msm_gem_submit_reloc *reloc;
-	uint32_t idx = APPEND(msm_ring, relocs);
+	uint32_t idx = APPEND(&msm_ring->submit, relocs);
 	uint32_t addr;
 
-	reloc = &msm_ring->relocs[idx];
+	reloc = &msm_ring->submit.relocs[idx];
 
 	reloc->reloc_idx = bo2idx(parent, r->bo, r->flags);
 	reloc->reloc_offset = r->offset;

------------------------------------------------------------------------------
--
_______________________________________________
Dri-patches mailing list
Dri-patches@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-patches
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic