From 5b8b4f78782e5096dfe82f6b21c293577241ce5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Roberto=20de=20Souza?= Date: Tue, 4 Jun 2024 11:42:22 -0700 Subject: [PATCH] intel/dev: Add engine_class_supported_count to intel_device_info MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Next patch will need to frequently get the count of supported engine for compute and copy engines, so to reduce the overhead of doing KMD queries at every call here caching this information into intel_device_info struct. With that ANV and Iris would need to set this information as intel/dev can't depend on intel/common, so here adding a single function to update intel_device_info with all fields filled by intel/common functions. Reviewed-by: Lionel Landwerlin Signed-off-by: José Roberto de Souza Part-of: --- src/gallium/drivers/iris/iris_bufmgr.c | 16 +++----------- src/intel/common/intel_common.c | 30 ++++++++++++++++++++++++++ src/intel/common/intel_common.h | 10 +++++++++ src/intel/common/meson.build | 2 ++ src/intel/dev/intel_device_info.py | 3 ++- src/intel/vulkan/anv_device.c | 16 +++++--------- 6 files changed, 52 insertions(+), 25 deletions(-) create mode 100644 src/intel/common/intel_common.c create mode 100644 src/intel/common/intel_common.h diff --git a/src/gallium/drivers/iris/iris_bufmgr.c b/src/gallium/drivers/iris/iris_bufmgr.c index aed5596d51b..7d18320679c 100644 --- a/src/gallium/drivers/iris/iris_bufmgr.c +++ b/src/gallium/drivers/iris/iris_bufmgr.c @@ -51,6 +51,7 @@ #include "common/intel_mem.h" #include "c99_alloca.h" #include "dev/intel_debug.h" +#include "common/intel_common.h" #include "common/intel_gem.h" #include "dev/intel_device_info.h" #include "drm-uapi/dma-buf.h" @@ -233,7 +234,6 @@ struct iris_bufmgr { struct intel_bind_timeline bind_timeline; /* Xe only */ bool bo_reuse:1; bool use_global_vm:1; - bool compute_engine_supported:1; struct intel_aux_map_context *aux_map_ctx; @@ -2351,17 +2351,7 @@ iris_bufmgr_create(struct intel_device_info *devinfo, int fd, bool bo_reuse) iris_bufmgr_get_meminfo(bufmgr, devinfo); bufmgr->kmd_backend = iris_kmd_backend_get(devinfo->kmd_type); - struct intel_query_engine_info *engine_info; - engine_info = intel_engine_get_info(bufmgr->fd, bufmgr->devinfo.kmd_type); - bufmgr->devinfo.has_compute_engine = engine_info && - intel_engines_count(engine_info, - INTEL_ENGINE_CLASS_COMPUTE); - bufmgr->compute_engine_supported = bufmgr->devinfo.has_compute_engine && - intel_engines_supported_count(bufmgr->fd, - &bufmgr->devinfo, - engine_info, - INTEL_ENGINE_CLASS_COMPUTE); - free(engine_info); + intel_common_update_device_info(bufmgr->fd, devinfo); if (!iris_bufmgr_init_global_vm(bufmgr)) goto error_init_vm; @@ -2638,7 +2628,7 @@ iris_bufmgr_use_global_vm_id(struct iris_bufmgr *bufmgr) bool iris_bufmgr_compute_engine_supported(struct iris_bufmgr *bufmgr) { - return bufmgr->compute_engine_supported; + return bufmgr->devinfo.engine_class_supported_count[INTEL_ENGINE_CLASS_COMPUTE]; } /** diff --git a/src/intel/common/intel_common.c b/src/intel/common/intel_common.c new file mode 100644 index 00000000000..205e0392924 --- /dev/null +++ b/src/intel/common/intel_common.c @@ -0,0 +1,30 @@ +/* + * Copyright 2024 Intel Corporation + * SPDX-License-Identifier: MIT + */ + +#include "intel_common.h" + +#include "intel_engine.h" + +/* Updates intel_device_info fields that has dependencies on intel/common + * functions. + */ +void intel_common_update_device_info(int fd, struct intel_device_info *devinfo) +{ + struct intel_query_engine_info *engine_info; + enum intel_engine_class klass; + + engine_info = intel_engine_get_info(fd, devinfo->kmd_type); + if (!engine_info) + return; + + devinfo->has_compute_engine = intel_engines_count(engine_info, + INTEL_ENGINE_CLASS_COMPUTE); + + for (klass = 0; klass < INTEL_ENGINE_CLASS_INVALID; klass++) + devinfo->engine_class_supported_count[klass] = + intel_engines_supported_count(fd, devinfo, engine_info, klass); + + free(engine_info); +} diff --git a/src/intel/common/intel_common.h b/src/intel/common/intel_common.h new file mode 100644 index 00000000000..4edff1ad10f --- /dev/null +++ b/src/intel/common/intel_common.h @@ -0,0 +1,10 @@ +/* + * Copyright 2024 Intel Corporation + * SPDX-License-Identifier: MIT + */ + +#pragma once + +#include "dev/intel_device_info.h" + +void intel_common_update_device_info(int fd, struct intel_device_info *devinfo); diff --git a/src/intel/common/meson.build b/src/intel/common/meson.build index d306187727b..953ebf6b09b 100644 --- a/src/intel/common/meson.build +++ b/src/intel/common/meson.build @@ -36,6 +36,8 @@ files_libintel_common = files( 'intel_bind_timeline.c', 'intel_bind_timeline.h', 'intel_buffer_alloc.h', + 'intel_common.c', + 'intel_common.h', 'intel_compute_slm.c', 'intel_compute_slm.h', 'intel_debug_identifier.h', diff --git a/src/intel/dev/intel_device_info.py b/src/intel/dev/intel_device_info.py index 64345ae64c4..45243dcc536 100644 --- a/src/intel/dev/intel_device_info.py +++ b/src/intel/dev/intel_device_info.py @@ -461,7 +461,8 @@ Struct("intel_device_info", Member("intel_device_info_urb_desc", "urb"), Member("unsigned", "max_constant_urb_size_kb"), Member("unsigned", "mesh_max_constant_urb_size_kb"), - Member("unsigned", "engine_class_prefetch", array="INTEL_ENGINE_CLASS_COMPUTE + 1"), + Member("unsigned", "engine_class_prefetch", array="INTEL_ENGINE_CLASS_INVALID"), + Member("unsigned", "engine_class_supported_count", array="INTEL_ENGINE_CLASS_INVALID"), Member("unsigned", "mem_alignment"), Member("uint64_t", "timestamp_frequency"), Member("uint64_t", "aperture_bytes"), diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index f9a68cdb198..b7a310cbdd5 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -59,6 +59,7 @@ #include "vk_deferred_operation.h" #include "vk_drm_syncobj.h" #include "common/intel_aux_map.h" +#include "common/intel_common.h" #include "common/intel_debug_identifier.h" #include "common/intel_uuid.h" #include "perf/intel_perf.h" @@ -2225,20 +2226,14 @@ anv_physical_device_init_queue_families(struct anv_physical_device *pdevice) sparse_supports_non_render_engines; if (can_use_non_render_engines) { - c_count = intel_engines_supported_count(pdevice->local_fd, - &pdevice->info, - pdevice->engine_info, - INTEL_ENGINE_CLASS_COMPUTE); + c_count = pdevice->info.engine_class_supported_count[INTEL_ENGINE_CLASS_COMPUTE]; } enum intel_engine_class compute_class = c_count < 1 ? INTEL_ENGINE_CLASS_RENDER : INTEL_ENGINE_CLASS_COMPUTE; int blit_count = 0; if (pdevice->info.verx10 >= 125 && can_use_non_render_engines) { - blit_count = intel_engines_supported_count(pdevice->local_fd, - &pdevice->info, - pdevice->engine_info, - INTEL_ENGINE_CLASS_COPY); + blit_count = pdevice->info.engine_class_supported_count[INTEL_ENGINE_CLASS_COPY]; } anv_override_engine_counts(&gc_count, &g_count, &c_count, &v_count); @@ -2581,9 +2576,8 @@ anv_physical_device_try_create(struct vk_instance *vk_instance, device->master_fd = master_fd; device->engine_info = intel_engine_get_info(fd, device->info.kmd_type); - device->info.has_compute_engine = device->engine_info && - intel_engines_count(device->engine_info, - INTEL_ENGINE_CLASS_COMPUTE); + intel_common_update_device_info(fd, &devinfo); + anv_physical_device_init_queue_families(device); anv_physical_device_init_perf(device, fd);