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:

committed by
Marge Bot

parent
b22899b494
commit
c2fd848002
@@ -283,3 +283,10 @@ i915_perf_stream_set_state(int perf_stream_fd, bool enable)
|
||||
|
||||
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);
|
||||
}
|
||||
|
@@ -21,6 +21,7 @@ int i915_perf_stream_open(struct intel_perf_config *perf_config, int drm_fd,
|
||||
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_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);
|
||||
|
||||
|
@@ -1592,3 +1592,18 @@ intel_perf_stream_set_state(struct intel_perf_config *perf_config,
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@@ -602,6 +602,8 @@ int intel_perf_stream_read_samples(struct intel_perf_config *perf_config,
|
||||
size_t buffer_len);
|
||||
int intel_perf_stream_set_state(struct intel_perf_config *perf_config,
|
||||
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
|
||||
} // extern "C"
|
||||
|
@@ -166,3 +166,15 @@ xe_perf_stream_set_state(int perf_stream_fd, bool enable)
|
||||
|
||||
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);
|
||||
}
|
||||
|
@@ -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,
|
||||
bool hold_preemption, 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);
|
||||
|
@@ -229,8 +229,9 @@ VkResult anv_QueueSetPerformanceConfigurationINTEL(
|
||||
if (device->perf_fd < 0)
|
||||
return VK_ERROR_INITIALIZATION_FAILED;
|
||||
} else {
|
||||
int ret = intel_ioctl(device->perf_fd, I915_PERF_IOCTL_CONFIG,
|
||||
(void *)(uintptr_t) config->config_id);
|
||||
int ret = intel_perf_stream_set_metrics_id(device->physical->perf,
|
||||
device->perf_fd,
|
||||
config->config_id);
|
||||
if (ret < 0)
|
||||
return vk_device_set_lost(&device->vk, "i915-perf config failed: %m");
|
||||
}
|
||||
|
@@ -934,8 +934,9 @@ i915_queue_exec_locked(struct anv_queue *queue,
|
||||
if (!INTEL_DEBUG(DEBUG_NO_OACONFIG) &&
|
||||
(query_info->kind == INTEL_PERF_QUERY_TYPE_OA ||
|
||||
query_info->kind == INTEL_PERF_QUERY_TYPE_RAW)) {
|
||||
int ret = intel_ioctl(device->perf_fd, I915_PERF_IOCTL_CONFIG,
|
||||
(void *)(uintptr_t) query_info->oa_metrics_set_id);
|
||||
int ret = intel_perf_stream_set_metrics_id(device->physical->perf,
|
||||
device->perf_fd,
|
||||
query_info->oa_metrics_set_id);
|
||||
if (ret < 0) {
|
||||
result = vk_device_set_lost(&device->vk,
|
||||
"i915-perf config failed: %s",
|
||||
|
@@ -2222,8 +2222,9 @@ anv_queue_exec_locked(struct anv_queue *queue,
|
||||
if (!INTEL_DEBUG(DEBUG_NO_OACONFIG) &&
|
||||
(query_info->kind == INTEL_PERF_QUERY_TYPE_OA ||
|
||||
query_info->kind == INTEL_PERF_QUERY_TYPE_RAW)) {
|
||||
int ret = intel_ioctl(device->perf_fd, I915_PERF_IOCTL_CONFIG,
|
||||
(void *)(uintptr_t) query_info->oa_metrics_set_id);
|
||||
int ret = intel_perf_stream_set_metrics_id(device->physical->perf,
|
||||
device->perf_fd,
|
||||
query_info->oa_metrics_set_id);
|
||||
if (ret < 0) {
|
||||
result = vk_device_set_lost(&device->vk,
|
||||
"i915-perf config failed: %s",
|
||||
|
@@ -236,8 +236,9 @@ VkResult anv_QueueSetPerformanceConfigurationINTEL(
|
||||
if (device->perf_fd < 0)
|
||||
return VK_ERROR_INITIALIZATION_FAILED;
|
||||
} else {
|
||||
int ret = intel_ioctl(device->perf_fd, I915_PERF_IOCTL_CONFIG,
|
||||
(void *)(uintptr_t) config->config_id);
|
||||
int ret = intel_perf_stream_set_metrics_id(device->physical->perf,
|
||||
device->perf_fd,
|
||||
config->config_id);
|
||||
if (ret < 0)
|
||||
return vk_device_set_lost(&device->vk, "i915-perf config failed: %m");
|
||||
}
|
||||
|
Reference in New Issue
Block a user