which does stream performance monitoring.
Signed-off-by: James Zhu <[email protected]>
---
include/uapi/drm/amdgpu_drm.h | 93 +++++++++++++++++++++++++++++++++++
1 file changed, 93 insertions(+)
diff --git a/include/uapi/drm/amdgpu_drm.h b/include/uapi/drm/amdgpu_drm.h
index dfc98d6d98a8..83f116d61df9 100644
--- a/include/uapi/drm/amdgpu_drm.h
+++ b/include/uapi/drm/amdgpu_drm.h
@@ -1710,17 +1710,110 @@ struct drm_color_ctm_3x4 {
__u64 matrix[12];
};
+/*
+ * Supported SPM (Stream Performance Monitor) Operations
+ */
+/**
+ * drm_amdgpu_spm_op - SPM ioctl operations
+ *
+ * @AMDGPU_SPM_OP_ACQUIRE: acquire exclusive access to SPM
+ * @AMDGPU_SPM_OP_RELEASE: release exclusive access to SPM
+ * @AMDGPU_SPM_OP_SET_DEST_BUF: set or unset destination buffer for SPM
streaming
+ */
+enum drm_amdgpu_spm_op {
+ AMDGPU_SPM_OP_ACQUIRE,
+ AMDGPU_SPM_OP_RELEASE,
+ AMDGPU_SPM_OP_SET_DEST_BUF
+};
+
+/**
+ * drm_amdgpu_spm_args - Arguments for SPM ioctl
+ *
+ * @op[in]: specifies the operation to perform
+ * @dst_buf[in]: used for the address of the destination buffer
+ * in @AMDGPU_SPM_SET_DEST_BUFFER
+ * @buf_size[in]: size of the destination buffer
+ * @timeout[in/out]: [in]: timeout in milliseconds, [out]: amount of time
left
+ * `in the timeout window
+ * @bytes_copied[out]: total amount of data that was copied to the previous
dest_buf
+ * @has_data_loss: total count for sub-block which has data loss
+ *
+ * This ioctl performs different functions depending on the @op parameter.
+ *
+ * AMDGPU_SPM_OP_ACQUIRE
+ * ------------------------
+ *
+ * Acquires exclusive access of SPM on the specified for the calling process.
+ * This must be called before using AMDGPU_SPM_OP_SET_DEST_BUF.
+ *
+ * AMDGPU_SPM_OP_RELEASE
+ * ------------------------
+ *
+ * Releases exclusive access of SPM on the specified for the calling process,
+ * which allows another process to acquire it in the future.
+ *
+ * AMDGPU_SPM_OP_SET_DEST_BUF
+ * -----------------------------
+ *
+ * If @dst_buf is NULL, the destination buffer address is unset and copying of
counters
+ * is stopped.
+ *
+ * If @dst_buf is not NULL, it specifies the pointer to a new destination
buffer.
+ * @buf_size specifies the size of the buffer.
+ *
+ * If @timeout is non-0, the call will wait for up to @timeout ms for the
previous
+ * buffer to be filled. If previous buffer to be filled before timeout, the
@timeout
+ * will be updated value with the time remaining. If the timeout is exceeded,
the function
+ * copies any partial data available into the previous user buffer and returns
success.
+ * The amount of valid data in the previous user buffer is indicated by
@bytes_copied.
+ *
+ * If @timeout is 0, the function immediately replaces the previous
destination buffer
+ * without waiting for the previous buffer to be filled. That means the
previous buffer
+ * may only be partially filled, and @bytes_copied will indicate how much data
has been
+ * copied to it.
+ *
+ * If data was lost, e.g. due to a ring buffer overflow, @has_data_loss will
be non-0.
+ *
+ * Returns negative error code on failure, 0 on success.
+ */
+struct drm_amdgpu_spm_args {
+ __u64 dest_buf;
+ __u32 buf_size;
+ __u32 op;
+ __u32 timeout;
+ __u32 bytes_copied;
+ __u32 has_data_loss;
+ __u32 pad;
+};
+
+/**
+ * drm_amdgpu_spm_buffer_header - SPM Buffer header for
drm_amdgpu_spm_args->dest_buf
+ *
+ * @version [out]: spm version
+ * @bytes_copied [out]: amount of data for each sub-block
+ * @has_data_loss: [out]: boolean indicating whether data was lost for each
sub-block
+ * (e.g. due to a ring-buffer overflow)
+ */
+struct drm_amdgpu_spm_buffer_header {
+ __u32 version; /* 0-23: minor 24-31: major */
+ __u32 bytes_copied;
+ __u32 has_data_loss;
+ __u32 reserved[5];
+};
+
/*
* Supported Profiler Operations
*/
enum drm_amdgpu_profiler_ops {
AMDGPU_PROFILER_VERSION = 0,
+ AMDGPU_PROFILER_SPM,
};
struct drm_amdgpu_profiler_args {
__u32 op; /* amdgpu_profiler_op */
union {
__u32 version; /* lower 16 bit: minor. higher 16 bit:
major */
+ struct drm_amdgpu_spm_args spm;
};
};
--
2.34.1