Skip to content

Commit 78ec187

Browse files
pH5lynxeye-dev
authored andcommitted
drm/etnaviv: submit support for out-fences
Based on commit 4cd0945 ("drm/msm: submit support for out-fences"). We increment the minor driver version so userspace can detect explicit fence support. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Lucas Stach <l.stach@pengutronix.de> --- v3: Changed to work with fence returned from GPU submit.
1 parent 6e2b98c commit 78ec187

3 files changed

Lines changed: 33 additions & 3 deletions

File tree

‎drivers/gpu/drm/etnaviv/etnaviv_drv.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ static struct drm_driver etnaviv_drm_driver = {
512512
.desc = "etnaviv DRM",
513513
.date = "20151214",
514514
.major = 1,
515-
.minor = 0,
515+
.minor = 1,
516516
};
517517

518518
/*

‎drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,8 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
309309
struct etnaviv_cmdbuf *cmdbuf;
310310
struct etnaviv_gpu *gpu;
311311
struct dma_fence *in_fence = NULL;
312+
struct sync_file *sync_file = NULL;
313+
int out_fence_fd = -1;
312314
void *stream;
313315
int ret;
314316

@@ -376,6 +378,14 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
376378
goto err_submit_cmds;
377379
}
378380

381+
if (args->flags & ETNA_SUBMIT_FENCE_FD_OUT) {
382+
out_fence_fd = get_unused_fd_flags(O_CLOEXEC);
383+
if (out_fence_fd < 0) {
384+
ret = out_fence_fd;
385+
goto err_submit_cmds;
386+
}
387+
}
388+
379389
submit = submit_create(dev, gpu, args->nr_bos);
380390
if (!submit) {
381391
ret = -ENOMEM;
@@ -436,6 +446,22 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
436446
if (ret == 0)
437447
cmdbuf = NULL;
438448

449+
if (args->flags & ETNA_SUBMIT_FENCE_FD_OUT) {
450+
/*
451+
* This can be improved: ideally we want to allocate the sync
452+
* file before kicking off the GPU job and just attach the
453+
* fence to the sync file here, eliminating the ENOMEM
454+
* possibility at this stage.
455+
*/
456+
sync_file = sync_file_create(submit->fence);
457+
if (!sync_file) {
458+
ret = -ENOMEM;
459+
goto out;
460+
}
461+
fd_install(out_fence_fd, sync_file->file);
462+
}
463+
464+
args->fence_fd = out_fence_fd;
439465
args->fence = submit->fence->seqno;
440466

441467
out:
@@ -455,6 +481,8 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
455481
submit_cleanup(submit);
456482

457483
err_submit_cmds:
484+
if (ret && (out_fence_fd >= 0))
485+
put_unused_fd(out_fence_fd);
458486
/* if we still own the cmdbuf */
459487
if (cmdbuf)
460488
etnaviv_cmdbuf_free(cmdbuf);

‎include/uapi/drm/etnaviv_drm.h‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,10 @@ struct drm_etnaviv_gem_submit_bo {
156156
*/
157157
#define ETNA_SUBMIT_NO_IMPLICIT 0x0001
158158
#define ETNA_SUBMIT_FENCE_FD_IN 0x0002
159+
#define ETNA_SUBMIT_FENCE_FD_OUT 0x0004
159160
#define ETNA_SUBMIT_FLAGS (ETNA_SUBMIT_NO_IMPLICIT | \
160-
ETNA_SUBMIT_FENCE_FD_IN)
161+
ETNA_SUBMIT_FENCE_FD_IN | \
162+
ETNA_SUBMIT_FENCE_FD_OUT)
161163
#define ETNA_PIPE_3D 0x00
162164
#define ETNA_PIPE_2D 0x01
163165
#define ETNA_PIPE_VG 0x02
@@ -172,7 +174,7 @@ struct drm_etnaviv_gem_submit {
172174
__u64 relocs; /* in, ptr to array of submit_reloc's */
173175
__u64 stream; /* in, ptr to cmdstream */
174176
__u32 flags; /* in, mask of ETNA_SUBMIT_x */
175-
__s32 fence_fd; /* in, fence fd (see ETNA_SUBMIT_FENCE_FD_IN) */
177+
__s32 fence_fd; /* in/out, fence fd (see ETNA_SUBMIT_FENCE_FD_x) */
176178
};
177179

178180
/* The normal way to synchronize with the GPU is just to CPU_PREP on

0 commit comments

Comments
 (0)