Commit 78ec187f authored by Philipp Zabel's avatar Philipp Zabel Committed by Lucas Stach

drm/etnaviv: submit support for out-fences

Based on commit 4cd09459 ("drm/msm: submit support for out-fences").
We increment the minor driver version so userspace can detect explicit
fence support.
Signed-off-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: default avatarLucas Stach <l.stach@pengutronix.de>
---
v3: Changed to work with fence returned from GPU submit.
parent 6e2b98cf
...@@ -512,7 +512,7 @@ static struct drm_driver etnaviv_drm_driver = { ...@@ -512,7 +512,7 @@ static struct drm_driver etnaviv_drm_driver = {
.desc = "etnaviv DRM", .desc = "etnaviv DRM",
.date = "20151214", .date = "20151214",
.major = 1, .major = 1,
.minor = 0, .minor = 1,
}; };
/* /*
......
...@@ -309,6 +309,8 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data, ...@@ -309,6 +309,8 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
struct etnaviv_cmdbuf *cmdbuf; struct etnaviv_cmdbuf *cmdbuf;
struct etnaviv_gpu *gpu; struct etnaviv_gpu *gpu;
struct dma_fence *in_fence = NULL; struct dma_fence *in_fence = NULL;
struct sync_file *sync_file = NULL;
int out_fence_fd = -1;
void *stream; void *stream;
int ret; int ret;
...@@ -376,6 +378,14 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data, ...@@ -376,6 +378,14 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
goto err_submit_cmds; goto err_submit_cmds;
} }
if (args->flags & ETNA_SUBMIT_FENCE_FD_OUT) {
out_fence_fd = get_unused_fd_flags(O_CLOEXEC);
if (out_fence_fd < 0) {
ret = out_fence_fd;
goto err_submit_cmds;
}
}
submit = submit_create(dev, gpu, args->nr_bos); submit = submit_create(dev, gpu, args->nr_bos);
if (!submit) { if (!submit) {
ret = -ENOMEM; ret = -ENOMEM;
...@@ -436,6 +446,22 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data, ...@@ -436,6 +446,22 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
if (ret == 0) if (ret == 0)
cmdbuf = NULL; cmdbuf = NULL;
if (args->flags & ETNA_SUBMIT_FENCE_FD_OUT) {
/*
* This can be improved: ideally we want to allocate the sync
* file before kicking off the GPU job and just attach the
* fence to the sync file here, eliminating the ENOMEM
* possibility at this stage.
*/
sync_file = sync_file_create(submit->fence);
if (!sync_file) {
ret = -ENOMEM;
goto out;
}
fd_install(out_fence_fd, sync_file->file);
}
args->fence_fd = out_fence_fd;
args->fence = submit->fence->seqno; args->fence = submit->fence->seqno;
out: out:
...@@ -455,6 +481,8 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data, ...@@ -455,6 +481,8 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
submit_cleanup(submit); submit_cleanup(submit);
err_submit_cmds: err_submit_cmds:
if (ret && (out_fence_fd >= 0))
put_unused_fd(out_fence_fd);
/* if we still own the cmdbuf */ /* if we still own the cmdbuf */
if (cmdbuf) if (cmdbuf)
etnaviv_cmdbuf_free(cmdbuf); etnaviv_cmdbuf_free(cmdbuf);
......
...@@ -156,8 +156,10 @@ struct drm_etnaviv_gem_submit_bo { ...@@ -156,8 +156,10 @@ struct drm_etnaviv_gem_submit_bo {
*/ */
#define ETNA_SUBMIT_NO_IMPLICIT 0x0001 #define ETNA_SUBMIT_NO_IMPLICIT 0x0001
#define ETNA_SUBMIT_FENCE_FD_IN 0x0002 #define ETNA_SUBMIT_FENCE_FD_IN 0x0002
#define ETNA_SUBMIT_FENCE_FD_OUT 0x0004
#define ETNA_SUBMIT_FLAGS (ETNA_SUBMIT_NO_IMPLICIT | \ #define ETNA_SUBMIT_FLAGS (ETNA_SUBMIT_NO_IMPLICIT | \
ETNA_SUBMIT_FENCE_FD_IN) ETNA_SUBMIT_FENCE_FD_IN | \
ETNA_SUBMIT_FENCE_FD_OUT)
#define ETNA_PIPE_3D 0x00 #define ETNA_PIPE_3D 0x00
#define ETNA_PIPE_2D 0x01 #define ETNA_PIPE_2D 0x01
#define ETNA_PIPE_VG 0x02 #define ETNA_PIPE_VG 0x02
...@@ -172,7 +174,7 @@ struct drm_etnaviv_gem_submit { ...@@ -172,7 +174,7 @@ struct drm_etnaviv_gem_submit {
__u64 relocs; /* in, ptr to array of submit_reloc's */ __u64 relocs; /* in, ptr to array of submit_reloc's */
__u64 stream; /* in, ptr to cmdstream */ __u64 stream; /* in, ptr to cmdstream */
__u32 flags; /* in, mask of ETNA_SUBMIT_x */ __u32 flags; /* in, mask of ETNA_SUBMIT_x */
__s32 fence_fd; /* in, fence fd (see ETNA_SUBMIT_FENCE_FD_IN) */ __s32 fence_fd; /* in/out, fence fd (see ETNA_SUBMIT_FENCE_FD_x) */
}; };
/* The normal way to synchronize with the GPU is just to CPU_PREP on /* The normal way to synchronize with the GPU is just to CPU_PREP on
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment