From: Jonathan Marek Date: Mon, 14 Oct 2019 15:24:27 +0000 (-0400) Subject: turnip: fix segmentation fault in events X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=eef195c9cc90076702b9b87c290abb98d8da4d8d;p=mesa.git turnip: fix segmentation fault in events Signed-off-by: Jonathan Marek Reviewed-by: Kristian H. Kristensen --- diff --git a/src/freedreno/vulkan/tu_device.c b/src/freedreno/vulkan/tu_device.c index 54988ac83cd..9d1169d6a66 100644 --- a/src/freedreno/vulkan/tu_device.c +++ b/src/freedreno/vulkan/tu_device.c @@ -1732,9 +1732,23 @@ tu_CreateEvent(VkDevice _device, if (!event) return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); + VkResult result = tu_bo_init_new(device, &event->bo, 0x1000); + if (result != VK_SUCCESS) + goto fail_alloc; + + result = tu_bo_map(device, &event->bo); + if (result != VK_SUCCESS) + goto fail_map; + *pEvent = tu_event_to_handle(event); return VK_SUCCESS; + +fail_map: + tu_bo_finish(device, &event->bo); +fail_alloc: + vk_free2(&device->alloc, pAllocator, event); + return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); } void @@ -1755,7 +1769,7 @@ tu_GetEventStatus(VkDevice _device, VkEvent _event) { TU_FROM_HANDLE(tu_event, event, _event); - if (*event->map == 1) + if (*(uint64_t*) event->bo.map == 1) return VK_EVENT_SET; return VK_EVENT_RESET; } @@ -1764,7 +1778,7 @@ VkResult tu_SetEvent(VkDevice _device, VkEvent _event) { TU_FROM_HANDLE(tu_event, event, _event); - *event->map = 1; + *(uint64_t*) event->bo.map = 1; return VK_SUCCESS; } @@ -1773,7 +1787,7 @@ VkResult tu_ResetEvent(VkDevice _device, VkEvent _event) { TU_FROM_HANDLE(tu_event, event, _event); - *event->map = 0; + *(uint64_t*) event->bo.map = 0; return VK_SUCCESS; } diff --git a/src/freedreno/vulkan/tu_private.h b/src/freedreno/vulkan/tu_private.h index ee00befd976..2537c3df9f9 100644 --- a/src/freedreno/vulkan/tu_private.h +++ b/src/freedreno/vulkan/tu_private.h @@ -981,7 +981,7 @@ tu_unaligned_dispatch(struct tu_cmd_buffer *cmd_buffer, struct tu_event { - uint64_t *map; + struct tu_bo bo; }; struct tu_shader_module;