iris: Switch to truly asynchronous VM binding in Xe KMD

Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26805>
This commit is contained in:
José Roberto de Souza
2023-12-22 12:41:51 -08:00
committed by Marge Bot
parent 3579413aed
commit bde9a16ce8

View File

@@ -113,11 +113,6 @@ xe_gem_vm_bind_op(struct iris_bo *bo, uint32_t op)
.type = DRM_XE_SYNC_TYPE_TIMELINE_SYNCOBJ, .type = DRM_XE_SYNC_TYPE_TIMELINE_SYNCOBJ,
.flags = DRM_XE_SYNC_FLAG_SIGNAL, .flags = DRM_XE_SYNC_FLAG_SIGNAL,
}; };
struct drm_syncobj_timeline_wait syncobj_wait = {
.timeout_nsec = INT64_MAX,
.handles = (uintptr_t)&xe_sync.handle,
.count_handles = 1,
};
uint64_t range, obj_offset = 0; uint64_t range, obj_offset = 0;
int ret, fd; int ret, fd;
@@ -156,11 +151,6 @@ xe_gem_vm_bind_op(struct iris_bo *bo, uint32_t op)
ret = intel_ioctl(fd, DRM_IOCTL_XE_VM_BIND, &args); ret = intel_ioctl(fd, DRM_IOCTL_XE_VM_BIND, &args);
intel_bind_timeline_bind_end(bind_timeline); intel_bind_timeline_bind_end(bind_timeline);
if (ret == 0) {
syncobj_wait.points = (uintptr_t)&xe_sync.timeline_value;
ret = intel_ioctl(fd, DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT, &syncobj_wait);
}
if (ret) if (ret)
DBG("vm_bind_op: DRM_IOCTL_XE_VM_BIND failed(%i)", ret); DBG("vm_bind_op: DRM_IOCTL_XE_VM_BIND failed(%i)", ret);
@@ -338,11 +328,12 @@ static int
xe_batch_submit(struct iris_batch *batch) xe_batch_submit(struct iris_batch *batch)
{ {
struct iris_bufmgr *bufmgr = batch->screen->bufmgr; struct iris_bufmgr *bufmgr = batch->screen->bufmgr;
struct intel_bind_timeline *bind_timeline = iris_bufmgr_get_bind_timeline(bufmgr);
simple_mtx_t *bo_deps_lock = iris_bufmgr_get_bo_deps_lock(bufmgr); simple_mtx_t *bo_deps_lock = iris_bufmgr_get_bo_deps_lock(bufmgr);
struct iris_implicit_sync implicit_sync = {}; struct iris_implicit_sync implicit_sync = {};
struct drm_xe_sync *syncs = NULL; struct drm_xe_sync *syncs = NULL;
unsigned long sync_len; unsigned long sync_len;
int ret; int ret, i;
iris_bo_unmap(batch->bo); iris_bo_unmap(batch->bo);
@@ -362,19 +353,15 @@ xe_batch_submit(struct iris_batch *batch)
if (ret) if (ret)
goto error_implicit_sync_import; goto error_implicit_sync_import;
sync_len = iris_batch_num_fences(batch); sync_len = iris_batch_num_fences(batch) + 1 /* vm bind sync */;
if (sync_len) {
unsigned long i = 0;
syncs = calloc(sync_len, sizeof(*syncs)); syncs = calloc(sync_len, sizeof(*syncs));
if (!syncs) { if (!syncs) {
ret = -ENOMEM; ret = -ENOMEM;
goto error_no_sync_mem; goto error_no_sync_mem;
} }
util_dynarray_foreach(&batch->exec_fences, struct iris_batch_fence, i = 0;
fence) { util_dynarray_foreach(&batch->exec_fences, struct iris_batch_fence, fence) {
if (fence->flags & IRIS_BATCH_FENCE_SIGNAL) if (fence->flags & IRIS_BATCH_FENCE_SIGNAL)
syncs[i].flags = DRM_XE_SYNC_FLAG_SIGNAL; syncs[i].flags = DRM_XE_SYNC_FLAG_SIGNAL;
@@ -382,7 +369,10 @@ xe_batch_submit(struct iris_batch *batch)
syncs[i].type = DRM_XE_SYNC_TYPE_SYNCOBJ; syncs[i].type = DRM_XE_SYNC_TYPE_SYNCOBJ;
i++; i++;
} }
}
syncs[i].handle = intel_bind_timeline_get_syncobj(bind_timeline);
syncs[i].type = DRM_XE_SYNC_TYPE_TIMELINE_SYNCOBJ;
syncs[i].timeline_value = intel_bind_timeline_get_last_point(bind_timeline);
if ((INTEL_DEBUG(DEBUG_BATCH) && if ((INTEL_DEBUG(DEBUG_BATCH) &&
intel_debug_batch_in_range(batch->ice->frame)) || intel_debug_batch_in_range(batch->ice->frame)) ||