From 10a631f767ab4a4cba52ce1a58a9e14c9db0288b Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Thu, 4 Apr 2024 11:28:43 +0200 Subject: [PATCH] panvk: Re-order things in panvk_physical_device_init() We need to know the GPU architecture when we initialize the physical device properties/features. This implies creating the kmod device and querying its properties early. While at it, simplify the error path so we just have one entry point. Signed-off-by: Boris Brezillon Reviewed-by: Mary Guillemard Part-of: --- src/panfrost/vulkan/panvk_physical_device.c | 36 ++++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/panfrost/vulkan/panvk_physical_device.c b/src/panfrost/vulkan/panvk_physical_device.c index 3f22a5730d4..58854f2b33e 100644 --- a/src/panfrost/vulkan/panvk_physical_device.c +++ b/src/panfrost/vulkan/panvk_physical_device.c @@ -271,6 +271,18 @@ panvk_physical_device_init(struct panvk_physical_device *device, if (instance->debug_flags & PANVK_DEBUG_STARTUP) vk_logi(VK_LOG_NO_OBJS(instance), "Found compatible device '%s'.", path); + device->kmod.dev = pan_kmod_dev_create(fd, PAN_KMOD_DEV_FLAG_OWNS_FD, + &instance->kmod.allocator); + pan_kmod_dev_query_props(device->kmod.dev, &device->kmod.props); + + unsigned arch = pan_arch(device->kmod.props.gpu_prod_id); + + if (arch <= 5 || arch >= 8) { + result = vk_errorf(instance, VK_ERROR_INCOMPATIBLE_DRIVER, + "%s not supported", device->model->name); + goto fail; + } + struct vk_device_extension_table supported_extensions; get_device_extensions(device, &supported_extensions); @@ -301,30 +313,18 @@ panvk_physical_device_init(struct panvk_physical_device *device, device->master_fd = master_fd; - device->kmod.dev = pan_kmod_dev_create(fd, PAN_KMOD_DEV_FLAG_OWNS_FD, - &instance->kmod.allocator); - pan_kmod_dev_query_props(device->kmod.dev, &device->kmod.props); - - unsigned arch = pan_arch(device->kmod.props.gpu_prod_id); - device->model = panfrost_get_model(device->kmod.props.gpu_prod_id, device->kmod.props.gpu_variant); device->formats.all = panfrost_format_table(arch); device->formats.blendable = panfrost_blendable_format_table(arch); - if (arch <= 5 || arch >= 8) { - result = vk_errorf(instance, VK_ERROR_INCOMPATIBLE_DRIVER, - "%s not supported", device->model->name); - goto fail; - } - memset(device->name, 0, sizeof(device->name)); sprintf(device->name, "%s", device->model->name); if (get_cache_uuid(device->kmod.props.gpu_prod_id, device->cache_uuid)) { result = vk_errorf(instance, VK_ERROR_INITIALIZATION_FAILED, "cannot generate UUID"); - goto fail_close_device; + goto fail; } vk_warn_non_conformant_implementation("panvk"); @@ -346,14 +346,18 @@ panvk_physical_device_init(struct panvk_physical_device *device, result = panvk_wsi_init(device); if (result != VK_SUCCESS) { vk_error(instance, result); - goto fail_close_device; + goto fail; } return VK_SUCCESS; -fail_close_device: - pan_kmod_dev_destroy(device->kmod.dev); fail: + if (device->vk.instance) + vk_physical_device_finish(&device->vk); + + if (device->kmod.dev) + pan_kmod_dev_destroy(device->kmod.dev); + if (fd != -1) close(fd); if (master_fd != -1)