Skip to content

Commit 9f235df

Browse files
committed
drm/i915: Consolidate gen8_emit_pipe_control
We have a few open coded instances in the execlists code and an almost suitable helper in intel_ringbuf.c We can consolidate to a single helper if we change the existing helper to emit directly to ring buffer memory and move the space reservation outside it. v2: Drop memcpy for memset. (Chris Wilson) Signed-off-by: Tvrtko Ursulin <[email protected]> Reviewed-by: Chris Wilson <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 097d4f1 commit 9f235df

File tree

3 files changed

+52
-81
lines changed

3 files changed

+52
-81
lines changed

drivers/gpu/drm/i915/intel_lrc.c

Lines changed: 26 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -918,12 +918,10 @@ gen8_emit_flush_coherentl3_wa(struct intel_engine_cs *engine, u32 *batch)
918918
*batch++ = i915_mmio_reg_offset(GEN8_L3SQCREG4);
919919
*batch++ = 0x40400000 | GEN8_LQSC_FLUSH_COHERENT_LINES;
920920

921-
*batch++ = GFX_OP_PIPE_CONTROL(6);
922-
*batch++ = PIPE_CONTROL_CS_STALL | PIPE_CONTROL_DC_FLUSH_ENABLE;
923-
*batch++ = 0;
924-
*batch++ = 0;
925-
*batch++ = 0;
926-
*batch++ = 0;
921+
batch = gen8_emit_pipe_control(batch,
922+
PIPE_CONTROL_CS_STALL |
923+
PIPE_CONTROL_DC_FLUSH_ENABLE,
924+
0);
927925

928926
*batch++ = MI_LOAD_REGISTER_MEM_GEN8 | MI_SRM_LRM_GLOBAL_GTT;
929927
*batch++ = i915_mmio_reg_offset(GEN8_L3SQCREG4);
@@ -957,15 +955,15 @@ static u32 *gen8_init_indirectctx_bb(struct intel_engine_cs *engine, u32 *batch)
957955
if (IS_BROADWELL(engine->i915))
958956
batch = gen8_emit_flush_coherentl3_wa(engine, batch);
959957

960-
*batch++ = GFX_OP_PIPE_CONTROL(6);
961-
*batch++ = PIPE_CONTROL_FLUSH_L3 | PIPE_CONTROL_GLOBAL_GTT_IVB |
962-
PIPE_CONTROL_CS_STALL | PIPE_CONTROL_QW_WRITE;
963958
/* WaClearSlmSpaceAtContextSwitch:bdw,chv */
964959
/* Actual scratch location is at 128 bytes offset */
965-
*batch++ = i915_ggtt_offset(engine->scratch) + 2 * CACHELINE_BYTES;
966-
*batch++ = 0;
967-
*batch++ = 0;
968-
*batch++ = 0;
960+
batch = gen8_emit_pipe_control(batch,
961+
PIPE_CONTROL_FLUSH_L3 |
962+
PIPE_CONTROL_GLOBAL_GTT_IVB |
963+
PIPE_CONTROL_CS_STALL |
964+
PIPE_CONTROL_QW_WRITE,
965+
i915_ggtt_offset(engine->scratch) +
966+
2 * CACHELINE_BYTES);
969967

970968
/* Pad to end of cacheline */
971969
while ((unsigned long)batch % CACHELINE_BYTES)
@@ -1013,14 +1011,13 @@ static u32 *gen9_init_indirectctx_bb(struct intel_engine_cs *engine, u32 *batch)
10131011
/* WaClearSlmSpaceAtContextSwitch:kbl */
10141012
/* Actual scratch location is at 128 bytes offset */
10151013
if (IS_KBL_REVID(engine->i915, 0, KBL_REVID_A0)) {
1016-
*batch++ = GFX_OP_PIPE_CONTROL(6);
1017-
*batch++ = PIPE_CONTROL_FLUSH_L3 | PIPE_CONTROL_GLOBAL_GTT_IVB |
1018-
PIPE_CONTROL_CS_STALL | PIPE_CONTROL_QW_WRITE;
1019-
*batch++ = i915_ggtt_offset(engine->scratch) +
1020-
2 * CACHELINE_BYTES;
1021-
*batch++ = 0;
1022-
*batch++ = 0;
1023-
*batch++ = 0;
1014+
batch = gen8_emit_pipe_control(batch,
1015+
PIPE_CONTROL_FLUSH_L3 |
1016+
PIPE_CONTROL_GLOBAL_GTT_IVB |
1017+
PIPE_CONTROL_CS_STALL |
1018+
PIPE_CONTROL_QW_WRITE,
1019+
i915_ggtt_offset(engine->scratch)
1020+
+ 2 * CACHELINE_BYTES);
10241021
}
10251022

