8000 drm/i915: Workaround to avoid lite restore with HEAD==TAIL · bsd-unix/linux@53292cd · GitHub
[go: up one dir, main page]

Skip to content

Commit 53292cd

Browse files
mthierryjnikula
authored andcommitted
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>
1 parent 9535c47 commit 53292cd

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

drivers/gpu/drm/i915/i915_gem.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2377,10 +2377,11 @@ int __i915_add_request(struct intel_engine_cs *ring,
23772377
ret = ring->add_request(ring);
23782378
if (ret)
23792379
return ret;
2380+
2381+
request->tail = intel_ring_get_tail(ringbuf);
23802382
}
23812383

23822384
request->head = request_start;
2383-
request->tail = intel_ring_get_tail(ringbuf);
23842385

23852386
/* Whilst this request exists, batch_obj will be on the
23862387
* active_list, and so will hold the active reference. Only when this

drivers/gpu/drm/i915/intel_lrc.c

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,26 @@ static void execlists_context_unqueue(struct intel_engine_cs *ring)
393393
}
394394
}
395395

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+
10449 req0->tail += 8;
412+
req0->tail &= ringbuf->size - 1;
413+
}
414+
}
415+
396416
WARN_ON(req1 && req1->elsp_submitted);
397417

398418
execlists_submit_contexts(ring, req0->ctx, req0->tail,
@@ -1315,7 +1335,12 @@ static int gen8_emit_request(struct intel_ringbuffer *ringbuf,
13151335
u32 cmd;
13161336
int ret;
13171337

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);
13191344
if (ret)
13201345
return ret;
13211346

@@ -1333,6 +1358,14 @@ static int gen8_emit_request(struct intel_ringbuffer *ringbuf,
13331358
intel_logical_ring_emit(ringbuf, MI_NOOP);
13341359
intel_logical_ring_advance_and_submit(ringbuf, request->ctx, request);
13351360

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+
13361369
return 0;
13371370
}
13381371

0 commit comments

Comments
 (0)
0