[RFC 16/19] drm/xe/eudebug: Implement vm_bind_op discovery
Gwan-gyeong Mun
gwan-gyeong.mun at intel.com
Mon Oct 21 09:58:55 UTC 2024
From: Mika Kuoppala <mika.kuoppala at linux.intel.com>
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>
Signed-off-by: Gwan-gyeong Mun <gwan-gyeong.mun at 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 35ab65ef9c80..9ef1e5d9c65d 100644
--- a/drivers/gpu/drm/xe/xe_eudebug.c
+++ b/drivers/gpu/drm/xe/xe_eudebug.c
@@ -3154,6 +3154,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;
@@ -3176,6 +3217,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.46.1
More information about the Intel-xe
mailing list