aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Clark2016-08-15 12:26:18 -0500
committerRob Clark2016-11-05 09:18:44 -0500
commite9eb44b45b8d4a2f06ef83365b28eca55c0f3fb4 (patch)
treefde969c3233d5829605832d0978b40e983ef0e89 /freedreno
parent9270d984cde31a8abc5f9ec31cbd86a10b883864 (diff)
downloadexternal-libdrm-e9eb44b45b8d4a2f06ef83365b28eca55c0f3fb4.tar.gz
external-libdrm-e9eb44b45b8d4a2f06ef83365b28eca55c0f3fb4.tar.xz
external-libdrm-e9eb44b45b8d4a2f06ef83365b28eca55c0f3fb4.zip
freedreno: add fence fd support
Signed-off-by: Rob Clark <robclark@freedesktop.org>
Diffstat (limited to 'freedreno')
-rw-r--r--freedreno/freedreno_drmif.h1
-rw-r--r--freedreno/freedreno_priv.h3
-rw-r--r--freedreno/freedreno_ringbuffer.c11
-rw-r--r--freedreno/freedreno_ringbuffer.h5
-rw-r--r--freedreno/kgsl/kgsl_ringbuffer.c6
-rw-r--r--freedreno/msm/msm_ringbuffer.c16
6 files changed, 36 insertions, 6 deletions
diff --git a/freedreno/freedreno_drmif.h b/freedreno/freedreno_drmif.h
index 2d913e6c..7a8073ff 100644
--- a/freedreno/freedreno_drmif.h
+++ b/freedreno/freedreno_drmif.h
@@ -92,6 +92,7 @@ int fd_device_fd(struct fd_device *dev);
92enum fd_version { 92enum fd_version {
93 FD_VERSION_MADVISE = 1, /* kernel supports madvise */ 93 FD_VERSION_MADVISE = 1, /* kernel supports madvise */
94 FD_VERSION_UNLIMITED_CMDS = 1, /* submits w/ >4 cmd buffers (growable ringbuffer) */ 94 FD_VERSION_UNLIMITED_CMDS = 1, /* submits w/ >4 cmd buffers (growable ringbuffer) */
95 FD_VERSION_FENCE_FD = 2, /* submit command supports in/out fences */
95}; 96};
96enum fd_version fd_device_version(struct fd_device *dev); 97enum fd_version fd_device_version(struct fd_device *dev);
97 98
diff --git a/freedreno/freedreno_priv.h b/freedreno/freedreno_priv.h
index cdfdbe8d..86da83b9 100644
--- a/freedreno/freedreno_priv.h
+++ b/freedreno/freedreno_priv.h
@@ -133,7 +133,8 @@ struct fd_ringmarker {
133 133
134struct fd_ringbuffer_funcs { 134struct fd_ringbuffer_funcs {
135 void * (*hostptr)(struct fd_ringbuffer *ring); 135 void * (*hostptr)(struct fd_ringbuffer *ring);
136 int (*flush)(struct fd_ringbuffer *ring, uint32_t *last_start); 136 int (*flush)(struct fd_ringbuffer *ring, uint32_t *last_start,
137 int in_fence_fd, int *out_fence_fd);
137 void (*grow)(struct fd_ringbuffer *ring, uint32_t size); 138 void (*grow)(struct fd_ringbuffer *ring, uint32_t size);
138 void (*reset)(struct fd_ringbuffer *ring); 139 void (*reset)(struct fd_ringbuffer *ring);
139 void (*emit_reloc)(struct fd_ringbuffer *ring, 140 void (*emit_reloc)(struct fd_ringbuffer *ring,
diff --git a/freedreno/freedreno_ringbuffer.c b/freedreno/freedreno_ringbuffer.c
index 22dafb39..c132145a 100644
--- a/freedreno/freedreno_ringbuffer.c
+++ b/freedreno/freedreno_ringbuffer.c
@@ -80,10 +80,15 @@ void fd_ringbuffer_reset(struct fd_ringbuffer *ring)
80 ring->funcs->reset(ring); 80 ring->funcs->reset(ring);
81} 81}
82 82
83/* maybe get rid of this and use fd_ringmarker_flush() from DDX too? */
84int fd_ringbuffer_flush(struct fd_ringbuffer *ring) 83int fd_ringbuffer_flush(struct fd_ringbuffer *ring)
85{ 84{
86 return ring->funcs->flush(ring, ring->last_start); 85 return ring->funcs->flush(ring, ring->last_start, -1, NULL);
86}
87
88int fd_ringbuffer_flush2(struct fd_ringbuffer *ring, int in_fence_fd,
89 int *out_fence_fd)
90{
91 return ring->funcs->flush(ring, ring->last_start, in_fence_fd, out_fence_fd);
87} 92}
88 93
89void fd_ringbuffer_grow(struct fd_ringbuffer *ring, uint32_t ndwords) 94void fd_ringbuffer_grow(struct fd_ringbuffer *ring, uint32_t ndwords)
@@ -177,5 +182,5 @@ uint32_t fd_ringmarker_dwords(struct fd_ringmarker *start,
177int fd_ringmarker_flush(struct fd_ringmarker *marker) 182int fd_ringmarker_flush(struct fd_ringmarker *marker)
178{ 183{
179 struct fd_ringbuffer *ring = marker->ring; 184 struct fd_ringbuffer *ring = marker->ring;
180 return ring->funcs->flush(ring, marker->cur); 185 return ring->funcs->flush(ring, marker->cur, -1, NULL);
181} 186}
diff --git a/freedreno/freedreno_ringbuffer.h b/freedreno/freedreno_ringbuffer.h
index 8899b5de..108d5a6d 100644
--- a/freedreno/freedreno_ringbuffer.h
+++ b/freedreno/freedreno_ringbuffer.h
@@ -56,6 +56,11 @@ void fd_ringbuffer_set_parent(struct fd_ringbuffer *ring,
56 struct fd_ringbuffer *parent); 56 struct fd_ringbuffer *parent);
57void fd_ringbuffer_reset(struct fd_ringbuffer *ring); 57void fd_ringbuffer_reset(struct fd_ringbuffer *ring);
58int fd_ringbuffer_flush(struct fd_ringbuffer *ring); 58int fd_ringbuffer_flush(struct fd_ringbuffer *ring);
59/* in_fence_fd: -1 for no in-fence, else fence fd
60 * out_fence_fd: NULL for no output-fence requested, else ptr to return out-fence
61 */
62int fd_ringbuffer_flush2(struct fd_ringbuffer *ring, int in_fence_fd,
63 int *out_fence_fd);
59void fd_ringbuffer_grow(struct fd_ringbuffer *ring, uint32_t ndwords); 64void fd_ringbuffer_grow(struct fd_ringbuffer *ring, uint32_t ndwords);
60uint32_t fd_ringbuffer_timestamp(struct fd_ringbuffer *ring); 65uint32_t fd_ringbuffer_timestamp(struct fd_ringbuffer *ring);
61 66
diff --git a/freedreno/kgsl/kgsl_ringbuffer.c b/freedreno/kgsl/kgsl_ringbuffer.c
index 7b3298ab..e4696b1b 100644
--- a/freedreno/kgsl/kgsl_ringbuffer.c
+++ b/freedreno/kgsl/kgsl_ringbuffer.c
@@ -113,7 +113,8 @@ static void * kgsl_ringbuffer_hostptr(struct fd_ringbuffer *ring)
113 return kgsl_ring->bo->hostptr; 113 return kgsl_ring->bo->hostptr;
114} 114}
115 115
116static int kgsl_ringbuffer_flush(struct fd_ringbuffer *ring, uint32_t *last_start) 116static int kgsl_ringbuffer_flush(struct fd_ringbuffer *ring, uint32_t *last_start,
117 int in_fence_fd, int *out_fence_fd)
117{ 118{
118 struct kgsl_ringbuffer *kgsl_ring = to_kgsl_ringbuffer(ring); 119 struct kgsl_ringbuffer *kgsl_ring = to_kgsl_ringbuffer(ring);
119 struct kgsl_pipe *kgsl_pipe = to_kgsl_pipe(ring->pipe); 120 struct kgsl_pipe *kgsl_pipe = to_kgsl_pipe(ring->pipe);
@@ -131,6 +132,9 @@ static int kgsl_ringbuffer_flush(struct fd_ringbuffer *ring, uint32_t *last_star
131 }; 132 };
132 int ret; 133 int ret;
133 134
135 assert(in_fence_fd == -1);
136 assert(out_fence_fd == NULL);
137
134 kgsl_pipe_pre_submit(kgsl_pipe); 138 kgsl_pipe_pre_submit(kgsl_pipe);
135 139
136 /* z180_cmdstream_issueibcmds() is made of fail: */ 140 /* z180_cmdstream_issueibcmds() is made of fail: */
diff --git a/freedreno/msm/msm_ringbuffer.c b/freedreno/msm/msm_ringbuffer.c
index 60f03154..5117df1a 100644
--- a/freedreno/msm/msm_ringbuffer.c
+++ b/freedreno/msm/msm_ringbuffer.c
@@ -395,7 +395,8 @@ static void dump_submit(struct msm_ringbuffer *msm_ring)
395 } 395 }
396} 396}
397 397
398static int msm_ringbuffer_flush(struct fd_ringbuffer *ring, uint32_t *last_start) 398static int msm_ringbuffer_flush(struct fd_ringbuffer *ring, uint32_t *last_start,
399 int in_fence_fd, int *out_fence_fd)
399{ 400{
400 struct msm_ringbuffer *msm_ring = to_msm_ringbuffer(ring); 401 struct msm_ringbuffer *msm_ring = to_msm_ringbuffer(ring);
401 struct drm_msm_gem_submit req = { 402 struct drm_msm_gem_submit req = {
@@ -404,6 +405,15 @@ static int msm_ringbuffer_flush(struct fd_ringbuffer *ring, uint32_t *last_start
404 uint32_t i; 405 uint32_t i;
405 int ret; 406 int ret;
406 407
408 if (in_fence_fd != -1) {
409 req.flags |= MSM_SUBMIT_FENCE_FD_IN | MSM_SUBMIT_NO_IMPLICIT;
410 req.fence_fd = in_fence_fd;
411 }
412
413 if (out_fence_fd) {
414 req.flags |= MSM_SUBMIT_FENCE_FD_OUT;
415 }
416
407 finalize_current_cmd(ring, last_start); 417 finalize_current_cmd(ring, last_start);
408 418
409 /* needs to be after get_cmd() as that could create bos/cmds table: */ 419 /* needs to be after get_cmd() as that could create bos/cmds table: */
@@ -435,6 +445,10 @@ static int msm_ringbuffer_flush(struct fd_ringbuffer *ring, uint32_t *last_start
435 struct msm_cmd *msm_cmd = msm_ring->cmds[i]; 445 struct msm_cmd *msm_cmd = msm_ring->cmds[i];
436 msm_cmd->ring->last_timestamp = req.fence; 446 msm_cmd->ring->last_timestamp = req.fence;
437 } 447 }
448
449 if (out_fence_fd) {
450 *out_fence_fd = req.fence_fd;
451 }
438 } 452 }
439 453
440 flush_reset(ring); 454 flush_reset(ring);