intel/perf: use common ioctl wrapper
There were multiple ioctl-wrapper functions, so a common implementation was put in gen_gem.h. With a common implementation, perf no longer needs the caller to configure one for it. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
@@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
#include <drm-uapi/i915_drm.h>
|
#include <drm-uapi/i915_drm.h>
|
||||||
|
|
||||||
|
#include "common/gen_gem.h"
|
||||||
#include "gen_perf.h"
|
#include "gen_perf.h"
|
||||||
#include "perf/gen_perf_metrics.h"
|
#include "perf/gen_perf_metrics.h"
|
||||||
|
|
||||||
@@ -214,8 +215,8 @@ kernel_has_dynamic_config_support(struct gen_perf_config *perf, int fd)
|
|||||||
{
|
{
|
||||||
uint64_t invalid_config_id = UINT64_MAX;
|
uint64_t invalid_config_id = UINT64_MAX;
|
||||||
|
|
||||||
return perf->ioctl(fd, DRM_IOCTL_I915_PERF_REMOVE_CONFIG,
|
return gen_ioctl(fd, DRM_IOCTL_I915_PERF_REMOVE_CONFIG,
|
||||||
&invalid_config_id) < 0 && errno == ENOENT;
|
&invalid_config_id) < 0 && errno == ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@@ -259,7 +260,7 @@ init_oa_configs(struct gen_perf_config *perf, int fd)
|
|||||||
config.n_flex_regs = query->n_flex_regs;
|
config.n_flex_regs = query->n_flex_regs;
|
||||||
config.flex_regs_ptr = (uintptr_t) query->flex_regs;
|
config.flex_regs_ptr = (uintptr_t) query->flex_regs;
|
||||||
|
|
||||||
ret = perf->ioctl(fd, DRM_IOCTL_I915_PERF_ADD_CONFIG, &config);
|
ret = gen_ioctl(fd, DRM_IOCTL_I915_PERF_ADD_CONFIG, &config);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
DBG("Failed to load \"%s\" (%s) metrics set in kernel: %s\n",
|
DBG("Failed to load \"%s\" (%s) metrics set in kernel: %s\n",
|
||||||
query->name, query->guid, strerror(errno));
|
query->name, query->guid, strerror(errno));
|
||||||
|
@@ -188,8 +188,6 @@ struct gen_perf_config {
|
|||||||
|
|
||||||
/* Location of the device's sysfs entry. */
|
/* Location of the device's sysfs entry. */
|
||||||
char sysfs_dev_dir[256];
|
char sysfs_dev_dir[256];
|
||||||
|
|
||||||
int (*ioctl)(int, unsigned long, void *);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline size_t
|
static inline size_t
|
||||||
@@ -264,12 +262,9 @@ gen_perf_query_info_add_basic_stat_reg(struct gen_perf_query_info *query,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline struct gen_perf_config *
|
static inline struct gen_perf_config *
|
||||||
gen_perf_new(void *ctx, int (*ioctl_cb)(int, unsigned long, void *))
|
gen_perf_new(void *ctx)
|
||||||
{
|
{
|
||||||
struct gen_perf_config *perf = rzalloc(ctx, struct gen_perf_config);
|
struct gen_perf_config *perf = rzalloc(ctx, struct gen_perf_config);
|
||||||
|
|
||||||
perf->ioctl = ioctl_cb;
|
|
||||||
|
|
||||||
return perf;
|
return perf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1733,7 +1733,7 @@ brw_init_perf_query_info(struct gl_context *ctx)
|
|||||||
if (brw->perfquery.perf)
|
if (brw->perfquery.perf)
|
||||||
return brw->perfquery.perf->n_queries;
|
return brw->perfquery.perf->n_queries;
|
||||||
|
|
||||||
brw->perfquery.perf = gen_perf_new(brw, drmIoctl);
|
brw->perfquery.perf = gen_perf_new(brw);
|
||||||
|
|
||||||
init_pipeline_statistic_query_registers(brw);
|
init_pipeline_statistic_query_registers(brw);
|
||||||
brw_perf_query_register_mdapi_statistic_query(brw);
|
brw_perf_query_register_mdapi_statistic_query(brw);
|
||||||
|
Reference in New Issue
Block a user