anv: fix utrace signaling with Xe
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Tue, 11 Jul 2023 09:36:15 +0000 (12:36 +0300)
committerMarge Bot <emma+marge@anholt.net>
Tue, 11 Jul 2023 16:27:06 +0000 (16:27 +0000)
utrace submits can either have a batch or not.

When there is a batch, the utrace vk_sync is signaled by the utrace
batch (because utrace does a timestamp buffer copy using its own
batch). When there is no batch, the utrace vk_sync should be signaled
by the application batch (no timestamp copy required, utrace can read
the timestamps when the application batch has completed).

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Fixes: fdea48df5e ("anv: Implement Xe version of anv_queue_exec_locked() and queue_exec_trace()")
Reviewed-by: José Roberto de Souza <jose.souza@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24085>

src/intel/vulkan/xe/anv_batch_chain.c

index bad00dce2c0e1d94e843dc82b42c617c73f2c52f..dbcf989d7c3005c5de71303a50ed29e6b67cd0ae 100644 (file)
@@ -119,7 +119,10 @@ xe_exec_process_syncs(struct anv_queue *queue,
 
    uint32_t count = 0;
 
-   if (utrace_submit) {
+   /* Signal the utrace sync only if it doesn't have a batch. Otherwise the
+    * it's the utrace batch that should signal its own sync.
+    */
+   if (utrace_submit && !utrace_submit->batch_bo) {
       struct drm_xe_sync *xe_sync = &xe_syncs[count++];
 
       xe_exec_fill_sync(xe_sync, utrace_submit->sync, 0, TYPE_SIGNAL);
@@ -217,9 +220,6 @@ xe_queue_exec_locked(struct anv_queue *queue,
    if (result != VK_SUCCESS)
       return result;
 
-   if (utrace_submit && !utrace_submit->batch_bo)
-      utrace_submit = NULL;
-
    struct drm_xe_sync *xe_syncs = NULL;
    uint32_t xe_syncs_count = 0;
    result = xe_exec_process_syncs(queue, wait_count, waits,
@@ -229,6 +229,10 @@ xe_queue_exec_locked(struct anv_queue *queue,
    if (result != VK_SUCCESS)
       return result;
 
+   /* If we have no batch for utrace, just forget about it now. */
+   if (utrace_submit && !utrace_submit->batch_bo)
+      utrace_submit = NULL;
+
    struct drm_xe_exec exec = {
       .engine_id = queue->engine_id,
       .num_batch_buffer = 1,