[Intel-xe] [RFC 24/25] drm/xe/xe_eudebug: Add vm bind events w/o acking
Mika Kuoppala
mika.kuoppala at linux.intel.com
Mon Nov 6 11:18:44 UTC 2023
From: Christoph Manszewski <christoph.manszewski at intel.com>
TODO:
- reduce code duplication in xe_eudebug bind/unbind functions
- rebase on latest eudebug-dev
- address XXX
Signed-off-by: Christoph Manszewski <christoph.manszewski at intel.com>
---
drivers/gpu/drm/xe/xe_eudebug.c | 93 +++++++++++++++++++++++++++
drivers/gpu/drm/xe/xe_eudebug.h | 4 ++
drivers/gpu/drm/xe/xe_eudebug_types.h | 13 ++++
drivers/gpu/drm/xe/xe_vm.c | 5 ++
include/uapi/drm/xe_drm_tmp.h | 22 +++++--
5 files changed, 131 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_eudebug.c b/drivers/gpu/drm/xe/xe_eudebug.c
index 886da91ea0a4..57a3cf59aaba 100644
--- a/drivers/gpu/drm/xe/xe_eudebug.c
+++ b/drivers/gpu/drm/xe/xe_eudebug.c
@@ -1983,6 +1983,99 @@ void xe_eudebug_exec_queue_destroy(struct xe_file *xef, struct xe_exec_queue *q)
xe_eudebug_put(d);
}
+static int send_vm_bind_event(struct xe_eudebug *d, u32 flags, u64 client_handle, u64 vm_handle,
+ u64 va_start, u64 va_length)
+{
+ struct xe_eudebug_event_vm_bind *e;
+ struct xe_eudebug_event *event;
+
+ const u32 sz = sizeof(*e);
+
+ event = xe_eudebug_create_event(d, DRM_XE_EUDEBUG_EVENT_VM_BIND,
+ flags, sz, GFP_KERNEL);
+ if (!event)
+ return -ENOMEM;
+
+ e = from_event(e, event);
+
+ write_member(struct drm_xe_eudebug_event_vm_bind, e, client_handle, client_handle);
+ write_member(struct drm_xe_eudebug_event_vm_bind, e, vm_handle, vm_handle);
+ write_member(struct drm_xe_eudebug_event_vm_bind, e, va_start, va_start);
+ write_member(struct drm_xe_eudebug_event_vm_bind, e, va_length, va_length);
+
+ return xe_eudebug_queue_event(d, event);
+}
+
+static int vm_bind_event(struct xe_eudebug *d, struct xe_file *xef, struct xe_vm *vm,
+ struct xe_vma *vma)
+{
+ int h_c, h_vm;
+
+ h_c = find_handle(d->res, XE_EUDEBUG_RES_TYPE_CLIENT, xef);
+ if (h_c < 0)
+ return h_c;
+
+ h_vm = find_handle(d->res, XE_EUDEBUG_RES_TYPE_VM, vm);
+ if (h_vm < 0)
+ return h_vm;
+
+ return send_vm_bind_event(d, DRM_XE_EUDEBUG_EVENT_CREATE, h_c, h_vm, vma->gpuva.va.addr,
+ vma->gpuva.va.range);
+}
+
+static int vm_unbind_event(struct xe_eudebug *d, struct xe_file *xef, struct xe_vm *vm,
+ struct xe_vma *vma)
+{
+ int h_c, h_vm;
+
+ h_c = find_handle(d->res, XE_EUDEBUG_RES_TYPE_CLIENT, xef);
+ if (h_c < 0)
+ return h_c;
+
+ h_vm = find_handle(d->res, XE_EUDEBUG_RES_TYPE_VM, vm);
+ if (h_vm < 0)
+ return h_vm;
+
+ return send_vm_bind_event(d, DRM_XE_EUDEBUG_EVENT_DESTROY, h_c, h_vm, vma->gpuva.va.addr,
+ vma->gpuva.va.range);
+}
+
+void xe_eudebug_vm_bind(struct xe_file *xef, struct xe_vm *vm, struct xe_vma *vma)
+{
+ struct xe_eudebug *d;
+ int err;
+
+ d = xe_eudebug_get(xef);
+ if (!d)
+ return;
+
+ err = vm_bind_event(d, xef, vm, vma);
+ if (err) {
+ eu_err(d, "error %d on %s, disconnecting", err, __func__);
+ xe_eudebug_disconnect(d, err);
+ }
+
+ xe_eudebug_put(d);
+}
+
+void xe_eudebug_vm_unbind(struct xe_file *xef, struct xe_vm *vm, struct xe_vma *vma)
+{
+ struct xe_eudebug *d;
+ int err;
+
+ d = xe_eudebug_get(xef);
+ if (!d)
+ return;
+
+ err = vm_unbind_event(d, xef, vm, vma);
+ if (err) {
+ eu_err(d, "error %d on %s, disconnecting", err, __func__);
+ xe_eudebug_disconnect(d, err);
+ }
+
+ xe_eudebug_put(d);
+}
+
static int discover_client(struct xe_eudebug *d, struct xe_file *xef)
{
struct xe_exec_queue *q;
diff --git a/drivers/gpu/drm/xe/xe_eudebug.h b/drivers/gpu/drm/xe/xe_eudebug.h
index ac89a3d1ee1d..0f5e04603c9d 100644
--- a/drivers/gpu/drm/xe/xe_eudebug.h
+++ b/drivers/gpu/drm/xe/xe_eudebug.h
@@ -10,6 +10,7 @@ struct drm_file;
struct xe_device;
struct xe_file;
struct xe_vm;
+struct xe_vma;
struct xe_exec_queue;
struct xe_hw_engine;
@@ -30,4 +31,7 @@ void xe_eudebug_vm_destroy(struct xe_file *xef, struct xe_vm *vm);
void xe_eudebug_exec_queue_create(struct xe_file *xef, struct xe_exec_queue *q);
void xe_eudebug_exec_queue_destroy(struct xe_file *xef, struct xe_exec_queue *q);
+void xe_eudebug_vm_bind(struct xe_file *xef, struct xe_vm *vm, struct xe_vma *vma);
+void xe_eudebug_vm_unbind(struct xe_file *xef, struct xe_vm *vm, struct xe_vma *vma);
+
#endif
diff --git a/drivers/gpu/drm/xe/xe_eudebug_types.h b/drivers/gpu/drm/xe/xe_eudebug_types.h
index d5103ec4648e..73016a940585 100644
--- a/drivers/gpu/drm/xe/xe_eudebug_types.h
+++ b/drivers/gpu/drm/xe/xe_eudebug_types.h
@@ -129,6 +129,19 @@ struct xe_eudebug_event_eu_attention {
u8 bitmask[0];
} __packed;
+/**
+ * struct xe_eudebug_event_vm_bind - Internal event for vm bind/unbind operation
+ */
+struct xe_eudebug_event_vm_bind {
+ /** @base: base event */
+ struct xe_eudebug_event base;
+ u64 client_handle;
+
+ u64 vm_handle;
+ u64 va_start;
+ u64 va_length;
+} __packed;
+
/**
* struct xe_eudebug_handle - eudebug resource handle
*/
diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
index 480427a30b05..f8c3f3efd12e 100644
--- a/drivers/gpu/drm/xe/xe_vm.c
+++ b/drivers/gpu/drm/xe/xe_vm.c
@@ -1882,6 +1882,9 @@ static int __xe_vm_bind(struct xe_vm *vm, struct xe_vma *vma,
dma_fence_wait(fence, true);
dma_fence_put(fence);
+ /* XXX: get's also called for prefetch */
+ xe_eudebug_vm_bind(vm->xef, vm, vma);
+
return 0;
}
@@ -1919,6 +1922,8 @@ static int xe_vm_unbind(struct xe_vm *vm, struct xe_vma *vma,
if (IS_ERR(fence))
return PTR_ERR(fence);
+ xe_eudebug_vm_unbind(vm->xef, vm, vma);
+
xe_vma_destroy(vma, fence);
if (last_op)
xe_exec_queue_last_fence_set(wait_exec_queue, vm, fence);
diff --git a/include/uapi/drm/xe_drm_tmp.h b/include/uapi/drm/xe_drm_tmp.h
index 776ec9d0f32f..093884b70ca6 100644
--- a/include/uapi/drm/xe_drm_tmp.h
+++ b/include/uapi/drm/xe_drm_tmp.h
@@ -28,13 +28,14 @@ struct drm_xe_eudebug_event {
__u32 len;
__u16 type;
-#define DRM_XE_EUDEBUG_EVENT_NONE 0
-#define DRM_XE_EUDEBUG_EVENT_READ 1
-#define DRM_XE_EUDEBUG_EVENT_OPEN 2
-#define DRM_XE_EUDEBUG_EVENT_VM 3
+#define DRM_XE_EUDEBUG_EVENT_NONE 0
+#define DRM_XE_EUDEBUG_EVENT_READ 1
+#define DRM_XE_EUDEBUG_EVENT_OPEN 2
+#define DRM_XE_EUDEBUG_EVENT_VM 3
#define DRM_XE_EUDEBUG_EVENT_EXEC_QUEUE 4
-#define DRM_XE_EUDEBUG_EVENT_EU_ATTENTION 5
-#define DRM_XE_EUDEBUG_EVENT_MAX_EVENT DRM_XE_EUDEBUG_EVENT_EU_ATTENTION
+#define DRM_XE_EUDEBUG_EVENT_EU_ATTENTION 5
+#define DRM_XE_EUDEBUG_EVENT_VM_BIND 6
+#define DRM_XE_EUDEBUG_EVENT_MAX_EVENT DRM_XE_EUDEBUG_EVENT_VM_BIND
__u16 flags;
#define DRM_XE_EUDEBUG_EVENT_CREATE BIT(0)
@@ -79,6 +80,15 @@ struct drm_xe_eudebug_event_eu_attention {
__u8 bitmask[0];
} __attribute__((packed));
+struct drm_xe_eudebug_event_vm_bind {
+ struct drm_xe_eudebug_event base;
+ __u64 client_handle;
+
+ __u64 vm_handle;
+ __u64 va_start;
+ __u64 va_length;
+} __attribute__((packed));
+
struct drm_xe_eudebug_event_metadata {
struct drm_xe_eudebug_event base;
--
2.34.1
More information about the Intel-xe
mailing list