aboutsummaryrefslogtreecommitdiffstats
path: root/src/freedreno
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2019-01-10 14:07:50 -0800
committerChia-I Wu <[email protected]>2019-03-11 10:01:41 -0700
commit2e684cb80000f5e615524f538358e0321d18e3e8 (patch)
treef97197807183163004dca1f58aa67a765c9c0da3 /src/freedreno
parentb7a6a80e6c66b8bb91dcadd9a868c46fc138b26b (diff)
turnip: preliminary support for tu_QueueWaitIdle
This creates a new fd on each queue submit. I do not go with DRM_IOCTL_MSM_WAIT_FENCE solely because the path is marked legacy. Otherwise, we can use the fence id rather than requesting a fence fd until external fences are supported and enabled.
Diffstat (limited to 'src/freedreno')
-rw-r--r--src/freedreno/vulkan/tu_device.c33
-rw-r--r--src/freedreno/vulkan/tu_private.h1
2 files changed, 33 insertions, 1 deletions
diff --git a/src/freedreno/vulkan/tu_device.c b/src/freedreno/vulkan/tu_device.c
index d5a65aadf53..11d200e2f03 100644
--- a/src/freedreno/vulkan/tu_device.c
+++ b/src/freedreno/vulkan/tu_device.c
@@ -28,6 +28,7 @@
#include "tu_private.h"
#include <fcntl.h>
+#include <libsync.h>
#include <stdbool.h>
#include <string.h>
#include <sys/mman.h>
@@ -953,12 +954,17 @@ tu_queue_init(struct tu_device *device,
if (ret)
return VK_ERROR_INITIALIZATION_FAILED;
+ queue->submit_fence_fd = -1;
+
return VK_SUCCESS;
}
static void
tu_queue_finish(struct tu_queue *queue)
{
+ if (queue->submit_fence_fd >= 0) {
+ close(queue->submit_fence_fd);
+ }
tu_drm_submitqueue_close(queue->device, queue->msm_queue_id);
}
@@ -1166,6 +1172,7 @@ tu_QueueSubmit(VkQueue _queue,
for (uint32_t i = 0; i < submitCount; ++i) {
const VkSubmitInfo *submit = pSubmits + i;
+ const bool last_submit = (i == submitCount - 1);
struct tu_bo_list bo_list;
tu_bo_list_init(&bo_list);
@@ -1199,8 +1206,13 @@ tu_QueueSubmit(VkQueue _queue,
bos[i].presumed = 0;
}
+ uint32_t flags = MSM_PIPE_3D0;
+ if (last_submit) {
+ flags |= MSM_SUBMIT_FENCE_FD_OUT;
+ }
+
struct drm_msm_gem_submit req = {
- .flags = MSM_PIPE_3D0,
+ .flags = flags,
.queueid = queue->msm_queue_id,
.bos = (uint64_t)(uintptr_t)bos,
.nr_bos = bo_list.count,
@@ -1217,6 +1229,14 @@ tu_QueueSubmit(VkQueue _queue,
}
tu_bo_list_destroy(&bo_list);
+
+ if (last_submit) {
+ /* no need to merge fences as queue execution is serialized */
+ if (queue->submit_fence_fd >= 0) {
+ close(queue->submit_fence_fd);
+ }
+ queue->submit_fence_fd = req.fence_fd;
+ }
}
return VK_SUCCESS;
}
@@ -1224,6 +1244,17 @@ tu_QueueSubmit(VkQueue _queue,
VkResult
tu_QueueWaitIdle(VkQueue _queue)
{
+ TU_FROM_HANDLE(tu_queue, queue, _queue);
+
+ if (queue->submit_fence_fd >= 0) {
+ int ret = sync_wait(queue->submit_fence_fd, -1);
+ if (ret)
+ tu_loge("sync_wait on fence fd %d failed", queue->submit_fence_fd);
+
+ close(queue->submit_fence_fd);
+ queue->submit_fence_fd = -1;
+ }
+
return VK_SUCCESS;
}
diff --git a/src/freedreno/vulkan/tu_private.h b/src/freedreno/vulkan/tu_private.h
index 4602628169e..53f493a61aa 100644
--- a/src/freedreno/vulkan/tu_private.h
+++ b/src/freedreno/vulkan/tu_private.h
@@ -401,6 +401,7 @@ struct tu_queue
VkDeviceQueueCreateFlags flags;
uint32_t msm_queue_id;
+ int submit_fence_fd;
};
struct tu_device