10261023
/* WaMediaPoolStateCmdInWABB:bxt,glk */
@@ -1456,39 +1453,17 @@ static int gen8_emit_flush_render(struct drm_i915_gem_request *request,
14561453
if (IS_ERR(cs))
14571454
return PTR_ERR(cs);
14581455

1459-
if (vf_flush_wa) {
1460-
*cs++ = GFX_OP_PIPE_CONTROL(6);
1461-
*cs++ = 0;
1462-
*cs++ = 0;
1463-
*cs++ = 0;
1464-
*cs++ = 0;
1465-
*cs++ = 0;
1466-
}
1456+
if (vf_flush_wa)
1457+
cs = gen8_emit_pipe_control(cs, 0, 0);
14671458

1468-
if (dc_flush_wa) {
1469-
*cs++ = GFX_OP_PIPE_CONTROL(6);
1470-
*cs++ = PIPE_CONTROL_DC_FLUSH_ENABLE;
1471-
*cs++ = 0;
1472-
*cs++ = 0;
1473-
*cs++ = 0;
1474-
*cs++ = 0;
1475-
}
1459+
if (dc_flush_wa)
1460+
cs = gen8_emit_pipe_control(cs, PIPE_CONTROL_DC_FLUSH_ENABLE,
1461+
0);
14761462

1477-
*cs++ = GFX_OP_PIPE_CONTROL(6);
1478-
*cs++ = flags;
1479-
*cs++ = scratch_addr;
1480-
*cs++ = 0;
1481-
*cs++ = 0;
1482-
*cs++ = 0;
1463+
cs = gen8_emit_pipe_control(cs, flags, scratch_addr);
14831464

1484-
if (dc_flush_wa) {
1485-
*cs++ = GFX_OP_PIPE_CONTROL(6);
1486-
*cs++ = PIPE_CONTROL_CS_STALL;
1487-
*cs++ = 0;
1488-
*cs++ = 0;
1489-
*cs++ = 0;
1490-
*cs++ = 0;
1491-
}
1465+
if (dc_flush_wa)
1466+
cs = gen8_emit_pipe_control(cs, PIPE_CONTROL_CS_STALL, 0);
14921467

14931468
intel_ring_advance(request, cs);
14941469

drivers/gpu/drm/i915/intel_ringbuffer.c

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -334,35 +334,16 @@ gen7_render_ring_flush(struct drm_i915_gem_request *req, u32 mode)
334334
}
335335

336336
static int
337-
gen8_emit_pipe_control(struct drm_i915_gem_request *req,
338-
u32 flags, u32 scratch_addr)
337+
gen8_render_ring_flush(struct drm_i915_gem_request *req, u32 mode)
339338
{
339+
u32 flags;
340340
u32 *cs;
341341

342-
cs = intel_ring_begin(req, 6);
342+
cs = intel_ring_begin(req, mode & EMIT_INVALIDATE ? 12 : 6);
343343
if (IS_ERR(cs))
344344
return PTR_ERR(cs);
345345

346-
*cs++ = GFX_OP_PIPE_CONTROL(6);
347-
*cs++ = flags;
348-
*cs++ = scratch_addr;
349-
*cs++ = 0;
350-
*cs++ = 0;
351-
*cs++ = 0;
352-
intel_ring_advance(req, cs);
353-
354-
return 0;
355-
}
356-
357-
static int
358-
gen8_render_ring_flush(struct drm_i915_gem_request *req, u32 mode)
359-
{
360-
u32 scratch_addr =
361-
i915_ggtt_offset(req->engine->scratch) + 2 * CACHELINE_BYTES;
362-
u32 flags = 0;
363-
int ret;
364-
365-
flags |= PIPE_CONTROL_CS_STALL;
346+
flags = PIPE_CONTROL_CS_STALL;
366347

367348
if (mode & EMIT_FLUSH) {
368349
flags |= PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH;
@@ -381,15 +362,19 @@ gen8_render_ring_flush(struct drm_i915_gem_request *req, u32 mode)
381362
flags |= PIPE_CONTROL_GLOBAL_GTT_IVB;
382363

383364
/* WaCsStallBeforeStateCacheInvalidate:bdw,chv */
384-
ret = gen8_emit_pipe_control(req,
385-
PIPE_CONTROL_CS_STALL |
386-
PIPE_CONTROL_STALL_AT_SCOREBOARD,
387-
0);
388-
if (ret)
389-
return ret;
365+
cs = gen8_emit_pipe_control(cs,
366+
PIPE_CONTROL_CS_STALL |
367+
PIPE_CONTROL_STALL_AT_SCOREBOARD,
368+
0);
390369
}
391370

392-
return gen8_emit_pipe_control(req, flags, scratch_addr);
371+
cs = gen8_emit_pipe_control(cs, flags,
372+
i915_ggtt_offset(req->engine->scratch) +
373+
2 * CACHELINE_BYTES);
374+
375+
intel_ring_advance(req, cs);
376+
377+
return 0;
393378
}
394379

395380
static void ring_setup_phys_status_page(struct intel_engine_cs *engine)

drivers/gpu/drm/i915/intel_ringbuffer.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,4 +631,15 @@ void intel_engine_reset_breadcrumbs(struct intel_engine_cs *engine);
631631
void intel_engine_fini_breadcrumbs(struct intel_engine_cs *engine);
632632
unsigned int intel_breadcrumbs_busy(struct drm_i915_private *i915);
633633

634+
static inline u32 *gen8_emit_pipe_control(u32 *batch, u32 flags, u32 offset)
635+
{
636+
memset(batch, 0, 6 * sizeof(u32));
637+
638+
batch[0] = GFX_OP_PIPE_CONTROL(6);
639+
batch[1] = flags;
640+
batch[2] = offset;
641+
642+
return batch + 6;
643+
}
644+
634645
#endif /* _INTEL_RINGBUFFER_H_ */

0 commit comments

Comments
 (0)