[PATCH 16/18] drm/xe/eudebug: Implement vm_bind_op discovery
Mika Kuoppala
mika.kuoppala at linux.intel.com
Tue Oct 1 14:43:04 UTC 2024
Follow the vm bind, vm_bind op sequence for
discovery process of a vm with the vmas it has.
Send events for ops and attach metadata if available.
v2: - Fix bad op ref seqno (Christoph)
- with discovery semaphore, we dont need vm lock (Matthew)
Cc: Matthew Brost <matthew.brost at intel.com>
Signed-off-by: Mika Kuoppala <mika.kuoppala at linux.intel.com>
---
drivers/gpu/drm/xe/xe_eudebug.c | 45 +++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/drivers/gpu/drm/xe/xe_eudebug.c b/drivers/gpu/drm/xe/xe_eudebug.c
index 368e1a987f7a..faa49ba55b78 100644
--- a/drivers/gpu/drm/xe/xe_eudebug.c
+++ b/drivers/gpu/drm/xe/xe_eudebug.c
@@ -3153,6 +3153,47 @@ void xe_eudebug_debug_metadata_destroy(struct xe_file *xef, struct xe_debug_meta
xe_eudebug_event_put(d, debug_metadata_destroy_event(d, xef, m));
}
+static int vm_discover_binds(struct xe_eudebug *d, struct xe_vm *vm)
+{
+ struct drm_gpuva *va;
+ unsigned int num_ops = 0, send_ops = 0;
+ u64 ref_seqno = 0;
+ int err;
+
+ /*
+ * Currently only vm_bind_ioctl inserts vma's
+ * and with discovery lock, we have exclusivity.
+ */
+ lockdep_assert_held_write(&d->xe->eudebug.discovery_lock);
+
+ drm_gpuvm_for_each_va(va, &vm->gpuvm)
+ num_ops++;
+
+ if (!num_ops)
+ return 0;
+
+ err = vm_bind_event(d, vm, num_ops, &ref_seqno);
+ if (err)
+ return err;
+
+ drm_gpuvm_for_each_va(va, &vm->gpuvm) {
+ struct xe_vma *vma = container_of(va, struct xe_vma, gpuva);
+
+ if (send_ops >= num_ops)
+ break;
+
+ err = vm_bind_op(d, vm, DRM_XE_EUDEBUG_EVENT_CREATE, ref_seqno,
+ xe_vma_start(vma), xe_vma_size(vma),
+ &vma->eudebug.metadata.list);
+ if (err)
+ return err;
+
+ send_ops++;
+ }
+
+ return num_ops == send_ops ? 0 : -EINVAL;
+}
+
static int discover_client(struct xe_eudebug *d, struct xe_file *xef)
{
struct xe_debug_metadata *m;
@@ -3175,6 +3216,10 @@ static int discover_client(struct xe_eudebug *d, struct xe_file *xef)
err = vm_create_event(d, xef, vm);
if (err)
break;
+
+ err = vm_discover_binds(d, vm);
+ if (err)
+ break;
}
xa_for_each(&xef->exec_queue.xa, i, q) {
--
2.34.1
More information about the Intel-xe
mailing list