intel/perf: Move i915 specific code from common code
More code will be moved to i915 specific files in the next patches. 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/29421>
This commit is contained in:

committed by
Marge Bot

parent
8ad56247c3
commit
30f97a7242
@@ -5,11 +5,19 @@
|
|||||||
|
|
||||||
#include "perf/i915/intel_perf.h"
|
#include "perf/i915/intel_perf.h"
|
||||||
|
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include "common/intel_gem.h"
|
#include "common/intel_gem.h"
|
||||||
|
#include "common/i915/intel_gem.h"
|
||||||
|
#include "dev/intel_debug.h"
|
||||||
|
#include "dev/intel_device_info.h"
|
||||||
|
#include "intel_perf_common.h"
|
||||||
#include "perf/intel_perf.h"
|
#include "perf/intel_perf.h"
|
||||||
|
|
||||||
#include "drm-uapi/i915_drm.h"
|
#include "drm-uapi/i915_drm.h"
|
||||||
|
|
||||||
|
#define FILE_DEBUG_FLAG DEBUG_PERFMON
|
||||||
|
|
||||||
uint64_t i915_perf_get_oa_format(struct intel_perf_config *perf)
|
uint64_t i915_perf_get_oa_format(struct intel_perf_config *perf)
|
||||||
{
|
{
|
||||||
if (perf->devinfo->verx10 <= 75)
|
if (perf->devinfo->verx10 <= 75)
|
||||||
@@ -79,3 +87,91 @@ i915_perf_stream_open(struct intel_perf_config *perf_config, int drm_fd,
|
|||||||
int fd = intel_ioctl(drm_fd, DRM_IOCTL_I915_PERF_OPEN, ¶m);
|
int fd = intel_ioctl(drm_fd, DRM_IOCTL_I915_PERF_OPEN, ¶m);
|
||||||
return fd > -1 ? fd : 0;
|
return fd > -1 ? fd : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
i915_query_perf_config_supported(struct intel_perf_config *perf, int fd)
|
||||||
|
{
|
||||||
|
int32_t length = 0;
|
||||||
|
return !intel_i915_query_flags(fd, DRM_I915_QUERY_PERF_CONFIG,
|
||||||
|
DRM_I915_QUERY_PERF_CONFIG_LIST,
|
||||||
|
NULL, &length);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
i915_query_perf_config_data(struct intel_perf_config *perf,
|
||||||
|
int fd, const char *guid,
|
||||||
|
struct drm_i915_perf_oa_config *config)
|
||||||
|
{
|
||||||
|
char data[sizeof(struct drm_i915_query_perf_config) +
|
||||||
|
sizeof(struct drm_i915_perf_oa_config)] = {};
|
||||||
|
struct drm_i915_query_perf_config *i915_query = (void *)data;
|
||||||
|
struct drm_i915_perf_oa_config *i915_config = (void *)data + sizeof(*i915_query);
|
||||||
|
|
||||||
|
memcpy(i915_query->uuid, guid, sizeof(i915_query->uuid));
|
||||||
|
memcpy(i915_config, config, sizeof(*config));
|
||||||
|
|
||||||
|
int32_t item_length = sizeof(data);
|
||||||
|
if (intel_i915_query_flags(fd, DRM_I915_QUERY_PERF_CONFIG,
|
||||||
|
DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_UUID,
|
||||||
|
i915_query, &item_length))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
memcpy(config, i915_config, sizeof(*config));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
i915_perf_version(int drm_fd)
|
||||||
|
{
|
||||||
|
int tmp = 0;
|
||||||
|
intel_gem_get_param(drm_fd, I915_PARAM_PERF_REVISION, &tmp);
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
i915_get_sseu(int drm_fd, struct drm_i915_gem_context_param_sseu *sseu)
|
||||||
|
{
|
||||||
|
struct drm_i915_gem_context_param arg = {
|
||||||
|
.param = I915_CONTEXT_PARAM_SSEU,
|
||||||
|
.size = sizeof(*sseu),
|
||||||
|
.value = (uintptr_t) sseu
|
||||||
|
};
|
||||||
|
|
||||||
|
intel_ioctl(drm_fd, DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM, &arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
i915_oa_metrics_available(struct intel_perf_config *perf, int fd, bool use_register_snapshots)
|
||||||
|
{
|
||||||
|
bool i915_perf_oa_available = false;
|
||||||
|
struct stat sb;
|
||||||
|
|
||||||
|
perf->i915_query_supported = i915_query_perf_config_supported(perf, fd);
|
||||||
|
perf->i915_perf_version = i915_perf_version(fd);
|
||||||
|
|
||||||
|
/* Record the default SSEU configuration. */
|
||||||
|
i915_get_sseu(fd, &perf->sseu);
|
||||||
|
|
||||||
|
/* The existence of this sysctl parameter implies the kernel supports
|
||||||
|
* the i915 perf interface.
|
||||||
|
*/
|
||||||
|
if (stat("/proc/sys/dev/i915/perf_stream_paranoid", &sb) == 0) {
|
||||||
|
|
||||||
|
/* If _paranoid == 1 then on Gfx8+ we won't be able to access OA
|
||||||
|
* metrics unless running as root.
|
||||||
|
*/
|
||||||
|
if (perf->devinfo->platform == INTEL_PLATFORM_HSW)
|
||||||
|
i915_perf_oa_available = true;
|
||||||
|
else {
|
||||||
|
uint64_t paranoid = 1;
|
||||||
|
|
||||||
|
read_file_uint64("/proc/sys/dev/i915/perf_stream_paranoid", ¶noid);
|
||||||
|
|
||||||
|
if (paranoid == 0 || geteuid() == 0)
|
||||||
|
i915_perf_oa_available = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return i915_perf_oa_available;
|
||||||
|
}
|
||||||
|
@@ -9,6 +9,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
struct intel_perf_config;
|
struct intel_perf_config;
|
||||||
|
struct drm_i915_perf_oa_config;
|
||||||
|
|
||||||
uint64_t i915_perf_get_oa_format(struct intel_perf_config *perf);
|
uint64_t i915_perf_get_oa_format(struct intel_perf_config *perf);
|
||||||
|
|
||||||
@@ -16,3 +17,7 @@ int i915_perf_stream_open(struct intel_perf_config *perf_config, int drm_fd,
|
|||||||
uint32_t ctx_id, uint64_t metrics_set_id,
|
uint32_t ctx_id, uint64_t metrics_set_id,
|
||||||
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);
|
||||||
|
|
||||||
|
bool i915_query_perf_config_data(struct intel_perf_config *perf, int fd, const char *guid, struct drm_i915_perf_oa_config *config);
|
||||||
|
|
||||||
|
bool i915_oa_metrics_available(struct intel_perf_config *perf, int fd, bool use_register_snapshots);
|
||||||
|
@@ -245,39 +245,6 @@ kernel_has_dynamic_config_support(struct intel_perf_config *perf, int fd)
|
|||||||
&invalid_config_id) < 0 && errno == ENOENT;
|
&invalid_config_id) < 0 && errno == ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
|
||||||
i915_query_perf_config_supported(struct intel_perf_config *perf, int fd)
|
|
||||||
{
|
|
||||||
int32_t length = 0;
|
|
||||||
return !intel_i915_query_flags(fd, DRM_I915_QUERY_PERF_CONFIG,
|
|
||||||
DRM_I915_QUERY_PERF_CONFIG_LIST,
|
|
||||||
NULL, &length);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
|
||||||
i915_query_perf_config_data(struct intel_perf_config *perf,
|
|
||||||
int fd, const char *guid,
|
|
||||||
struct drm_i915_perf_oa_config *config)
|
|
||||||
{
|
|
||||||
char data[sizeof(struct drm_i915_query_perf_config) +
|
|
||||||
sizeof(struct drm_i915_perf_oa_config)] = {};
|
|
||||||
struct drm_i915_query_perf_config *i915_query = (void *)data;
|
|
||||||
struct drm_i915_perf_oa_config *i915_config = (void *)data + sizeof(*i915_query);
|
|
||||||
|
|
||||||
memcpy(i915_query->uuid, guid, sizeof(i915_query->uuid));
|
|
||||||
memcpy(i915_config, config, sizeof(*config));
|
|
||||||
|
|
||||||
int32_t item_length = sizeof(data);
|
|
||||||
if (intel_i915_query_flags(fd, DRM_I915_QUERY_PERF_CONFIG,
|
|
||||||
DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_UUID,
|
|
||||||
i915_query, &item_length))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
memcpy(config, i915_config, sizeof(*config));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
intel_perf_load_metric_id(struct intel_perf_config *perf_cfg,
|
intel_perf_load_metric_id(struct intel_perf_config *perf_cfg,
|
||||||
const char *guid,
|
const char *guid,
|
||||||
@@ -587,26 +554,6 @@ load_pipeline_statistic_metrics(struct intel_perf_config *perf_cfg,
|
|||||||
sort_query(query);
|
sort_query(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
i915_perf_version(int drm_fd)
|
|
||||||
{
|
|
||||||
int tmp = 0;
|
|
||||||
intel_gem_get_param(drm_fd, I915_PARAM_PERF_REVISION, &tmp);
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
i915_get_sseu(int drm_fd, struct drm_i915_gem_context_param_sseu *sseu)
|
|
||||||
{
|
|
||||||
struct drm_i915_gem_context_param arg = {
|
|
||||||
.param = I915_CONTEXT_PARAM_SSEU,
|
|
||||||
.size = sizeof(*sseu),
|
|
||||||
.value = to_user_pointer(sseu)
|
|
||||||
};
|
|
||||||
|
|
||||||
intel_ioctl(drm_fd, DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM, &arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
compare_str_or_null(const char *s1, const char *s2)
|
compare_str_or_null(const char *s1, const char *s2)
|
||||||
{
|
{
|
||||||
@@ -699,8 +646,7 @@ oa_metrics_available(struct intel_perf_config *perf, int fd,
|
|||||||
bool use_register_snapshots)
|
bool use_register_snapshots)
|
||||||
{
|
{
|
||||||
perf_register_oa_queries_t oa_register = get_register_queries_function(devinfo);
|
perf_register_oa_queries_t oa_register = get_register_queries_function(devinfo);
|
||||||
bool i915_perf_oa_available = false;
|
bool oa_metrics_available = false;
|
||||||
struct stat sb;
|
|
||||||
|
|
||||||
/* TODO: Xe still don't have support for performance metrics */
|
/* TODO: Xe still don't have support for performance metrics */
|
||||||
if (devinfo->kmd_type != INTEL_KMD_TYPE_I915)
|
if (devinfo->kmd_type != INTEL_KMD_TYPE_I915)
|
||||||
@@ -714,9 +660,7 @@ oa_metrics_available(struct intel_perf_config *perf, int fd,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
perf->i915_query_supported = i915_query_perf_config_supported(perf, fd);
|
|
||||||
perf->enable_all_metrics = debug_get_bool_option("INTEL_EXTENDED_METRICS", false);
|
perf->enable_all_metrics = debug_get_bool_option("INTEL_EXTENDED_METRICS", false);
|
||||||
perf->i915_perf_version = i915_perf_version(fd);
|
|
||||||
|
|
||||||
/* TODO: We should query this from i915 */
|
/* TODO: We should query this from i915 */
|
||||||
if (devinfo->verx10 >= 125)
|
if (devinfo->verx10 >= 125)
|
||||||
@@ -725,30 +669,18 @@ oa_metrics_available(struct intel_perf_config *perf, int fd,
|
|||||||
perf->oa_timestamp_mask =
|
perf->oa_timestamp_mask =
|
||||||
0xffffffffffffffffull >> (32 + perf->oa_timestamp_shift);
|
0xffffffffffffffffull >> (32 + perf->oa_timestamp_shift);
|
||||||
|
|
||||||
/* Record the default SSEU configuration. */
|
switch (devinfo->kmd_type) {
|
||||||
i915_get_sseu(fd, &perf->sseu);
|
case INTEL_KMD_TYPE_I915:
|
||||||
|
oa_metrics_available = i915_oa_metrics_available(perf, fd, use_register_snapshots);
|
||||||
/* The existence of this sysctl parameter implies the kernel supports
|
break;
|
||||||
* the i915 perf interface.
|
case INTEL_KMD_TYPE_XE:
|
||||||
*/
|
break;
|
||||||
if (stat("/proc/sys/dev/i915/perf_stream_paranoid", &sb) == 0) {
|
default:
|
||||||
|
unreachable("missing");
|
||||||
/* If _paranoid == 1 then on Gfx8+ we won't be able to access OA
|
break;
|
||||||
* metrics unless running as root.
|
|
||||||
*/
|
|
||||||
if (devinfo->platform == INTEL_PLATFORM_HSW)
|
|
||||||
i915_perf_oa_available = true;
|
|
||||||
else {
|
|
||||||
uint64_t paranoid = 1;
|
|
||||||
|
|
||||||
read_file_uint64("/proc/sys/dev/i915/perf_stream_paranoid", ¶noid);
|
|
||||||
|
|
||||||
if (paranoid == 0 || geteuid() == 0)
|
|
||||||
i915_perf_oa_available = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return i915_perf_oa_available &&
|
return oa_metrics_available &&
|
||||||
oa_register &&
|
oa_register &&
|
||||||
get_sysfs_dev_dir(perf, fd) &&
|
get_sysfs_dev_dir(perf, fd) &&
|
||||||
init_oa_sys_vars(perf, use_register_snapshots);
|
init_oa_sys_vars(perf, use_register_snapshots);
|
||||||
|
Reference in New Issue
Block a user