diff options
author | Michel Thierry <michel.thierry@intel.com> | 2015-04-15 13:11:33 -0400 |
---|---|---|
committer | Jani Nikula <jani.nikula@intel.com> | 2015-04-23 16:56:52 -0400 |
commit | 53292cdb066950611e5bc2e0eb109c7edb42af78 (patch) | |
tree | 2c2b0ed161701386dfff4000b084d9289c8eca97 | |
parent | 9535c4757b881e06fae72a857485ad57c422b8d2 (diff) |
drm/i915: Workaround to avoid lite restore with HEAD==TAIL
WaIdleLiteRestore is an execlists-only workaround, and requires the driver
to ensure that any context always has HEAD!=TAIL when attempting lite
restore.
Add two extra MI_NOOP instructions at the end of each request, but keep
the requests tail pointing before the MI_NOOPs. We may not need to
executed them, and this is why request->tail is sampled before adding
these extra instructions.
If we submit a context to the ELSP which has previously been submitted,
move the tail pointer past the MI_NOOPs. This ensures HEAD!=TAIL.
v2: Move overallocation to gen8_emit_request, and added note about
sampling request->tail in commit message (Chris).
v3: Remove redundant request->tail assignment in __i915_add_request, in
lrc mode this is already set in execlists_context_queue.
Do not add wa implementation details inside gem (Chris).
v4: Apply the wa whenever the req has been resubmitted and update
comment (Chris).
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Thomas Daniel <thomas.daniel@intel.com>
Signed-off-by: Michel Thierry <michel.thierry@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
-rw-r--r-- | drivers/gpu/drm/i915/i915_gem.c | 3 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_lrc.c | 35 |
2 files changed, 36 insertions, 2 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index d07c0b1fb498..53394f998a1f 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c | |||
@@ -2377,10 +2377,11 @@ int __i915_add_request(struct intel_engine_cs *ring, | |||
2377 | ret = ring->add_request(ring); | 2377 | ret = ring->add_request(ring); |
2378 | if (ret) | 2378 | if (ret) |
2379 | return ret; | 2379 | return ret; |
2380 | |||
2381 | request->tail = intel_ring_get_tail(ringbuf); | ||
2380 | } | 2382 | } |
2381 | 2383 | ||
2382 | request->head = request_start; | 2384 | request->head = request_start; |
2383 | request->tail = intel_ring_get_tail(ringbuf); | ||
2384 | 2385 | ||
2385 | /* Whilst this request exists, batch_obj will be on the | 2386 | /* Whilst this request exists, batch_obj will be on the |
2386 | * active_list, and so will hold the active reference. Only when this | 2387 | * active_list, and so will hold the active reference. Only when this |
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c index fcb074bd55dc..09df74b8e917 100644 --- a/drivers/gpu/drm/i915/intel_lrc.c +++ b/drivers/gpu/drm/i915/intel_lrc.c | |||
@@ -393,6 +393,26 @@ static void execlists_context_unqueue(struct intel_engine_cs *ring) | |||
393 | } | 393 | } |
394 | } | 394 | } |
395 | 395 | ||
396 | if (IS_GEN8(ring->dev) || IS_GEN9(ring->dev)) { | ||
397 | /* | ||
398 | * WaIdleLiteRestore: make sure we never cause a lite | ||
399 | * restore with HEAD==TAIL | ||
400 | */ | ||
401 | if (req0 && req0->elsp_submitted) { | ||
402 | /* | ||
403 | * Apply the wa NOOPS to prevent ring:HEAD == req:TAIL | ||
404 | * as we resubmit the request. See gen8_emit_request() | ||
405 | * for where we prepare the padding after the end of the | ||
406 | * request. | ||
407 | */ | ||
408 | struct intel_ringbuffer *ringbuf; | ||
409 | |||
410 | ringbuf = req0->ctx->engine[ring->id].ringbuf; | ||
411 | req0->tail += 8; | ||
412 | req0->tail &= ringbuf->size - 1; | ||
413 | } | ||
414 | } | ||
415 | |||
396 | WARN_ON(req1 && req1->elsp_submitted); | 416 | WARN_ON(req1 && req1->elsp_submitted); |
397 | 417 | ||
398 | execlists_submit_contexts(ring, req0->ctx, req0->tail, | 418 | execlists_submit_contexts(ring, req0->ctx, req0->tail, |
@@ -1315,7 +1335,12 @@ static int gen8_emit_request(struct intel_ringbuffer *ringbuf, | |||
1315 | u32 cmd; | 1335 | u32 cmd; |
1316 | int ret; | 1336 | int ret; |
1317 | 1337 | ||
1318 | ret = intel_logical_ring_begin(ringbuf, request->ctx, 6); | 1338 | /* |
1339 | * Reserve space for 2 NOOPs at the end of each request to be | ||
1340 | * used as a workaround for not being allowed to do lite | ||
1341 | * restore with HEAD==TAIL (WaIdleLiteRestore). | ||
1342 | */ | ||
1343 | ret = intel_logical_ring_begin(ringbuf, request->ctx, 8); | ||
1319 | if (ret) | 1344 | if (ret) |
1320 | return ret; | 1345 | return ret; |
1321 | 1346 | ||
@@ -1333,6 +1358,14 @@ static int gen8_emit_request(struct intel_ringbuffer *ringbuf, | |||
1333 | intel_logical_ring_emit(ringbuf, MI_NOOP); | 1358 | intel_logical_ring_emit(ringbuf, MI_NOOP); |
1334 | intel_logical_ring_advance_and_submit(ringbuf, request->ctx, request); | 1359 | intel_logical_ring_advance_and_submit(ringbuf, request->ctx, request); |
1335 | 1360 | ||
1361 | /* | ||
1362 | * Here we add two extra NOOPs as padding to avoid | ||
1363 | * lite restore of a context with HEAD==TAIL. | ||
1364 | */ | ||
1365 | intel_logical_ring_emit(ringbuf, MI_NOOP); | ||
1366 | intel_logical_ring_emit(ringbuf, MI_NOOP); | ||
1367 | intel_logical_ring_advance(ringbuf); | ||
1368 | |||
1336 | return 0; | 1369 | return 0; |
1337 | } | 1370 | } |
1338 | 1371 | ||