Skip to content

Commit 611cdf3

Browse files
ickledanvet
authored andcommitted
drm/i915: Disable EXEC_OBJECT_ASYNC when doing relocations
If we write a relocation into the buffer, we require our own implicit synchronisation added after the start of the execbuf, outside of the user's control. As we may end up clflushing, or doing the patch itself on the GPU, asynchronously we need to look at the implicit serialisation on obj->resv and hence need to disable EXEC_OBJECT_ASYNC for this object. If the user does trigger a stall for relocations, we make sure the stall is complete enough so that the batch is not submitted before we complete those relocations. Fixes: 77ae995 ("drm/i915: Enable userspace to opt-out of implicit fencing") Signed-off-by: Chris Wilson <[email protected]> Cc: Joonas Lahtinen <[email protected]> Cc: Jason Ekstrand <[email protected]> Reviewed-by: Joonas Lahtinen <[email protected]> (cherry picked from commit 071750e) [danvet: Resolve conflicts, resolution reviewed by Tvrtko on irc.] Signed-off-by: Daniel Vetter <[email protected]>
1 parent 2c73676 commit 611cdf3

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

drivers/gpu/drm/i915/i915_gem_execbuffer.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -546,11 +546,12 @@ relocate_entry(struct drm_i915_gem_object *obj,
546546
}
547547

548548
static int
549-
i915_gem_execbuffer_relocate_entry(struct drm_i915_gem_object *obj,
549+
i915_gem_execbuffer_relocate_entry(struct i915_vma *vma,
550550
struct eb_vmas *eb,
551551
struct drm_i915_gem_relocation_entry *reloc,
552552
struct reloc_cache *cache)
553553
{
554+
struct drm_i915_gem_object *obj = vma->obj;
554555
struct drm_i915_private *dev_priv = to_i915(obj->base.dev);
555556
struct drm_gem_object *target_obj;
556557
struct drm_i915_gem_object *target_i915_obj;
@@ -628,6 +629,16 @@ i915_gem_execbuffer_relocate_entry(struct drm_i915_gem_object *obj,
628629
return -EINVAL;
629630
}
630631

632+
/*
633+
* If we write into the object, we need to force the synchronisation
634+
* barrier, either with an asynchronous clflush or if we executed the
635+
* patching using the GPU (though that should be serialised by the
636+
* timeline). To be completely sure, and since we are required to
637+
* do relocations we are already stalling, disable the user's opt
638+
* of our synchronisation.
639+
*/
640+
vma->exec_entry->flags &= ~EXEC_OBJECT_ASYNC;
641+
631642
ret = relocate_entry(obj, reloc, cache, target_offset);
632643
if (ret)
633644
return ret;
@@ -678,7 +689,7 @@ i915_gem_execbuffer_relocate_vma(struct i915_vma *vma,
678689
do {
679690
u64 offset = r->presumed_offset;
680691

681-
ret = i915_gem_execbuffer_relocate_entry(vma->obj, eb, r, &cache);
692+
ret = i915_gem_execbuffer_relocate_entry(vma, eb, r, &cache);
682693
if (ret)
683694
goto out;
684695

@@ -726,7 +737,7 @@ i915_gem_execbuffer_relocate_vma_slow(struct i915_vma *vma,
726737

727738
reloc_cache_init(&cache, eb->i915);
728739
for (i = 0; i < entry->relocation_count; i++) {
729-
ret = i915_gem_execbuffer_relocate_entry(vma->obj, eb, &relocs[i], &cache);
740+
ret = i915_gem_execbuffer_relocate_entry(vma, eb, &relocs[i], &cache);
730741
if (ret)
731742
break;
732743
}

0 commit comments

Comments
 (0)