Commit cdf02fe1 authored by Ashutosh Dixit's avatar Ashutosh Dixit

drm/xe/oa/uapi: Add/remove OA config perf ops

Introduce add/remove config perf ops for OA. OA configurations consist of a
set of event/counter select register address/value pairs. The add_config
perf op validates and stores such configurations and also exposes them in
the metrics sysfs. These configurations will be programmed to OA unit HW
when an OA stream using a configuration is opened. The OA stream can also
switch to other stored configurations.

v2: Start config id's from 1 and other minor review comments (Umesh)
v3: Add 32 bit build
v4: Add kernel doc for non-static functions (Michal)
Acked-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
Acked-by: default avatarJosé Roberto de Souza <jose.souza@intel.com>
Reviewed-by: default avatarUmesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Signed-off-by: default avatarAshutosh Dixit <ashutosh.dixit@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240618014609.3233427-6-ashutosh.dixit@intel.com
parent a9f905ae
......@@ -670,6 +670,8 @@ int xe_device_probe(struct xe_device *xe)
xe_display_register(xe);
xe_oa_register(xe);
xe_debugfs_register(xe);
xe_hwmon_register(xe);
......@@ -710,6 +712,8 @@ void xe_device_remove(struct xe_device *xe)
struct xe_gt *gt;
u8 id;
xe_oa_unregister(xe);
xe_device_remove_display(xe);
xe_display_fini(xe);
......
This diff is collapsed.
......@@ -8,9 +8,15 @@
#include "xe_oa_types.h"
struct drm_device;
struct drm_file;
struct xe_device;
int xe_oa_init(struct xe_device *xe);
void xe_oa_fini(struct xe_device *xe);
void xe_oa_register(struct xe_device *xe);
void xe_oa_unregister(struct xe_device *xe);
int xe_oa_add_config_ioctl(struct drm_device *dev, u64 data, struct drm_file *file);
int xe_oa_remove_config_ioctl(struct drm_device *dev, u64 data, struct drm_file *file);
#endif
......@@ -7,6 +7,7 @@
#define _XE_OA_TYPES_H_
#include <linux/bitops.h>
#include <linux/idr.h>
#include <linux/mutex.h>
#include <linux/types.h>
......@@ -125,6 +126,15 @@ struct xe_oa {
/** @xe: back pointer to xe device */
struct xe_device *xe;
/** @metrics_kobj: kobj for metrics sysfs */
struct kobject *metrics_kobj;
/** @metrics_lock: lock protecting add/remove configs */
struct mutex metrics_lock;
/** @metrics_idr: List of dynamic configurations (struct xe_oa_config) */
struct idr metrics_idr;
/** @oa_formats: tracks all OA formats across platforms */
const struct xe_oa_format *oa_formats;
......
......@@ -8,11 +8,25 @@
#include <drm/xe_drm.h>
#include "xe_oa.h"
#include "xe_perf.h"
u32 xe_perf_stream_paranoid = true;
static struct ctl_table_header *sysctl_header;
static int xe_oa_ioctl(struct drm_device *dev, struct drm_xe_perf_param *arg,
struct drm_file *file)
{
switch (arg->perf_op) {
case DRM_XE_PERF_OP_ADD_CONFIG:
return xe_oa_add_config_ioctl(dev, arg->param, file);
case DRM_XE_PERF_OP_REMOVE_CONFIG:
return xe_oa_remove_config_ioctl(dev, arg->param, file);
default:
return -EINVAL;
}
}
/**
* xe_perf_ioctl - The top level perf layer ioctl
* @dev: @drm_device
......@@ -32,6 +46,8 @@ int xe_perf_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
return -EINVAL;
switch (arg->perf_type) {
case DRM_XE_PERF_TYPE_OA:
return xe_oa_ioctl(dev, arg, file);
default:
return -EINVAL;
}
......
......@@ -1378,6 +1378,7 @@ struct drm_xe_wait_user_fence {
* enum drm_xe_perf_type - Perf stream types
*/
enum drm_xe_perf_type {
DRM_XE_PERF_TYPE_OA,
__DRM_XE_PERF_TYPE_MAX, /* non-ABI */
};
......@@ -1469,6 +1470,30 @@ enum drm_xe_oa_format_type {
DRM_XE_OA_FMT_TYPE_PEC,
};
/**
* struct drm_xe_oa_config - OA metric configuration
*
* Multiple OA configs can be added using @DRM_XE_PERF_OP_ADD_CONFIG. A
* particular config can be specified when opening an OA stream using
* @DRM_XE_OA_PROPERTY_OA_METRIC_SET property.
*/
struct drm_xe_oa_config {
/** @extensions: Pointer to the first extension struct, if any */
__u64 extensions;
/** @uuid: String formatted like "%\08x-%\04x-%\04x-%\04x-%\012x" */
char uuid[36];
/** @n_regs: Number of regs in @regs_ptr */
__u32 n_regs;
/**
* @regs_ptr: Pointer to (register address, value) pairs for OA config
* registers. Expected length of buffer is: (2 * sizeof(u32) * @n_regs).
*/
__u64 regs_ptr;
};
#if defined(__cplusplus)
}
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment