tu: Free device->bo_idx and device->bo_list on init failure

Two related changes:

- in tu_device.c:tu_CreateDevice we need to free both pointers in the
  teardown path after tu_bo_finish(global_bo), which uses the pointers.
  They are allocated in the first call to tu_bo_init(), which happens
  when global_bo is allocated.

- in tu_drm.c:tu_bo_init we need to free bo_list if the bo_idx
  allocation fails. Convert to the goto teardown pattern as well.

Fixes the following dEQP-VK tests:
  dEQP-VK.api.device_init.create_instance_device_intentional_alloc_fail
  dEQP-VK.api.object_management.alloc_callback_fail.device
  dEQP-VK.api.object_management.alloc_callback_fail.device_group

Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12481>
This commit is contained in:
Matt Turner 2021-08-19 20:12:57 -07:00 committed by Marge Bot
parent 61c8e39649
commit e0bc11d9d2
3 changed files with 12 additions and 19 deletions

View File

@ -59,11 +59,6 @@ bypass-dEQP-GLES31.functional.blend_equation_advanced.msaa.overlay,Fail
bypass-dEQP-GLES31.functional.blend_equation_advanced.msaa.screen,Fail
bypass-dEQP-GLES31.functional.blend_equation_advanced.msaa.softlight,Fail
# "Fail (createInstance returned VK_ERROR_INITIALIZATION_FAILED)"
# happens inside the loader on anholt's debian system, and there are various
# likely-looking fixes in later versions of the loader.
dEQP-VK.api.device_init.create_instance_device_intentional_alloc_fail,Fail
# optimalTilingFeatures missing: VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT|VK_FORMAT_FEATURE_TRANSFER_SRC_BIT|VK_FORMAT_FEATURE_TRANSFER_DST_BIT|VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT
dEQP-VK.api.info.format_properties.g8_b8_r8_3plane_420_unorm,Fail
dEQP-VK.api.info.format_properties.g8_b8r8_2plane_420_unorm,Fail
@ -76,11 +71,6 @@ dEQP-VK.api.info.image_format_properties.2d.optimal.g8_b8r8_2plane_420_unorm,Fai
# "Mismatch between VkPhysicalDeviceProtectedMemoryProperties at vktApiFeatureInfo.cpp:4208"
dEQP-VK.api.info.get_physical_device_properties2.properties,Fail
# LEAK 1: REALLOCATION: original=0x0000000000000000, size=400, alignment=8, scope=3, returnedPtr=0x0000aaaaf6b61310
# ERROR: Found 1 memory leaks!
dEQP-VK.api.object_management.alloc_callback_fail.device,Fail
dEQP-VK.api.object_management.alloc_callback_fail.device_group,Fail
# "deqp-vk: ../src/freedreno/vulkan/tu_cs.h:186: tu_cs_reserve: Assertion `tu_cs_get_space(cs) >= reserved_size' failed."
# https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8841
dEQP-VK.spirv_assembly.instruction.compute.opphi.wide,Crash

View File

@ -1488,7 +1488,8 @@ fail_pipeline_cache:
tu_destroy_clear_blit_shaders(device);
fail_global_bo_map:
tu_bo_finish(device, &device->global_bo);
vk_free(&device->vk.alloc, device->bo_idx);
vk_free(&device->vk.alloc, device->bo_list);
fail_global_bo:
ir3_compiler_destroy(device->compiler);

View File

@ -246,10 +246,8 @@ tu_bo_init(struct tu_device *dev,
struct drm_msm_gem_submit_bo *new_ptr =
vk_realloc(&dev->vk.alloc, dev->bo_list, new_len * sizeof(*dev->bo_list),
8, VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
if (!new_ptr) {
tu_gem_close(dev, gem_handle);
return VK_ERROR_OUT_OF_HOST_MEMORY;
}
if (!new_ptr)
goto fail_bo_list;
dev->bo_list = new_ptr;
dev->bo_list_size = new_len;
@ -261,10 +259,8 @@ tu_bo_init(struct tu_device *dev,
uint32_t *new_ptr =
vk_realloc(&dev->vk.alloc, dev->bo_idx, new_len * sizeof(*dev->bo_idx),
8, VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
if (!new_ptr) {
tu_gem_close(dev, gem_handle);
return VK_ERROR_OUT_OF_HOST_MEMORY;
}
if (!new_ptr)
goto fail_bo_idx;
dev->bo_idx = new_ptr;
dev->bo_idx_size = new_len;
@ -280,6 +276,12 @@ tu_bo_init(struct tu_device *dev,
mtx_unlock(&dev->bo_mutex);
return VK_SUCCESS;
fail_bo_idx:
vk_free(&dev->vk.alloc, dev->bo_list);
fail_bo_list:
tu_gem_close(dev, gem_handle);
return VK_ERROR_OUT_OF_HOST_MEMORY;
}
VkResult