Skip to content

Commit fe49789

Browse files
committed
drm/i915: Deconstruct execute fence
On reflection, we are only using the execute fence as a waitqueue on the global_seqno and not using it for dependency tracking between fences (unlike the submit and dma fences). By only treating it as a waitqueue, we can then treat it similar to the other waitqueues during submit, making the code simpler. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/20170223074422.4125-8-chris@chris-wilson.co.uk
1 parent 541ca6e commit fe49789

File tree

2 files changed

+13
-47
lines changed

2 files changed

+13
-47
lines changed

drivers/gpu/drm/i915/i915_gem_request.c

Lines changed: 12 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ static void i915_fence_release(struct dma_fence *fence)
6969
* caught trying to reuse dead objects.
7070
*/
7171
i915_sw_fence_fini(&req->submit);
72-
i915_sw_fence_fini(&req->execute);
7372

7473
kmem_cache_free(req->i915->requests, req);
7574
}
@@ -294,7 +293,6 @@ static void i915_gem_request_retire(struct drm_i915_gem_request *request)
294293

295294
lockdep_assert_held(&request->i915->drm.struct_mutex);
296295
GEM_BUG_ON(!i915_sw_fence_signaled(&request->submit));
297-
GEM_BUG_ON(!i915_sw_fence_signaled(&request->execute));
298296
GEM_BUG_ON(!i915_gem_request_completed(request));
299297
GEM_BUG_ON(!request->i915->gt.active_requests);
300298

@@ -402,6 +400,8 @@ void __i915_gem_request_submit(struct drm_i915_gem_request *request)
402400
struct intel_timeline *timeline;
403401
u32 seqno;
404402

403+
trace_i915_gem_request_execute(request);
404+
405405
/* Transfer from per-context onto the global per-engine timeline */
406406
timeline = engine->timeline;
407407
GEM_BUG_ON(timeline == request->timeline);
@@ -426,8 +426,7 @@ void __i915_gem_request_submit(struct drm_i915_gem_request *request)
426426
list_move_tail(&request->link, &timeline->requests);
427427
spin_unlock(&request->timeline->lock);
428428

429-
i915_sw_fence_commit(&request->execute);
430-
trace_i915_gem_request_execute(request);
429+
wake_up_all(&request->execute);
431430
}
432431

433432
void i915_gem_request_submit(struct drm_i915_gem_request *request)
@@ -463,24 +462,6 @@ submit_notify(struct i915_sw_fence *fence, enum i915_sw_fence_notify state)
463462
return NOTIFY_DONE;
464463
}
465464

466-
static int __i915_sw_fence_call
467-
execute_notify(struct i915_sw_fence *fence, enum i915_sw_fence_notify state)
468-
{
469-
struct drm_i915_gem_request *request =
470-
container_of(fence, typeof(*request), execute);
471-
472-
switch (state) {
473-
case FENCE_COMPLETE:
474-
break;
475-
476-
case FENCE_FREE:
477-
i915_gem_request_put(request);
478-
break;
479-
}
480-
481-
return NOTIFY_DONE;
482-
}
483-
484465
/**
485466
* i915_gem_request_alloc - allocate a request structure
486467
*
@@ -573,13 +554,7 @@ i915_gem_request_alloc(struct intel_engine_cs *engine,
573554

574555
/* We bump the ref for the fence chain */
575556
i915_sw_fence_init(&i915_gem_request_get(req)->submit, submit_notify);
576-
i915_sw_fence_init(&i915_gem_request_get(req)->execute, execute_notify);
577-
578-
/* Ensure that the execute fence completes after the submit fence -
579-
* as we complete the execute fence from within the submit fence
580-
* callback, its completion would otherwise be visible first.
581-
*/
582-
i915_sw_fence_await_sw_fence(&req->execute, &req->submit, &req->execq);
557+
init_waitqueue_head(&req->execute);
583558

584559
i915_priotree_init(&req->priotree);
585560

@@ -1031,6 +1006,7 @@ long i915_wait_request(struct drm_i915_gem_request *req,
10311006
TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE;
10321007
wait_queue_head_t *errq = &req->i915->gpu_error.wait_queue;
10331008
DEFINE_WAIT(reset);
1009+
DEFINE_WAIT(exec);
10341010
struct intel_wait wait;
10351011

10361012
might_sleep();
@@ -1052,12 +1028,11 @@ long i915_wait_request(struct drm_i915_gem_request *req,
10521028
if (flags & I915_WAIT_LOCKED)
10531029
add_wait_queue(errq, &reset);
10541030

1055-
if (!i915_sw_fence_done(&req->execute)) {
1056-
DEFINE_WAIT(exec);
1057-
1031+
reset_wait_queue(&req->execute, &exec);
1032+
if (!req->global_seqno) {
10581033
do {
1059-
prepare_to_wait(&req->execute.wait, &exec, state);
1060-
if (i915_sw_fence_done(&req->execute))
1034+
set_current_state(state);
1035+
if (req->global_seqno)
10611036
break;
10621037

10631038
if (flags & I915_WAIT_LOCKED &&
@@ -1080,15 +1055,14 @@ long i915_wait_request(struct drm_i915_gem_request *req,
10801055

10811056
timeout = io_schedule_timeout(timeout);
10821057
} while (1);
1083-
finish_wait(&req->execute.wait, &exec);
1058+
finish_wait(&req->execute, &exec);
10841059

10851060
if (timeout < 0)
10861061
goto complete;
10871062

1088-
GEM_BUG_ON(!i915_sw_fence_done(&req->execute));
1063+
GEM_BUG_ON(!req->global_seqno);
10891064
}
1090-
GEM_BUG_ON(!i915_sw_fence_done(&req->submit));
1091-
GEM_BUG_ON(!req->global_seqno);
1065+
GEM_BUG_ON(!i915_sw_fence_signaled(&req->submit));
10921066

10931067
/* Optimistic short spin before touching IRQs */
10941068
if (i915_spin_request(req, state, 5))

drivers/gpu/drm/i915/i915_gem_request.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,18 +119,10 @@ struct drm_i915_gem_request {
119119
* The submit fence is used to await upon all of the request's
120120
* dependencies. When it is signaled, the request is ready to run.
121121
* It is used by the driver to then queue the request for execution.
122-
*
123-
* The execute fence is used to signal when the request has been
124-
* sent to hardware.
125-
*
126-
* It is illegal for the submit fence of one request to wait upon the
127-
* execute fence of an earlier request. It should be sufficient to
128-
* wait upon the submit fence of the earlier request.
129122
*/
130123
struct i915_sw_fence submit;
131-
struct i915_sw_fence execute;
132124
wait_queue_t submitq;
133-
wait_queue_t execq;
125+
wait_queue_head_t execute;
134126

135127
/* A list of everyone we wait upon, and everyone who waits upon us.
136128
* Even though we will not be submitted to the hardware before the

0 commit comments

Comments
 (0)