From fd8700b793c649d12c767d541a0398dfc81ceba1 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Fri, 28 Jun 2024 09:17:56 +0200 Subject: [PATCH] panvk: Rename the error labels in create_device() It's usually clearer to describe what the error unwinding entrypoint does than which type of error it's supposed to handle, because some entrypoints can be called from different error paths. Signed-off-by: Boris Brezillon Reviewed-by: Mary Guillemard Part-of: --- src/panfrost/vulkan/panvk_vX_device.c | 28 +++++++++++++-------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/panfrost/vulkan/panvk_vX_device.c b/src/panfrost/vulkan/panvk_vX_device.c index 5504015f403..b4221af1bd3 100644 --- a/src/panfrost/vulkan/panvk_vX_device.c +++ b/src/panfrost/vulkan/panvk_vX_device.c @@ -131,10 +131,8 @@ panvk_per_arch(create_device)(struct panvk_physical_device *physical_device, result = vk_device_init(&device->vk, &physical_device->vk, &dispatch_table, pCreateInfo, pAllocator); - if (result != VK_SUCCESS) { - vk_free(&device->vk.alloc, device); - return result; - } + if (result != VK_SUCCESS) + goto err_free_dev; /* Must be done after vk_device_init() because this function memset(0) the * whole struct. @@ -154,7 +152,7 @@ panvk_per_arch(create_device)(struct panvk_physical_device *physical_device, if (!device->kmod.dev) { result = vk_errorf(instance, panvk_errno_to_vk_error(), "cannot create device"); - goto fail_dev; + goto err_free_dev; } if (instance->debug_flags & @@ -175,7 +173,7 @@ panvk_per_arch(create_device)(struct panvk_physical_device *physical_device, if (!device->kmod.vm) { result = vk_error(physical_device, VK_ERROR_OUT_OF_HOST_MEMORY); - goto fail_vm; + goto err_destroy_kdev; } panvk_device_init_mempools(device); @@ -187,7 +185,7 @@ panvk_per_arch(create_device)(struct panvk_physical_device *physical_device, if (!device->tiler_heap) { result = vk_error(physical_device, VK_ERROR_OUT_OF_HOST_MEMORY); - goto fail_priv_bo; + goto err_free_priv_bos; } device->sample_positions = @@ -196,7 +194,7 @@ panvk_per_arch(create_device)(struct panvk_physical_device *physical_device, if (!device->sample_positions) { result = vk_error(physical_device, VK_ERROR_OUT_OF_HOST_MEMORY); - goto fail_priv_bo; + goto err_free_priv_bos; } panfrost_upload_sample_positions(device->sample_positions->addr.host); @@ -206,7 +204,7 @@ panvk_per_arch(create_device)(struct panvk_physical_device *physical_device, result = panvk_per_arch(blend_shader_cache_init)(device); if (result != VK_SUCCESS) - goto fail_priv_bo; + goto err_free_priv_bos; panvk_per_arch(meta_init)(device); @@ -220,7 +218,7 @@ panvk_per_arch(create_device)(struct panvk_physical_device *physical_device, VK_SYSTEM_ALLOCATION_SCOPE_DEVICE); if (!device->queues[qfi]) { result = VK_ERROR_OUT_OF_HOST_MEMORY; - goto fail; + goto err_finish_queues; } memset(device->queues[qfi], 0, @@ -232,14 +230,14 @@ panvk_per_arch(create_device)(struct panvk_physical_device *physical_device, result = panvk_per_arch(queue_init)(device, &device->queues[qfi][q], q, queue_create); if (result != VK_SUCCESS) - goto fail; + goto err_finish_queues; } } *pDevice = panvk_device_to_handle(device); return VK_SUCCESS; -fail: +err_finish_queues: for (unsigned i = 0; i < PANVK_MAX_QUEUE_FAMILIES; i++) { for (unsigned q = 0; q < device->queue_count[i]; q++) panvk_queue_finish(&device->queues[i][q]); @@ -250,16 +248,16 @@ fail: panvk_per_arch(meta_cleanup)(device); panvk_per_arch(blend_shader_cache_cleanup)(device); -fail_priv_bo: +err_free_priv_bos: panvk_priv_bo_unref(device->sample_positions); panvk_priv_bo_unref(device->tiler_heap); panvk_device_cleanup_mempools(device); pan_kmod_vm_destroy(device->kmod.vm); -fail_vm: +err_destroy_kdev: pan_kmod_dev_destroy(device->kmod.dev); -fail_dev: +err_free_dev: vk_free(&device->vk.alloc, device); return result; }