提交 9ad59fea 编写于 作者: P Philipp Zabel 提交者: Lucas Stach

drm/etnaviv: submit support for in-fences

Loosely based on commit f0a42bb5 ("drm/msm: submit support for
in-fences"). Unfortunately, struct drm_etnaviv_gem_submit doesn't have
a flags field yet, so we have to extend the structure and trust that
drm_ioctl will clear the flags for us if an older userspace only submits
part of the struct.
Signed-off-by: NPhilipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: NGustavo Padovan <gustavo.padovan@collabora.com>
Reviewed-by: NSumit Semwal <sumit.semwal@linaro.org>
Reviewed-by: NLucas Stach <l.stach@pengutronix.de>
Signed-off-by: NLucas Stach <l.stach@pengutronix.de>
上级 bcdfb5e5
...@@ -5,6 +5,7 @@ config DRM_ETNAVIV ...@@ -5,6 +5,7 @@ config DRM_ETNAVIV
depends on ARCH_MXC || ARCH_DOVE || (ARM && COMPILE_TEST) depends on ARCH_MXC || ARCH_DOVE || (ARM && COMPILE_TEST)
depends on MMU depends on MMU
select SHMEM select SHMEM
select SYNC_FILE
select TMPFS select TMPFS
select IOMMU_API select IOMMU_API
select IOMMU_SUPPORT select IOMMU_SUPPORT
......
...@@ -107,6 +107,7 @@ struct etnaviv_gem_submit { ...@@ -107,6 +107,7 @@ struct etnaviv_gem_submit {
u32 fence; u32 fence;
unsigned int nr_bos; unsigned int nr_bos;
struct etnaviv_gem_submit_bo bos[0]; struct etnaviv_gem_submit_bo bos[0];
u32 flags;
}; };
int etnaviv_gem_wait_bo(struct etnaviv_gpu *gpu, struct drm_gem_object *obj, int etnaviv_gem_wait_bo(struct etnaviv_gpu *gpu, struct drm_gem_object *obj,
......
...@@ -14,7 +14,9 @@ ...@@ -14,7 +14,9 @@
* this program. If not, see <http://www.gnu.org/licenses/>. * this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <linux/dma-fence-array.h>
#include <linux/reservation.h> #include <linux/reservation.h>
#include <linux/sync_file.h>
#include "etnaviv_cmdbuf.h" #include "etnaviv_cmdbuf.h"
#include "etnaviv_drv.h" #include "etnaviv_drv.h"
#include "etnaviv_gpu.h" #include "etnaviv_gpu.h"
...@@ -169,8 +171,10 @@ static int submit_fence_sync(const struct etnaviv_gem_submit *submit) ...@@ -169,8 +171,10 @@ static int submit_fence_sync(const struct etnaviv_gem_submit *submit)
for (i = 0; i < submit->nr_bos; i++) { for (i = 0; i < submit->nr_bos; i++) {
struct etnaviv_gem_object *etnaviv_obj = submit->bos[i].obj; struct etnaviv_gem_object *etnaviv_obj = submit->bos[i].obj;
bool write = submit->bos[i].flags & ETNA_SUBMIT_BO_WRITE; bool write = submit->bos[i].flags & ETNA_SUBMIT_BO_WRITE;
bool explicit = !(submit->flags & ETNA_SUBMIT_NO_IMPLICIT);
ret = etnaviv_gpu_fence_sync_obj(etnaviv_obj, context, write); ret = etnaviv_gpu_fence_sync_obj(etnaviv_obj, context, write,
explicit);
if (ret) if (ret)
break; break;
} }
...@@ -303,6 +307,7 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data, ...@@ -303,6 +307,7 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
struct etnaviv_gem_submit *submit; struct etnaviv_gem_submit *submit;
struct etnaviv_cmdbuf *cmdbuf; struct etnaviv_cmdbuf *cmdbuf;
struct etnaviv_gpu *gpu; struct etnaviv_gpu *gpu;
struct dma_fence *in_fence = NULL;
void *stream; void *stream;
int ret; int ret;
...@@ -326,6 +331,11 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data, ...@@ -326,6 +331,11 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
return -EINVAL; return -EINVAL;
} }
if (args->flags & ~ETNA_SUBMIT_FLAGS) {
DRM_ERROR("invalid flags: 0x%x\n", args->flags);
return -EINVAL;
}
/* /*
* Copy the command submission and bo array to kernel space in * Copy the command submission and bo array to kernel space in
* one go, and do this outside of any locks. * one go, and do this outside of any locks.
...@@ -371,6 +381,8 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data, ...@@ -371,6 +381,8 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
goto err_submit_cmds; goto err_submit_cmds;
} }
submit->flags = args->flags;
ret = submit_lookup_objects(submit, file, bos, args->nr_bos); ret = submit_lookup_objects(submit, file, bos, args->nr_bos);
if (ret) if (ret)
goto err_submit_objects; goto err_submit_objects;
...@@ -385,6 +397,24 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data, ...@@ -385,6 +397,24 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
goto err_submit_objects; goto err_submit_objects;
} }
if (args->flags & ETNA_SUBMIT_FENCE_FD_IN) {
in_fence = sync_file_get_fence(args->fence_fd);
if (!in_fence) {
ret = -EINVAL;
goto err_submit_objects;
}
/*
* Wait if the fence is from a foreign context, or if the fence
* array contains any fence from a foreign context.
*/
if (!dma_fence_match_context(in_fence, gpu->fence_context)) {
ret = dma_fence_wait(in_fence, true);
if (ret)
goto err_submit_objects;
}
}
ret = submit_fence_sync(submit); ret = submit_fence_sync(submit);
if (ret) if (ret)
goto err_submit_objects; goto err_submit_objects;
...@@ -419,6 +449,8 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data, ...@@ -419,6 +449,8 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
flush_workqueue(priv->wq); flush_workqueue(priv->wq);
err_submit_objects: err_submit_objects:
if (in_fence)
dma_fence_put(in_fence);
submit_cleanup(submit); submit_cleanup(submit);
err_submit_cmds: err_submit_cmds:
......
...@@ -1077,7 +1077,7 @@ static struct dma_fence *etnaviv_gpu_fence_alloc(struct etnaviv_gpu *gpu) ...@@ -1077,7 +1077,7 @@ static struct dma_fence *etnaviv_gpu_fence_alloc(struct etnaviv_gpu *gpu)
} }
int etnaviv_gpu_fence_sync_obj(struct etnaviv_gem_object *etnaviv_obj, int etnaviv_gpu_fence_sync_obj(struct etnaviv_gem_object *etnaviv_obj,
unsigned int context, bool exclusive) unsigned int context, bool exclusive, bool explicit)
{ {
struct reservation_object *robj = etnaviv_obj->resv; struct reservation_object *robj = etnaviv_obj->resv;
struct reservation_object_list *fobj; struct reservation_object_list *fobj;
...@@ -1090,6 +1090,9 @@ int etnaviv_gpu_fence_sync_obj(struct etnaviv_gem_object *etnaviv_obj, ...@@ -1090,6 +1090,9 @@ int etnaviv_gpu_fence_sync_obj(struct etnaviv_gem_object *etnaviv_obj,
return ret; return ret;
} }
if (explicit)
return 0;
/* /*
* If we have any shared fences, then the exclusive fence * If we have any shared fences, then the exclusive fence
* should be ignored as it will already have been signalled. * should be ignored as it will already have been signalled.
......
...@@ -183,7 +183,7 @@ int etnaviv_gpu_debugfs(struct etnaviv_gpu *gpu, struct seq_file *m); ...@@ -183,7 +183,7 @@ int etnaviv_gpu_debugfs(struct etnaviv_gpu *gpu, struct seq_file *m);
#endif #endif
int etnaviv_gpu_fence_sync_obj(struct etnaviv_gem_object *etnaviv_obj, int etnaviv_gpu_fence_sync_obj(struct etnaviv_gem_object *etnaviv_obj,
unsigned int context, bool exclusive); unsigned int context, bool exclusive, bool implicit);
void etnaviv_gpu_retire(struct etnaviv_gpu *gpu); void etnaviv_gpu_retire(struct etnaviv_gpu *gpu);
int etnaviv_gpu_wait_fence_interruptible(struct etnaviv_gpu *gpu, int etnaviv_gpu_wait_fence_interruptible(struct etnaviv_gpu *gpu,
......
...@@ -154,6 +154,10 @@ struct drm_etnaviv_gem_submit_bo { ...@@ -154,6 +154,10 @@ struct drm_etnaviv_gem_submit_bo {
* one or more cmdstream buffers. This allows for conditional execution * one or more cmdstream buffers. This allows for conditional execution
* (context-restore), and IB buffers needed for per tile/bin draw cmds. * (context-restore), and IB buffers needed for per tile/bin draw cmds.
*/ */
#define ETNA_SUBMIT_NO_IMPLICIT 0x0001
#define ETNA_SUBMIT_FENCE_FD_IN 0x0002
#define ETNA_SUBMIT_FLAGS (ETNA_SUBMIT_NO_IMPLICIT | \
ETNA_SUBMIT_FENCE_FD_IN)
#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
...@@ -167,6 +171,8 @@ struct drm_etnaviv_gem_submit { ...@@ -167,6 +171,8 @@ struct drm_etnaviv_gem_submit {
__u64 bos; /* in, ptr to array of submit_bo's */ __u64 bos; /* in, ptr to array of submit_bo's */
__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 */
__s32 fence_fd; /* in, fence fd (see ETNA_SUBMIT_FENCE_FD_IN) */
}; };
/* 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% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册