diff --git a/.pick_status.json b/.pick_status.json index eb56f524b63..900f6034816 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -427,7 +427,7 @@ "description": "iris: fix race condition during busy tracking", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "89a34cb8450a6fdaceb0e537613871fa86d93132" }, diff --git a/src/gallium/drivers/iris/iris_batch.c b/src/gallium/drivers/iris/iris_batch.c index 26a07df1a02..f4a52f04ce6 100644 --- a/src/gallium/drivers/iris/iris_batch.c +++ b/src/gallium/drivers/iris/iris_batch.c @@ -882,11 +882,6 @@ update_bo_syncobjs(struct iris_batch *batch, struct iris_bo *bo, bool write) static void update_batch_syncobjs(struct iris_batch *batch) { - struct iris_bufmgr *bufmgr = batch->screen->bufmgr; - simple_mtx_t *bo_deps_lock = iris_bufmgr_get_bo_deps_lock(bufmgr); - - simple_mtx_lock(bo_deps_lock); - for (int i = 0; i < batch->exec_count; i++) { struct iris_bo *bo = batch->exec_bos[i]; bool write = BITSET_TEST(batch->bos_written, i); @@ -896,7 +891,6 @@ update_batch_syncobjs(struct iris_batch *batch) update_bo_syncobjs(batch, bo, write); } - simple_mtx_unlock(bo_deps_lock); } /** @@ -905,6 +899,9 @@ update_batch_syncobjs(struct iris_batch *batch) static int submit_batch(struct iris_batch *batch) { + struct iris_bufmgr *bufmgr = batch->screen->bufmgr; + simple_mtx_t *bo_deps_lock = iris_bufmgr_get_bo_deps_lock(bufmgr); + iris_bo_unmap(batch->bo); struct drm_i915_gem_exec_object2 *validation_list = @@ -938,15 +935,22 @@ submit_batch(struct iris_batch *batch) free(index_for_handle); + /* The decode operation may map and wait on the batch buffer, which could + * in theory try to grab bo_deps_lock. Let's keep it safe and decode + * outside the lock. + */ + if (INTEL_DEBUG(DEBUG_BATCH)) + decode_batch(batch); + + simple_mtx_lock(bo_deps_lock); + + update_batch_syncobjs(batch); + if (INTEL_DEBUG(DEBUG_BATCH | DEBUG_SUBMIT)) { dump_fence_list(batch); dump_bo_list(batch); } - if (INTEL_DEBUG(DEBUG_BATCH)) { - decode_batch(batch); - } - /* The requirement for using I915_EXEC_NO_RELOC are: * * The addresses written in the objects must match the corresponding @@ -984,6 +988,8 @@ submit_batch(struct iris_batch *batch) intel_ioctl(batch->screen->fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf)) ret = -errno; + simple_mtx_unlock(bo_deps_lock); + for (int i = 0; i < batch->exec_count; i++) { struct iris_bo *bo = batch->exec_bos[i]; @@ -1029,8 +1035,6 @@ _iris_batch_flush(struct iris_batch *batch, const char *file, int line) iris_finish_batch(batch); - update_batch_syncobjs(batch); - if (INTEL_DEBUG(DEBUG_BATCH | DEBUG_SUBMIT | DEBUG_PIPE_CONTROL)) { const char *basefile = strstr(file, "iris/"); if (basefile)