From 08add9f61c96f749ae5830545ff91be195610daf Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 17 Sep 2020 09:13:10 -0700 Subject: [PATCH] turnip/kgsl: Associate fences with submits. This fixes all the I was seeing in the multiview tests. Part-of: --- src/freedreno/vulkan/tu_kgsl.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/src/freedreno/vulkan/tu_kgsl.c b/src/freedreno/vulkan/tu_kgsl.c index d017ceb..f31a33a 100644 --- a/src/freedreno/vulkan/tu_kgsl.c +++ b/src/freedreno/vulkan/tu_kgsl.c @@ -221,6 +221,7 @@ tu_QueueSubmit(VkQueue _queue, VkFence _fence) { TU_FROM_HANDLE(tu_queue, queue, _queue); + VkResult result = VK_SUCCESS; uint32_t max_entry_count = 0; for (uint32_t i = 0; i < submitCount; ++i) { @@ -271,18 +272,35 @@ tu_QueueSubmit(VkQueue _queue, int ret = safe_ioctl(queue->device->physical_device->local_fd, IOCTL_KGSL_GPU_COMMAND, &req); if (ret) { - fprintf(stderr, "submit failed: %s\n", strerror(errno)); - abort(); + result = tu_device_set_lost(queue->device, + "submit failed: %s\n", strerror(errno)); + goto fail; } -#if 0 + /* no need to merge fences as queue execution is serialized */ if (i == submitCount - 1) { - /* no need to merge fences as queue execution is serialized */ - tu_fence_update_fd(&queue->submit_fence, req.fence_fd); + int fd; + struct kgsl_timestamp_event event = { + .type = KGSL_TIMESTAMP_EVENT_FENCE, + .context_id = queue->msm_queue_id, + .timestamp = req.timestamp, + .priv = &fd, + .len = sizeof(fd), + }; + + int ret = safe_ioctl(queue->device->physical_device->local_fd, + IOCTL_KGSL_TIMESTAMP_EVENT, &event); + if (ret != 0) { + result = tu_device_set_lost(queue->device, + "Failed to create sync file for timestamp: %s\n", + strerror(errno)); + goto fail; + } + + tu_fence_update_fd(&queue->submit_fence, fd); } -#endif } - +fail: vk_free(&queue->device->vk.alloc, cmds); if (_fence != VK_NULL_HANDLE) { @@ -290,7 +308,7 @@ tu_QueueSubmit(VkQueue _queue, tu_fence_copy(fence, &queue->submit_fence); } - return VK_SUCCESS; + return result; } VkResult -- 2.7.4