[PATCH v5 6/7] drm/xe/query: Add a device query to get EU stall data information
Harish Chegondi
harish.chegondi at intel.com
Mon Nov 18 09:07:18 UTC 2024
User space can find the EU stall data record size and capabilities
with the DRM_IOCTL_XE_DEVICE_QUERY with .query set to
DRM_XE_DEVICE_QUERY_EU_STALL. query data is returned in
a struct drm_xe_query_eu_stall.
Any capabilities in EU stall sampling as of this patch are considered
as base capabilities. Any new capabilities added later will need
a new capabilities flag.
Signed-off-by: Harish Chegondi <harish.chegondi at intel.com>
---
drivers/gpu/drm/xe/xe_eu_stall.c | 2 +-
drivers/gpu/drm/xe/xe_eu_stall.h | 2 ++
drivers/gpu/drm/xe/xe_query.c | 30 ++++++++++++++++++++++++++++++
include/uapi/drm/xe_drm.h | 23 +++++++++++++++++++++++
4 files changed, 56 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/xe/xe_eu_stall.c b/drivers/gpu/drm/xe/xe_eu_stall.c
index 9169a31f620c..297b36910296 100644
--- a/drivers/gpu/drm/xe/xe_eu_stall.c
+++ b/drivers/gpu/drm/xe/xe_eu_stall.c
@@ -109,7 +109,7 @@ struct drm_xe_eu_stall_data_xe2 {
__u64 unused[6];
} __packed;
-static unsigned long
+unsigned long
xe_eu_stall_data_record_size(struct xe_device *xe)
{
enum xe_platform platform = xe->info.platform;
diff --git a/drivers/gpu/drm/xe/xe_eu_stall.h b/drivers/gpu/drm/xe/xe_eu_stall.h
index d9482e1b522b..48061778263b 100644
--- a/drivers/gpu/drm/xe/xe_eu_stall.h
+++ b/drivers/gpu/drm/xe/xe_eu_stall.h
@@ -53,4 +53,6 @@ void xe_eu_stall_fini(struct xe_gt *gt);
int xe_eu_stall_stream_open(struct drm_device *dev,
u64 data,
struct drm_file *file);
+unsigned long
+xe_eu_stall_data_record_size(struct xe_device *xe);
#endif
diff --git a/drivers/gpu/drm/xe/xe_query.c b/drivers/gpu/drm/xe/xe_query.c
index 3eda616f1502..8c4f7f961dbe 100644
--- a/drivers/gpu/drm/xe/xe_query.c
+++ b/drivers/gpu/drm/xe/xe_query.c
@@ -26,6 +26,7 @@
#include "xe_oa.h"
#include "xe_ttm_vram_mgr.h"
#include "xe_wa.h"
+#include "xe_eu_stall.h"
static const u16 xe_to_user_engine_class[] = {
[XE_ENGINE_CLASS_RENDER] = DRM_XE_ENGINE_CLASS_RENDER,
@@ -696,6 +697,34 @@ static int query_oa_units(struct xe_device *xe,
return ret ? -EFAULT : 0;
}
+static int query_eu_stall_data(struct xe_device *xe,
+ struct drm_xe_device_query *query)
+{
+ size_t size = sizeof(struct drm_xe_query_eu_stall);
+ void __user *query_ptr = u64_to_user_ptr(query->data);
+ struct drm_xe_query_eu_stall *info;
+ int ret;
+
+ if (query->size == 0) {
+ query->size = size;
+ return 0;
+ } else if (XE_IOCTL_DBG(xe, query->size != size)) {
+ return -EINVAL;
+ }
+
+ info = kzalloc(size, GFP_KERNEL);
+ if (!info)
+ return -ENOMEM;
+
+ info->capabilities = DRM_XE_EU_STALL_CAPS_BASE;
+ info->record_size = xe_eu_stall_data_record_size(xe);
+
+ ret = copy_to_user(query_ptr, info, size);
+ kfree(info);
+
+ return ret ? -EFAULT : 0;
+}
+
static int (* const xe_query_funcs[])(struct xe_device *xe,
struct drm_xe_device_query *query) = {
query_engines,
@@ -707,6 +736,7 @@ static int (* const xe_query_funcs[])(struct xe_device *xe,
query_engine_cycles,
query_uc_fw_version,
query_oa_units,
+ query_eu_stall_data,
};
int xe_query_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
diff --git a/include/uapi/drm/xe_drm.h b/include/uapi/drm/xe_drm.h
index 80aaa5b50c8a..8fffd05d2c7e 100644
--- a/include/uapi/drm/xe_drm.h
+++ b/include/uapi/drm/xe_drm.h
@@ -700,6 +700,7 @@ struct drm_xe_device_query {
#define DRM_XE_DEVICE_QUERY_ENGINE_CYCLES 6
#define DRM_XE_DEVICE_QUERY_UC_FW_VERSION 7
#define DRM_XE_DEVICE_QUERY_OA_UNITS 8
+#define DRM_XE_DEVICE_QUERY_EU_STALL 9
/** @query: The type of data to query */
__u32 query;
@@ -1752,6 +1753,28 @@ enum drm_xe_eu_stall_property_id {
DRM_XE_EU_STALL_PROP_GT_ID,
};
+/**
+ * struct drm_xe_query_eu_stall - Information about EU stall data
+ *
+ * If a query is made with a struct @drm_xe_device_query where .query
+ * is equal to @DRM_XE_DEVICE_QUERY_EU_STALL, then the reply uses
+ * struct @drm_xe_query_eu_stall in .data.
+ */
+struct drm_xe_query_eu_stall {
+ /** @extensions: Pointer to the first extension struct, if any */
+ __u64 extensions;
+
+ /** @record_size: size of each EU stall data record */
+ __u64 record_size;
+
+ /** @capabilities: EU stall capabilities bit-mask */
+ __u64 capabilities;
+#define DRM_XE_EU_STALL_CAPS_BASE (1 << 0)
+
+ /** @reserved: Reserved */
+ __u64 reserved[5];
+};
+
#if defined(__cplusplus)
}
#endif
--
2.45.1
More information about the Intel-xe
mailing list