diff --git a/src/intel/perf/intel_perf.c b/src/intel/perf/intel_perf.c index 64d13255697..35a3459ec8d 100644 --- a/src/intel/perf/intel_perf.c +++ b/src/intel/perf/intel_perf.c @@ -788,6 +788,19 @@ intel_perf_load_configuration(struct intel_perf_config *perf_cfg, int fd, const } } +uint64_t +intel_perf_get_configuration_id(struct intel_perf_config *perf_cfg, const char *guid) +{ + char path[512]; + uint64_t val; + + snprintf(path, sizeof(path), "metrics/%s/id", guid); + if (read_sysfs_drm_device_file_uint64(perf_cfg, path, &val)) + return val; + + return 0; +} + uint64_t intel_perf_store_configuration(struct intel_perf_config *perf_cfg, int fd, const struct intel_perf_registers *config, diff --git a/src/intel/perf/intel_perf.h b/src/intel/perf/intel_perf.h index 6ef032783d1..bb2b1415f96 100644 --- a/src/intel/perf/intel_perf.h +++ b/src/intel/perf/intel_perf.h @@ -572,6 +572,11 @@ bool intel_perf_load_metric_id(struct intel_perf_config *perf_cfg, struct intel_perf_registers *intel_perf_load_configuration(struct intel_perf_config *perf_cfg, int fd, const char *guid); +/** Load a configuration's id from KMD using a guid. + */ +uint64_t +intel_perf_get_configuration_id(struct intel_perf_config *perf_cfg, const char *guid); + /** Store a configuration into i915 using guid and return a new metric id. * * If guid is NULL, then a generated one will be provided by hashing the diff --git a/src/intel/vulkan/anv_perf.c b/src/intel/vulkan/anv_perf.c index 156323aba6d..925861c661a 100644 --- a/src/intel/vulkan/anv_perf.c +++ b/src/intel/vulkan/anv_perf.c @@ -221,18 +221,8 @@ VkResult anv_AcquirePerformanceConfigurationINTEL( return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY); if (!INTEL_DEBUG(DEBUG_NO_OACONFIG)) { - struct intel_perf_registers *metric_config = - intel_perf_load_configuration(device->physical->perf, device->fd, - INTEL_PERF_QUERY_GUID_MDAPI); - if (!metric_config) { - vk_object_free(&device->vk, NULL, config); - return VK_INCOMPLETE; - } - - config->config_id = - intel_perf_store_configuration(device->physical->perf, device->fd, - metric_config, NULL /* guid */); - ralloc_free(metric_config); + config->config_id = intel_perf_get_configuration_id(device->physical->perf, + INTEL_PERF_QUERY_GUID_MDAPI); if (config->config_id == 0) { vk_object_free(&device->vk, NULL, config); return VK_INCOMPLETE; diff --git a/src/intel/vulkan_hasvk/anv_perf.c b/src/intel/vulkan_hasvk/anv_perf.c index ca43022a8b4..0d35fa68266 100644 --- a/src/intel/vulkan_hasvk/anv_perf.c +++ b/src/intel/vulkan_hasvk/anv_perf.c @@ -180,18 +180,8 @@ VkResult anv_AcquirePerformanceConfigurationINTEL( return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY); if (!INTEL_DEBUG(DEBUG_NO_OACONFIG)) { - struct intel_perf_registers *metric_config = - intel_perf_load_configuration(device->physical->perf, device->fd, - INTEL_PERF_QUERY_GUID_MDAPI); - if (!metric_config) { - vk_object_free(&device->vk, NULL, config); - return VK_INCOMPLETE; - } - - config->config_id = - intel_perf_store_configuration(device->physical->perf, device->fd, - metric_config, NULL /* guid */); - ralloc_free(metric_config); + config->config_id = intel_perf_get_configuration_id(device->physical->perf, + INTEL_PERF_QUERY_GUID_MDAPI); if (config->config_id == 0) { vk_object_free(&device->vk, NULL, config); return VK_INCOMPLETE;