intel/perf: Refactor and add Xe KMD support to change stream metrics id

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29312>
This commit is contained in:
José Roberto de Souza
2024-04-30 13:51:52 -07:00
committed by Marge Bot
parent b22899b494
commit c2fd848002
10 changed files with 50 additions and 8 deletions

View File

@@ -283,3 +283,10 @@ i915_perf_stream_set_state(int perf_stream_fd, bool enable)
return intel_ioctl(perf_stream_fd, uapi, 0); return intel_ioctl(perf_stream_fd, uapi, 0);
} }
int
i915_perf_stream_set_metrics_id(int perf_stream_fd, uint64_t metrics_set_id)
{
return intel_ioctl(perf_stream_fd, I915_PERF_IOCTL_CONFIG,
(void *)(uintptr_t)metrics_set_id);
}

View File

@@ -21,6 +21,7 @@ int i915_perf_stream_open(struct intel_perf_config *perf_config, int drm_fd,
bool hold_preemption, bool enable); bool hold_preemption, bool enable);
int i915_perf_stream_read_samples(int perf_stream_fd, uint8_t *buffer, size_t buffer_len); int i915_perf_stream_read_samples(int perf_stream_fd, uint8_t *buffer, size_t buffer_len);
int i915_perf_stream_set_state(int perf_stream_fd, bool enable); int i915_perf_stream_set_state(int perf_stream_fd, bool enable);
int i915_perf_stream_set_metrics_id(int perf_stream_fd, uint64_t metrics_set_id);
struct intel_perf_registers *i915_perf_load_configurations(struct intel_perf_config *perf_cfg, int fd, const char *guid); struct intel_perf_registers *i915_perf_load_configurations(struct intel_perf_config *perf_cfg, int fd, const char *guid);

View File

@@ -1592,3 +1592,18 @@ intel_perf_stream_set_state(struct intel_perf_config *perf_config,
return -1; return -1;
} }
} }
int
intel_perf_stream_set_metrics_id(struct intel_perf_config *perf_config,
int perf_stream_fd, uint64_t metrics_set_id)
{
switch (perf_config->devinfo->kmd_type) {
case INTEL_KMD_TYPE_I915:
return i915_perf_stream_set_metrics_id(perf_stream_fd, metrics_set_id);
case INTEL_KMD_TYPE_XE:
return xe_perf_stream_set_metrics_id(perf_stream_fd, metrics_set_id);
default:
unreachable("missing");
return -1;
}
}

View File

@@ -602,6 +602,8 @@ int intel_perf_stream_read_samples(struct intel_perf_config *perf_config,
size_t buffer_len); size_t buffer_len);
int intel_perf_stream_set_state(struct intel_perf_config *perf_config, int intel_perf_stream_set_state(struct intel_perf_config *perf_config,
int perf_stream_fd, bool enable); int perf_stream_fd, bool enable);
int intel_perf_stream_set_metrics_id(struct intel_perf_config *perf_config,
int perf_stream_fd, uint64_t metrics_set_id);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // extern "C"

View File

@@ -166,3 +166,15 @@ xe_perf_stream_set_state(int perf_stream_fd, bool enable)
return intel_ioctl(perf_stream_fd, uapi, 0); return intel_ioctl(perf_stream_fd, uapi, 0);
} }
int
xe_perf_stream_set_metrics_id(int perf_stream_fd, uint64_t metrics_set_id)
{
struct drm_xe_ext_set_property prop = {};
uint32_t index = 0;
perf_prop_set(&prop, &index, DRM_XE_OA_PROPERTY_OA_METRIC_SET,
metrics_set_id);
return intel_ioctl(perf_stream_fd, DRM_XE_PERF_IOCTL_CONFIG,
(void *)(uintptr_t)&prop);
}

View File

@@ -23,3 +23,4 @@ int xe_perf_stream_open(struct intel_perf_config *perf_config, int drm_fd,
uint64_t report_format, uint64_t period_exponent, uint64_t report_format, uint64_t period_exponent,
bool hold_preemption, bool enable); bool hold_preemption, bool enable);
int xe_perf_stream_set_state(int perf_stream_fd, bool enable); int xe_perf_stream_set_state(int perf_stream_fd, bool enable);
int xe_perf_stream_set_metrics_id(int perf_stream_fd, uint64_t metrics_set_id);

