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 <sys/stat.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 "drm-uapi/i915_drm.h"
|
||||
|
||||
#define FILE_DEBUG_FLAG DEBUG_PERFMON
|
||||
|
||||
uint64_t i915_perf_get_oa_format(struct intel_perf_config *perf)
|
||||
{
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user