mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2024-11-23 18:24:13 +08:00
intel: Rename XE_PERF to XE_OBSERVATION
Xe KMD renamed XE_PERF to XE_OBSERVATION to better match with Intel specification and avoid confusion. This uAPI rename will land in the same kernel version that added the uAPI being renamed. There is no uAPI change, just renames. Sync xe_drm.h with 63347fe031e3 ("drm/xe/uapi: Rename xe perf layer as xe observation layer"). Acked-by: Caio Oliveira <caio.oliveira@intel.com> Signed-off-by: José Roberto de Souza <jose.souza@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30027>
This commit is contained in:
parent
40dbb6e8e8
commit
4fd7cad05d
@ -80,7 +80,7 @@ extern "C" {
|
||||
* - &DRM_IOCTL_XE_EXEC_QUEUE_GET_PROPERTY
|
||||
* - &DRM_IOCTL_XE_EXEC
|
||||
* - &DRM_IOCTL_XE_WAIT_USER_FENCE
|
||||
* - &DRM_IOCTL_XE_PERF
|
||||
* - &DRM_IOCTL_XE_OBSERVATION
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -101,7 +101,7 @@ extern "C" {
|
||||
#define DRM_XE_EXEC_QUEUE_GET_PROPERTY 0x08
|
||||
#define DRM_XE_EXEC 0x09
|
||||
#define DRM_XE_WAIT_USER_FENCE 0x0a
|
||||
#define DRM_XE_PERF 0x0b
|
||||
#define DRM_XE_OBSERVATION 0x0b
|
||||
|
||||
/* Must be kept compact -- no holes */
|
||||
|
||||
@ -116,7 +116,7 @@ extern "C" {
|
||||
#define DRM_IOCTL_XE_EXEC_QUEUE_GET_PROPERTY DRM_IOWR(DRM_COMMAND_BASE + DRM_XE_EXEC_QUEUE_GET_PROPERTY, struct drm_xe_exec_queue_get_property)
|
||||
#define DRM_IOCTL_XE_EXEC DRM_IOW(DRM_COMMAND_BASE + DRM_XE_EXEC, struct drm_xe_exec)
|
||||
#define DRM_IOCTL_XE_WAIT_USER_FENCE DRM_IOWR(DRM_COMMAND_BASE + DRM_XE_WAIT_USER_FENCE, struct drm_xe_wait_user_fence)
|
||||
#define DRM_IOCTL_XE_PERF DRM_IOW(DRM_COMMAND_BASE + DRM_XE_PERF, struct drm_xe_perf_param)
|
||||
#define DRM_IOCTL_XE_OBSERVATION DRM_IOW(DRM_COMMAND_BASE + DRM_XE_OBSERVATION, struct drm_xe_observation_param)
|
||||
|
||||
/**
|
||||
* DOC: Xe IOCTL Extensions
|
||||
@ -1376,66 +1376,67 @@ struct drm_xe_wait_user_fence {
|
||||
};
|
||||
|
||||
/**
|
||||
* enum drm_xe_perf_type - Perf stream types
|
||||
* enum drm_xe_observation_type - Observation stream types
|
||||
*/
|
||||
enum drm_xe_perf_type {
|
||||
/** @DRM_XE_PERF_TYPE_OA: OA perf stream type */
|
||||
DRM_XE_PERF_TYPE_OA,
|
||||
enum drm_xe_observation_type {
|
||||
/** @DRM_XE_OBSERVATION_TYPE_OA: OA observation stream type */
|
||||
DRM_XE_OBSERVATION_TYPE_OA,
|
||||
};
|
||||
|
||||
/**
|
||||
* enum drm_xe_perf_op - Perf stream ops
|
||||
* enum drm_xe_observation_op - Observation stream ops
|
||||
*/
|
||||
enum drm_xe_perf_op {
|
||||
/** @DRM_XE_PERF_OP_STREAM_OPEN: Open a perf counter stream */
|
||||
DRM_XE_PERF_OP_STREAM_OPEN,
|
||||
enum drm_xe_observation_op {
|
||||
/** @DRM_XE_OBSERVATION_OP_STREAM_OPEN: Open an observation stream */
|
||||
DRM_XE_OBSERVATION_OP_STREAM_OPEN,
|
||||
|
||||
/** @DRM_XE_PERF_OP_ADD_CONFIG: Add perf stream config */
|
||||
DRM_XE_PERF_OP_ADD_CONFIG,
|
||||
/** @DRM_XE_OBSERVATION_OP_ADD_CONFIG: Add observation stream config */
|
||||
DRM_XE_OBSERVATION_OP_ADD_CONFIG,
|
||||
|
||||
/** @DRM_XE_PERF_OP_REMOVE_CONFIG: Remove perf stream config */
|
||||
DRM_XE_PERF_OP_REMOVE_CONFIG,
|
||||
/** @DRM_XE_OBSERVATION_OP_REMOVE_CONFIG: Remove observation stream config */
|
||||
DRM_XE_OBSERVATION_OP_REMOVE_CONFIG,
|
||||
};
|
||||
|
||||
/**
|
||||
* struct drm_xe_perf_param - Input of &DRM_XE_PERF
|
||||
* struct drm_xe_observation_param - Input of &DRM_XE_OBSERVATION
|
||||
*
|
||||
* The perf layer enables multiplexing perf counter streams of multiple
|
||||
* types. The actual params for a particular stream operation are supplied
|
||||
* via the @param pointer (use __copy_from_user to get these params).
|
||||
* The observation layer enables multiplexing observation streams of
|
||||
* multiple types. The actual params for a particular stream operation are
|
||||
* supplied via the @param pointer (use __copy_from_user to get these
|
||||
* params).
|
||||
*/
|
||||
struct drm_xe_perf_param {
|
||||
struct drm_xe_observation_param {
|
||||
/** @extensions: Pointer to the first extension struct, if any */
|
||||
__u64 extensions;
|
||||
/** @perf_type: Perf stream type, of enum @drm_xe_perf_type */
|
||||
__u64 perf_type;
|
||||
/** @perf_op: Perf op, of enum @drm_xe_perf_op */
|
||||
__u64 perf_op;
|
||||
/** @observation_type: observation stream type, of enum @drm_xe_observation_type */
|
||||
__u64 observation_type;
|
||||
/** @observation_op: observation stream op, of enum @drm_xe_observation_op */
|
||||
__u64 observation_op;
|
||||
/** @param: Pointer to actual stream params */
|
||||
__u64 param;
|
||||
};
|
||||
|
||||
/**
|
||||
* enum drm_xe_perf_ioctls - Perf fd ioctl's
|
||||
* enum drm_xe_observation_ioctls - Observation stream fd ioctl's
|
||||
*
|
||||
* Information exchanged between userspace and kernel for perf fd ioctl's
|
||||
* is stream type specific
|
||||
* Information exchanged between userspace and kernel for observation fd
|
||||
* ioctl's is stream type specific
|
||||
*/
|
||||
enum drm_xe_perf_ioctls {
|
||||
/** @DRM_XE_PERF_IOCTL_ENABLE: Enable data capture for a stream */
|
||||
DRM_XE_PERF_IOCTL_ENABLE = _IO('i', 0x0),
|
||||
enum drm_xe_observation_ioctls {
|
||||
/** @DRM_XE_OBSERVATION_IOCTL_ENABLE: Enable data capture for an observation stream */
|
||||
DRM_XE_OBSERVATION_IOCTL_ENABLE = _IO('i', 0x0),
|
||||
|
||||
/** @DRM_XE_PERF_IOCTL_DISABLE: Disable data capture for a stream */
|
||||
DRM_XE_PERF_IOCTL_DISABLE = _IO('i', 0x1),
|
||||
/** @DRM_XE_OBSERVATION_IOCTL_DISABLE: Disable data capture for a observation stream */
|
||||
DRM_XE_OBSERVATION_IOCTL_DISABLE = _IO('i', 0x1),
|
||||
|
||||
/** @DRM_XE_PERF_IOCTL_CONFIG: Change stream configuration */
|
||||
DRM_XE_PERF_IOCTL_CONFIG = _IO('i', 0x2),
|
||||
/** @DRM_XE_OBSERVATION_IOCTL_CONFIG: Change observation stream configuration */
|
||||
DRM_XE_OBSERVATION_IOCTL_CONFIG = _IO('i', 0x2),
|
||||
|
||||
/** @DRM_XE_PERF_IOCTL_STATUS: Return stream status */
|
||||
DRM_XE_PERF_IOCTL_STATUS = _IO('i', 0x3),
|
||||
/** @DRM_XE_OBSERVATION_IOCTL_STATUS: Return observation stream status */
|
||||
DRM_XE_OBSERVATION_IOCTL_STATUS = _IO('i', 0x3),
|
||||
|
||||
/** @DRM_XE_PERF_IOCTL_INFO: Return stream info */
|
||||
DRM_XE_PERF_IOCTL_INFO = _IO('i', 0x4),
|
||||
/** @DRM_XE_OBSERVATION_IOCTL_INFO: Return observation stream info */
|
||||
DRM_XE_OBSERVATION_IOCTL_INFO = _IO('i', 0x4),
|
||||
};
|
||||
|
||||
/**
|
||||
@ -1546,12 +1547,12 @@ enum drm_xe_oa_format_type {
|
||||
* Stream params are specified as a chain of @drm_xe_ext_set_property
|
||||
* struct's, with @property values from enum @drm_xe_oa_property_id and
|
||||
* @drm_xe_user_extension base.name set to @DRM_XE_OA_EXTENSION_SET_PROPERTY.
|
||||
* @param field in struct @drm_xe_perf_param points to the first
|
||||
* @param field in struct @drm_xe_observation_param points to the first
|
||||
* @drm_xe_ext_set_property struct.
|
||||
*
|
||||
* Exactly the same mechanism is also used for stream reconfiguration using
|
||||
* the @DRM_XE_PERF_IOCTL_CONFIG perf fd ioctl, though only a subset of
|
||||
* properties below can be specified for stream reconfiguration.
|
||||
* Exactly the same mechanism is also used for stream reconfiguration using the
|
||||
* @DRM_XE_OBSERVATION_IOCTL_CONFIG observation stream fd ioctl, though only a
|
||||
* subset of properties below can be specified for stream reconfiguration.
|
||||
*/
|
||||
enum drm_xe_oa_property_id {
|
||||
#define DRM_XE_OA_EXTENSION_SET_PROPERTY 0
|
||||
@ -1571,11 +1572,11 @@ enum drm_xe_oa_property_id {
|
||||
|
||||
/**
|
||||
* @DRM_XE_OA_PROPERTY_OA_METRIC_SET: OA metrics defining contents of OA
|
||||
* reports, previously added via @DRM_XE_PERF_OP_ADD_CONFIG.
|
||||
* reports, previously added via @DRM_XE_OBSERVATION_OP_ADD_CONFIG.
|
||||
*/
|
||||
DRM_XE_OA_PROPERTY_OA_METRIC_SET,
|
||||
|
||||
/** @DRM_XE_OA_PROPERTY_OA_FORMAT: Perf counter report format */
|
||||
/** @DRM_XE_OA_PROPERTY_OA_FORMAT: OA counter report format */
|
||||
DRM_XE_OA_PROPERTY_OA_FORMAT,
|
||||
/*
|
||||
* OA_FORMAT's are specified the same way as in PRM/Bspec 52198/60942,
|
||||
@ -1596,13 +1597,13 @@ enum drm_xe_oa_property_id {
|
||||
|
||||
/**
|
||||
* @DRM_XE_OA_PROPERTY_OA_DISABLED: A value of 1 will open the OA
|
||||
* stream in a DISABLED state (see @DRM_XE_PERF_IOCTL_ENABLE).
|
||||
* stream in a DISABLED state (see @DRM_XE_OBSERVATION_IOCTL_ENABLE).
|
||||
*/
|
||||
DRM_XE_OA_PROPERTY_OA_DISABLED,
|
||||
|
||||
/**
|
||||
* @DRM_XE_OA_PROPERTY_EXEC_QUEUE_ID: Open the stream for a specific
|
||||
* @exec_queue_id. Perf queries can be executed on this exec queue.
|
||||
* @exec_queue_id. OA queries can be executed on this exec queue.
|
||||
*/
|
||||
DRM_XE_OA_PROPERTY_EXEC_QUEUE_ID,
|
||||
|
||||
@ -1622,7 +1623,7 @@ enum drm_xe_oa_property_id {
|
||||
/**
|
||||
* struct drm_xe_oa_config - OA metric configuration
|
||||
*
|
||||
* Multiple OA configs can be added using @DRM_XE_PERF_OP_ADD_CONFIG. A
|
||||
* Multiple OA configs can be added using @DRM_XE_OBSERVATION_OP_ADD_CONFIG. A
|
||||
* particular config can be specified when opening an OA stream using
|
||||
* @DRM_XE_OA_PROPERTY_OA_METRIC_SET property.
|
||||
*/
|
||||
@ -1645,8 +1646,9 @@ struct drm_xe_oa_config {
|
||||
|
||||
/**
|
||||
* struct drm_xe_oa_stream_status - OA stream status returned from
|
||||
* @DRM_XE_PERF_IOCTL_STATUS perf fd ioctl. Userspace can call the ioctl to
|
||||
* query stream status in response to EIO errno from perf fd read().
|
||||
* @DRM_XE_OBSERVATION_IOCTL_STATUS observation stream fd ioctl. Userspace can
|
||||
* call the ioctl to query stream status in response to EIO errno from
|
||||
* observation fd read().
|
||||
*/
|
||||
struct drm_xe_oa_stream_status {
|
||||
/** @extensions: Pointer to the first extension struct, if any */
|
||||
@ -1665,7 +1667,7 @@ struct drm_xe_oa_stream_status {
|
||||
|
||||
/**
|
||||
* struct drm_xe_oa_stream_info - OA stream info returned from
|
||||
* @DRM_XE_PERF_IOCTL_INFO perf fd ioctl
|
||||
* @DRM_XE_OBSERVATION_IOCTL_INFO observation stream fd ioctl
|
||||
*/
|
||||
struct drm_xe_oa_stream_info {
|
||||
/** @extensions: Pointer to the first extension struct, if any */
|
||||
|
@ -50,18 +50,18 @@ xe_oa_metrics_available(struct intel_perf_config *perf, int fd, bool use_registe
|
||||
struct stat sb;
|
||||
|
||||
/* The existence of this file implies that this Xe KMD version supports
|
||||
* perf interface.
|
||||
* observation interface.
|
||||
*/
|
||||
if (stat("/proc/sys/dev/xe/perf_stream_paranoid", &sb) == 0) {
|
||||
if (stat("/proc/sys/dev/xe/observation_paranoid", &sb) == 0) {
|
||||
uint64_t paranoid = 1;
|
||||
|
||||
/* Now we need to check if application has privileges to access perf
|
||||
/* Now we need to check if application has privileges to access observation
|
||||
* interface.
|
||||
*
|
||||
* TODO: this approach does not takes into account applications running
|
||||
* with CAP_PERFMON privileges.
|
||||
*/
|
||||
read_file_uint64("/proc/sys/dev/xe/perf_stream_paranoid", ¶noid);
|
||||
read_file_uint64("/proc/sys/dev/xe/observation_paranoid", ¶noid);
|
||||
if (paranoid == 0 || geteuid() == 0)
|
||||
perf_oa_available = true;
|
||||
}
|
||||
@ -80,9 +80,9 @@ xe_add_config(struct intel_perf_config *perf, int fd,
|
||||
const char *guid)
|
||||
{
|
||||
struct drm_xe_oa_config xe_config = {};
|
||||
struct drm_xe_perf_param perf_param = {
|
||||
.perf_type = DRM_XE_PERF_TYPE_OA,
|
||||
.perf_op = DRM_XE_PERF_OP_ADD_CONFIG,
|
||||
struct drm_xe_observation_param observation_param = {
|
||||
.observation_type = DRM_XE_OBSERVATION_TYPE_OA,
|
||||
.observation_op = DRM_XE_OBSERVATION_OP_ADD_CONFIG,
|
||||
.param = (uintptr_t)&xe_config,
|
||||
};
|
||||
uint32_t *regs;
|
||||
@ -102,7 +102,7 @@ xe_add_config(struct intel_perf_config *perf, int fd,
|
||||
regs += 2 * config->n_b_counter_regs;
|
||||
memcpy(regs, config->flex_regs, config->n_flex_regs * sizeof(uint64_t));
|
||||
|
||||
ret = intel_ioctl(fd, DRM_IOCTL_XE_PERF, &perf_param);
|
||||
ret = intel_ioctl(fd, DRM_IOCTL_XE_OBSERVATION, &observation_param);
|
||||
free((void*)(uintptr_t)xe_config.regs_ptr);
|
||||
return ret > 0 ? ret : 0;
|
||||
}
|
||||
@ -110,18 +110,18 @@ xe_add_config(struct intel_perf_config *perf, int fd,
|
||||
void
|
||||
xe_remove_config(struct intel_perf_config *perf, int fd, uint64_t config_id)
|
||||
{
|
||||
struct drm_xe_perf_param perf_param = {
|
||||
.perf_type = DRM_XE_PERF_TYPE_OA,
|
||||
.perf_op = DRM_XE_PERF_OP_REMOVE_CONFIG,
|
||||
struct drm_xe_observation_param observation_param = {
|
||||
.observation_type = DRM_XE_OBSERVATION_TYPE_OA,
|
||||
.observation_op = DRM_XE_OBSERVATION_OP_REMOVE_CONFIG,
|
||||
.param = (uintptr_t)&config_id,
|
||||
};
|
||||
|
||||
intel_ioctl(fd, DRM_IOCTL_XE_PERF, &perf_param);
|
||||
intel_ioctl(fd, DRM_IOCTL_XE_OBSERVATION, &observation_param);
|
||||
}
|
||||
|
||||
static void
|
||||
perf_prop_set(struct drm_xe_ext_set_property *props, uint32_t *index,
|
||||
enum drm_xe_oa_property_id prop_id, uint64_t value)
|
||||
oa_prop_set(struct drm_xe_ext_set_property *props, uint32_t *index,
|
||||
enum drm_xe_oa_property_id prop_id, uint64_t value)
|
||||
{
|
||||
if (*index > 0)
|
||||
props[*index - 1].base.next_extension = (uintptr_t)&props[*index];
|
||||
@ -139,25 +139,25 @@ xe_perf_stream_open(struct intel_perf_config *perf_config, int drm_fd,
|
||||
bool hold_preemption, bool enable)
|
||||
{
|
||||
struct drm_xe_ext_set_property props[DRM_XE_OA_PROPERTY_NO_PREEMPT + 1] = {};
|
||||
struct drm_xe_perf_param perf_param = {
|
||||
.perf_type = DRM_XE_PERF_TYPE_OA,
|
||||
.perf_op = DRM_XE_PERF_OP_STREAM_OPEN,
|
||||
struct drm_xe_observation_param observation_param = {
|
||||
.observation_type = DRM_XE_OBSERVATION_TYPE_OA,
|
||||
.observation_op = DRM_XE_OBSERVATION_OP_STREAM_OPEN,
|
||||
.param = (uintptr_t)&props,
|
||||
};
|
||||
uint32_t i = 0;
|
||||
int fd, flags;
|
||||
|
||||
if (exec_id)
|
||||
perf_prop_set(props, &i, DRM_XE_OA_PROPERTY_EXEC_QUEUE_ID, exec_id);
|
||||
perf_prop_set(props, &i, DRM_XE_OA_PROPERTY_OA_DISABLED, !enable);
|
||||
perf_prop_set(props, &i, DRM_XE_OA_PROPERTY_SAMPLE_OA, true);
|
||||
perf_prop_set(props, &i, DRM_XE_OA_PROPERTY_OA_METRIC_SET, metrics_set_id);
|
||||
perf_prop_set(props, &i, DRM_XE_OA_PROPERTY_OA_FORMAT, report_format);
|
||||
perf_prop_set(props, &i, DRM_XE_OA_PROPERTY_OA_PERIOD_EXPONENT, period_exponent);
|
||||
oa_prop_set(props, &i, DRM_XE_OA_PROPERTY_EXEC_QUEUE_ID, exec_id);
|
||||
oa_prop_set(props, &i, DRM_XE_OA_PROPERTY_OA_DISABLED, !enable);
|
||||
oa_prop_set(props, &i, DRM_XE_OA_PROPERTY_SAMPLE_OA, true);
|
||||
oa_prop_set(props, &i, DRM_XE_OA_PROPERTY_OA_METRIC_SET, metrics_set_id);
|
||||
oa_prop_set(props, &i, DRM_XE_OA_PROPERTY_OA_FORMAT, report_format);
|
||||
oa_prop_set(props, &i, DRM_XE_OA_PROPERTY_OA_PERIOD_EXPONENT, period_exponent);
|
||||
if (hold_preemption)
|
||||
perf_prop_set(props, &i, DRM_XE_OA_PROPERTY_NO_PREEMPT, hold_preemption);
|
||||
oa_prop_set(props, &i, DRM_XE_OA_PROPERTY_NO_PREEMPT, hold_preemption);
|
||||
|
||||
fd = intel_ioctl(drm_fd, DRM_IOCTL_XE_PERF, &perf_param);
|
||||
fd = intel_ioctl(drm_fd, DRM_IOCTL_XE_OBSERVATION, &observation_param);
|
||||
if (fd < 0)
|
||||
return fd;
|
||||
|
||||
@ -174,7 +174,8 @@ xe_perf_stream_open(struct intel_perf_config *perf_config, int drm_fd,
|
||||
int
|
||||
xe_perf_stream_set_state(int perf_stream_fd, bool enable)
|
||||
{
|
||||
unsigned long uapi = enable ? DRM_XE_PERF_IOCTL_ENABLE : DRM_XE_PERF_IOCTL_DISABLE;
|
||||
unsigned long uapi = enable ? DRM_XE_OBSERVATION_IOCTL_ENABLE :
|
||||
DRM_XE_OBSERVATION_IOCTL_DISABLE;
|
||||
|
||||
return intel_ioctl(perf_stream_fd, uapi, 0);
|
||||
}
|
||||
@ -185,9 +186,9 @@ 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,
|
||||
oa_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,
|
||||
return intel_ioctl(perf_stream_fd, DRM_XE_OBSERVATION_IOCTL_CONFIG,
|
||||
(void *)(uintptr_t)&prop);
|
||||
}
|
||||
|
||||
@ -198,7 +199,7 @@ xe_perf_stream_read_error(int perf_stream_fd, uint8_t *buffer, size_t buffer_len
|
||||
struct intel_perf_record_header *header;
|
||||
int ret;
|
||||
|
||||
ret = intel_ioctl(perf_stream_fd, DRM_XE_PERF_IOCTL_STATUS, &status);
|
||||
ret = intel_ioctl(perf_stream_fd, DRM_XE_OBSERVATION_IOCTL_STATUS, &status);
|
||||
if (ret)
|
||||
return -errno;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user