View File

@@ -229,8 +229,9 @@ VkResult anv_QueueSetPerformanceConfigurationINTEL(
if (device->perf_fd < 0) if (device->perf_fd < 0)
return VK_ERROR_INITIALIZATION_FAILED; return VK_ERROR_INITIALIZATION_FAILED;
} else { } else {
int ret = intel_ioctl(device->perf_fd, I915_PERF_IOCTL_CONFIG, int ret = intel_perf_stream_set_metrics_id(device->physical->perf,
(void *)(uintptr_t) config->config_id); device->perf_fd,
config->config_id);
if (ret < 0) if (ret < 0)
return vk_device_set_lost(&device->vk, "i915-perf config failed: %m"); return vk_device_set_lost(&device->vk, "i915-perf config failed: %m");
} }

View File

@@ -934,8 +934,9 @@ i915_queue_exec_locked(struct anv_queue *queue,
if (!INTEL_DEBUG(DEBUG_NO_OACONFIG) && if (!INTEL_DEBUG(DEBUG_NO_OACONFIG) &&
(query_info->kind == INTEL_PERF_QUERY_TYPE_OA || (query_info->kind == INTEL_PERF_QUERY_TYPE_OA ||
query_info->kind == INTEL_PERF_QUERY_TYPE_RAW)) { query_info->kind == INTEL_PERF_QUERY_TYPE_RAW)) {
int ret = intel_ioctl(device->perf_fd, I915_PERF_IOCTL_CONFIG, int ret = intel_perf_stream_set_metrics_id(device->physical->perf,
(void *)(uintptr_t) query_info->oa_metrics_set_id); device->perf_fd,
query_info->oa_metrics_set_id);
if (ret < 0) { if (ret < 0) {
result = vk_device_set_lost(&device->vk, result = vk_device_set_lost(&device->vk,
"i915-perf config failed: %s", "i915-perf config failed: %s",

View File

@@ -2222,8 +2222,9 @@ anv_queue_exec_locked(struct anv_queue *queue,
if (!INTEL_DEBUG(DEBUG_NO_OACONFIG) && if (!INTEL_DEBUG(DEBUG_NO_OACONFIG) &&
(query_info->kind == INTEL_PERF_QUERY_TYPE_OA || (query_info->kind == INTEL_PERF_QUERY_TYPE_OA ||
query_info->kind == INTEL_PERF_QUERY_TYPE_RAW)) { query_info->kind == INTEL_PERF_QUERY_TYPE_RAW)) {
int ret = intel_ioctl(device->perf_fd, I915_PERF_IOCTL_CONFIG, int ret = intel_perf_stream_set_metrics_id(device->physical->perf,
(void *)(uintptr_t) query_info->oa_metrics_set_id); device->perf_fd,
query_info->oa_metrics_set_id);
if (ret < 0) { if (ret < 0) {
result = vk_device_set_lost(&device->vk, result = vk_device_set_lost(&device->vk,
"i915-perf config failed: %s", "i915-perf config failed: %s",

View File

@@ -236,8 +236,9 @@ VkResult anv_QueueSetPerformanceConfigurationINTEL(
if (device->perf_fd < 0) if (device->perf_fd < 0)
return VK_ERROR_INITIALIZATION_FAILED; return VK_ERROR_INITIALIZATION_FAILED;
} else { } else {
int ret = intel_ioctl(device->perf_fd, I915_PERF_IOCTL_CONFIG, int ret = intel_perf_stream_set_metrics_id(device->physical->perf,
(void *)(uintptr_t) config->config_id); device->perf_fd,
config->config_id);
if (ret < 0) if (ret < 0)
return vk_device_set_lost(&device->vk, "i915-perf config failed: %m"); return vk_device_set_lost(&device->vk, "i915-perf config failed: %m");
} }