anv: Fix calculation of syncs required in Xe KMD

num_syncs was being incremented by one if 'utrace_submit != NULL' but
a sync was only being set if also
'util_dynarray_num_elements(&utrace_submit->batch_bos) == 0'.

This mismatch could cause application to abort due to
'assert(count == num_syncs)'.

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/27244>
This commit is contained in:
José Roberto de Souza
2024-01-24 08:54:47 -08:00
committed by Marge Bot
parent 38e92556a0
commit d5ec2fa52f

View File

@@ -114,9 +114,15 @@ xe_exec_process_syncs(struct anv_queue *queue,
struct drm_xe_sync **ret, uint32_t *ret_count)
{
struct anv_device *device = queue->device;
uint32_t num_syncs = wait_count + signal_count + extra_sync_count +
(utrace_submit ? 1 : 0) +
((queue->sync && !is_companion_rcs_queue) ? 1 : 0);
/* 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.
*/
const bool has_utrace_sync = utrace_submit &&
util_dynarray_num_elements(&utrace_submit->batch_bos, struct anv_bo *) == 0;
const uint32_t num_syncs = wait_count + signal_count + extra_sync_count +
(has_utrace_sync ? 1 : 0) +
((queue->sync && !is_companion_rcs_queue) ? 1 : 0);
if (!num_syncs)
return VK_SUCCESS;
@@ -128,12 +134,7 @@ xe_exec_process_syncs(struct anv_queue *queue,
uint32_t count = 0;
/* 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 &&
util_dynarray_num_elements(&utrace_submit->batch_bos,
struct anv_bo *) == 0) {
if (has_utrace_sync) {
struct drm_xe_sync *xe_sync = &xe_syncs[count++];
xe_exec_fill_sync(xe_sync, utrace_submit->sync, 0, TYPE_SIGNAL);