diff options
| -rw-r--r-- | drivers/gpu/drm/etnaviv/Kconfig | 1 | ||||
| -rw-r--r-- | drivers/gpu/drm/etnaviv/etnaviv_gem.h | 1 | ||||
| -rw-r--r-- | drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 34 | ||||
| -rw-r--r-- | drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 5 | ||||
| -rw-r--r-- | drivers/gpu/drm/etnaviv/etnaviv_gpu.h | 2 | ||||
| -rw-r--r-- | include/uapi/drm/etnaviv_drm.h | 6 |
6 files changed, 46 insertions, 3 deletions
diff --git a/drivers/gpu/drm/etnaviv/Kconfig b/drivers/gpu/drm/etnaviv/Kconfig index cc1731c5289c..71cee4e9fefb 100644 --- a/drivers/gpu/drm/etnaviv/Kconfig +++ b/drivers/gpu/drm/etnaviv/Kconfig | |||
| @@ -5,6 +5,7 @@ config DRM_ETNAVIV | |||
| 5 | depends on ARCH_MXC || ARCH_DOVE || (ARM && COMPILE_TEST) | 5 | depends on ARCH_MXC || ARCH_DOVE || (ARM && COMPILE_TEST) |
| 6 | depends on MMU | 6 | depends on MMU |
| 7 | select SHMEM | 7 | select SHMEM |
| 8 | select SYNC_FILE | ||
| 8 | select TMPFS | 9 | select TMPFS |
| 9 | select IOMMU_API | 10 | select IOMMU_API |
| 10 | select IOMMU_SUPPORT | 11 | select IOMMU_SUPPORT |
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.h b/drivers/gpu/drm/etnaviv/etnaviv_gem.h index e63ff116a3b3..120410d67eb5 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gem.h +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.h | |||
| @@ -107,6 +107,7 @@ struct etnaviv_gem_submit { | |||
| 107 | u32 fence; | 107 | u32 fence; |
| 108 | unsigned int nr_bos; | 108 | unsigned int nr_bos; |
| 109 | struct etnaviv_gem_submit_bo bos[0]; | 109 | struct etnaviv_gem_submit_bo bos[0]; |
| 110 | u32 flags; | ||
| 110 | }; | 111 | }; |
| 111 | 112 | ||
| 112 | int etnaviv_gem_wait_bo(struct etnaviv_gpu *gpu, struct drm_gem_object *obj, | 113 | int etnaviv_gem_wait_bo(struct etnaviv_gpu *gpu, struct drm_gem_object *obj, |
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c index 726090d7a6ac..fb8d5befbf4f 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | |||
| @@ -14,7 +14,9 @@ | |||
| 14 | * this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ | 15 | */ |
| 16 | 16 | ||
| 17 | #include <linux/dma-fence-array.h> | ||
| 17 | #include <linux/reservation.h> | 18 | #include <linux/reservation.h> |
| 19 | #include <linux/sync_file.h> | ||
| 18 | #include "etnaviv_cmdbuf.h" | 20 | #include "etnaviv_cmdbuf.h" |
| 19 | #include "etnaviv_drv.h" | 21 | #include "etnaviv_drv.h" |
| 20 | #include "etnaviv_gpu.h" | 22 | #include "etnaviv_gpu.h" |
| @@ -169,8 +171,10 @@ static int submit_fence_sync(const struct etnaviv_gem_submit *submit) | |||
| 169 | for (i = 0; i < submit->nr_bos; i++) { | 171 | for (i = 0; i < submit->nr_bos; i++) { |
| 170 | struct etnaviv_gem_object *etnaviv_obj = submit->bos[i].obj; | 172 | struct etnaviv_gem_object *etnaviv_obj = submit->bos[i].obj; |
| 171 | bool write = submit->bos[i].flags & ETNA_SUBMIT_BO_WRITE; | 173 | bool write = submit->bos[i].flags & ETNA_SUBMIT_BO_WRITE; |
| 174 | bool explicit = !(submit->flags & ETNA_SUBMIT_NO_IMPLICIT); | ||
| 172 | 175 | ||
| 173 | ret = etnaviv_gpu_fence_sync_obj(etnaviv_obj, context, write); | 176 | ret = etnaviv_gpu_fence_sync_obj(etnaviv_obj, context, write, |
| 177 | explicit); | ||
| 174 | if (ret) | 178 | if (ret) |
| 175 | break; | 179 | break; |
| 176 | } | 180 | } |
| @@ -303,6 +307,7 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data, | |||
| 303 | struct etnaviv_gem_submit *submit; | 307 | struct etnaviv_gem_submit *submit; |
| 304 | struct etnaviv_cmdbuf *cmdbuf; | 308 | struct etnaviv_cmdbuf *cmdbuf; |
| 305 | struct etnaviv_gpu *gpu; | 309 | struct etnaviv_gpu *gpu; |
| 310 | struct dma_fence *in_fence = NULL; | ||
| 306 | void *stream; | 311 | void *stream; |
| 307 | int ret; | 312 | int ret; |
| 308 | 313 | ||
| @@ -326,6 +331,11 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data, | |||
| 326 | return -EINVAL; | 331 | return -EINVAL; |
| 327 | } | 332 | } |
| 328 | 333 | ||
| 334 | if (args->flags & ~ETNA_SUBMIT_FLAGS) { | ||
| 335 | DRM_ERROR("invalid flags: 0x%x\n", args->flags); | ||
| 336 | return -EINVAL; | ||
| 337 | } | ||
| 338 | |||
| 329 | /* | 339 | /* |
| 330 | * Copy the command submission and bo array to kernel space in | 340 | * Copy the command submission and bo array to kernel space in |
| 331 | * one go, and do this outside of any locks. | 341 | * 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 | goto err_submit_cmds; | 381 | goto err_submit_cmds; |
| 372 | } | 382 | } |
| 373 | 383 | ||
| 384 | submit->flags = args->flags; | ||
| 385 | |||
| 374 | ret = submit_lookup_objects(submit, file, bos, args->nr_bos); | 386 | ret = submit_lookup_objects(submit, file, bos, args->nr_bos); |
| 375 | if (ret) | 387 | if (ret) |
| 376 | goto err_submit_objects; | 388 | goto err_submit_objects; |
| @@ -385,6 +397,24 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data, | |||
| 385 | goto err_submit_objects; | 397 | goto err_submit_objects; |
| 386 | } | 398 | } |
| 387 | 399 | ||
| 400 | if (args->flags & ETNA_SUBMIT_FENCE_FD_IN) { | ||
| 401 | in_fence = sync_file_get_fence(args->fence_fd); | ||
| 402 | if (!in_fence) { | ||
| 403 | ret = -EINVAL; | ||
| 404 | goto err_submit_objects; | ||
| 405 | } | ||
| 406 | |||
| 407 | /* | ||
| 408 | * Wait if the fence is from a foreign context, or if the fence | ||
| 409 | * array contains any fence from a foreign context. | ||
| 410 | */ | ||
| 411 | if (!dma_fence_match_context(in_fence, gpu->fence_context)) { | ||
| 412 | ret = dma_fence_wait(in_fence, true); | ||
| 413 | if (ret) | ||
| 414 | goto err_submit_objects; | ||
| 415 | } | ||
| 416 | } | ||
| 417 | |||
| 388 | ret = submit_fence_sync(submit); | 418 | ret = submit_fence_sync(submit); |
| 389 | if (ret) | 419 | if (ret) |
| 390 | goto err_submit_objects; | 420 | goto err_submit_objects; |
| @@ -419,6 +449,8 @@ out: | |||
| 419 | flush_workqueue(priv->wq); | 449 | flush_workqueue(priv->wq); |
| 420 | 450 | ||
| 421 | err_submit_objects: | 451 | err_submit_objects: |
| 452 | if (in_fence) | ||
| 453 | dma_fence_put(in_fence); | ||
| 422 | submit_cleanup(submit); | 454 | submit_cleanup(submit); |
| 423 | 455 | ||
| 424 | err_submit_cmds: | 456 | err_submit_cmds: |
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c index cab4cf546c17..68a4f59e4c22 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c | |||
| @@ -1077,7 +1077,7 @@ static struct dma_fence *etnaviv_gpu_fence_alloc(struct etnaviv_gpu *gpu) | |||
| 1077 | } | 1077 | } |
| 1078 | 1078 | ||
| 1079 | int etnaviv_gpu_fence_sync_obj(struct etnaviv_gem_object *etnaviv_obj, | 1079 | int etnaviv_gpu_fence_sync_obj(struct etnaviv_gem_object *etnaviv_obj, |
| 1080 | unsigned int context, bool exclusive) | 1080 | unsigned int context, bool exclusive, bool explicit) |
| 1081 | { | 1081 | { |
| 1082 | struct reservation_object *robj = etnaviv_obj->resv; | 1082 | struct reservation_object *robj = etnaviv_obj->resv; |
| 1083 | struct reservation_object_list *fobj; | 1083 | struct reservation_object_list *fobj; |
| @@ -1090,6 +1090,9 @@ int etnaviv_gpu_fence_sync_obj(struct etnaviv_gem_object *etnaviv_obj, | |||
| 1090 | return ret; | 1090 | return ret; |
| 1091 | } | 1091 | } |
| 1092 | 1092 | ||
| 1093 | if (explicit) | ||
| 1094 | return 0; | ||
| 1095 | |||
| 1093 | /* | 1096 | /* |
| 1094 | * If we have any shared fences, then the exclusive fence | 1097 | * If we have any shared fences, then the exclusive fence |
| 1095 | * should be ignored as it will already have been signalled. | 1098 | * should be ignored as it will already have been signalled. |
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.h b/drivers/gpu/drm/etnaviv/etnaviv_gpu.h index 6a1e68eec24c..9227a9740447 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.h +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.h | |||
| @@ -183,7 +183,7 @@ int etnaviv_gpu_debugfs(struct etnaviv_gpu *gpu, struct seq_file *m); | |||
| 183 | #endif | 183 | #endif |
| 184 | 184 | ||
| 185 | int etnaviv_gpu_fence_sync_obj(struct etnaviv_gem_object *etnaviv_obj, | 185 | int etnaviv_gpu_fence_sync_obj(struct etnaviv_gem_object *etnaviv_obj, |
| 186 | unsigned int context, bool exclusive); | 186 | unsigned int context, bool exclusive, bool implicit); |
| 187 | 187 | ||
| 188 | void etnaviv_gpu_retire(struct etnaviv_gpu *gpu); | 188 | void etnaviv_gpu_retire(struct etnaviv_gpu *gpu); |
| 189 | int etnaviv_gpu_wait_fence_interruptible(struct etnaviv_gpu *gpu, | 189 | int etnaviv_gpu_wait_fence_interruptible(struct etnaviv_gpu *gpu, |
diff --git a/include/uapi/drm/etnaviv_drm.h b/include/uapi/drm/etnaviv_drm.h index 2584c1cca42f..e9c388a1d8eb 100644 --- a/include/uapi/drm/etnaviv_drm.h +++ b/include/uapi/drm/etnaviv_drm.h | |||
| @@ -154,6 +154,10 @@ struct drm_etnaviv_gem_submit_bo { | |||
| 154 | * one or more cmdstream buffers. This allows for conditional execution | 154 | * one or more cmdstream buffers. This allows for conditional execution |
| 155 | * (context-restore), and IB buffers needed for per tile/bin draw cmds. | 155 | * (context-restore), and IB buffers needed for per tile/bin draw cmds. |
| 156 | */ | 156 | */ |
| 157 | #define ETNA_SUBMIT_NO_IMPLICIT 0x0001 | ||
| 158 | #define ETNA_SUBMIT_FENCE_FD_IN 0x0002 | ||
| 159 | #define ETNA_SUBMIT_FLAGS (ETNA_SUBMIT_NO_IMPLICIT | \ | ||
| 160 | ETNA_SUBMIT_FENCE_FD_IN) | ||
| 157 | #define ETNA_PIPE_3D 0x00 | 161 | #define ETNA_PIPE_3D 0x00 |
| 158 | #define ETNA_PIPE_2D 0x01 | 162 | #define ETNA_PIPE_2D 0x01 |
| 159 | #define ETNA_PIPE_VG 0x02 | 163 | #define ETNA_PIPE_VG 0x02 |
| @@ -167,6 +171,8 @@ struct drm_etnaviv_gem_submit { | |||
| 167 | __u64 bos; /* in, ptr to array of submit_bo's */ | 171 | __u64 bos; /* in, ptr to array of submit_bo's */ |
| 168 | __u64 relocs; /* in, ptr to array of submit_reloc's */ | 172 | __u64 relocs; /* in, ptr to array of submit_reloc's */ |
| 169 | __u64 stream; /* in, ptr to cmdstream */ | 173 | __u64 stream; /* in, ptr to cmdstream */ |
| 174 | __u32 flags; /* in, mask of ETNA_SUBMIT_x */ | ||
| 175 | __s32 fence_fd; /* in, fence fd (see ETNA_SUBMIT_FENCE_FD_IN) */ | ||
| 170 | }; | 176 | }; |
| 171 | 177 | ||
| 172 | /* The normal way to synchronize with the GPU is just to CPU_PREP on | 178 | /* The normal way to synchronize with the GPU is just to CPU_PREP on |
