Skip to content

Commit 1060974

Browse files
mlankhorstdanvet
authored andcommitted
drm/i915/selftests: Prepare timeline tests for obj->mm.lock removal
We can no longer call intel_timeline_pin with a null argument, so add a ww loop that locks the backing object. Signed-off-by: Maarten Lankhorst <[email protected]> Reviewed-by: Thomas Hellström <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 9aa6de9 commit 1060974

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

drivers/gpu/drm/i915/gt/selftest_timeline.c

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,26 @@ static unsigned long hwsp_cacheline(struct intel_timeline *tl)
3838
return (address + offset_in_page(tl->hwsp_offset)) / TIMELINE_SEQNO_BYTES;
3939
}
4040

41+
static int selftest_tl_pin(struct intel_timeline *tl)
42+
{
43+
struct i915_gem_ww_ctx ww;
44+
int err;
45+
46+
i915_gem_ww_ctx_init(&ww, false);
47+
retry:
48+
err = i915_gem_object_lock(tl->hwsp_ggtt->obj, &ww);
49+
if (!err)
50+
err = intel_timeline_pin(tl, &ww);
51+
52+
if (err == -EDEADLK) {
53+
err = i915_gem_ww_ctx_backoff(&ww);
54+
if (!err)
55+
goto retry;
56+
}
57+
i915_gem_ww_ctx_fini(&ww);
58+
return err;
59+
}
60+
4161
/* Only half of seqno's are usable, see __intel_timeline_get_seqno() */
4262
#define CACHELINES_PER_PAGE (PAGE_SIZE / TIMELINE_SEQNO_BYTES / 2)
4363

@@ -80,7 +100,7 @@ static int __mock_hwsp_timeline(struct mock_hwsp_freelist *state,
80100
if (IS_ERR(tl))
81101
return PTR_ERR(tl);
82102

83-
err = intel_timeline_pin(tl, NULL);
103+
err = selftest_tl_pin(tl);
84104
if (err) {
85105
intel_timeline_put(tl);
86106
return err;
@@ -466,7 +486,7 @@ checked_tl_write(struct intel_timeline *tl, struct intel_engine_cs *engine, u32
466486
struct i915_request *rq;
467487
int err;
468488

469-
err = intel_timeline_pin(tl, NULL);
489+
err = selftest_tl_pin(tl);
470490
if (err) {
471491
rq = ERR_PTR(err);
472492
goto out;
@@ -666,7 +686,7 @@ static int live_hwsp_wrap(void *arg)
666686
if (!tl->has_initial_breadcrumb)
667687
goto out_free;
668688

669-
err = intel_timeline_pin(tl, NULL);
689+
err = selftest_tl_pin(tl);
670690
if (err)
671691
goto out_free;
672692

@@ -813,13 +833,13 @@ static int setup_watcher(struct hwsp_watcher *w, struct intel_gt *gt)
813833
if (IS_ERR(obj))
814834
return PTR_ERR(obj);
815835

816-
w->map = i915_gem_object_pin_map(obj, I915_MAP_WB);
836+
w->map = i915_gem_object_pin_map_unlocked(obj, I915_MAP_WB);
817837
if (IS_ERR(w->map)) {
818838
i915_gem_object_put(obj);
819839
return PTR_ERR(w->map);
820840
}
821841

822-
vma = i915_gem_object_ggtt_pin_ww(obj, NULL, NULL, 0, 0, 0);
842+
vma = i915_gem_object_ggtt_pin(obj, NULL, 0, 0, 0);
823843
if (IS_ERR(vma)) {
824844
i915_gem_object_put(obj);
825845
return PTR_ERR(vma);

0 commit comments

Comments
 (0)