From: Tvrtko Ursulin <tursulin@ursulin.net>
To: Intel-gfx@lists.freedesktop.org
Subject: [PATCH 5/5] drm/i915: Consolidate gen8_emit_pipe_control
Date: Thu, 16 Feb 2017 12:23:25 +0000 [thread overview]
Message-ID: <20170216122325.31391-6-tvrtko.ursulin@linux.intel.com> (raw)
In-Reply-To: <20170216122325.31391-1-tvrtko.ursulin@linux.intel.com>
From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
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 <tvrtko.ursulin@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
---
drivers/gpu/drm/i915/intel_lrc.c | 77 +++++++++++----------------------
drivers/gpu/drm/i915/intel_ringbuffer.c | 45 +++++++------------
drivers/gpu/drm/i915/intel_ringbuffer.h | 11 +++++
3 files changed, 52 insertions(+), 81 deletions(-)
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index ec39e3e422ca..231b011ee1f3 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -918,12 +918,10 @@ gen8_emit_flush_coherentl3_wa(struct intel_engine_cs *engine, u32 *batch)
*batch++ = i915_mmio_reg_offset(GEN8_L3SQCREG4);
*batch++ = 0x40400000 | GEN8_LQSC_FLUSH_COHERENT_LINES;
- *batch++ = GFX_OP_PIPE_CONTROL(6);
- *batch++ = PIPE_CONTROL_CS_STALL | PIPE_CONTROL_DC_FLUSH_ENABLE;
- *batch++ = 0;
- *batch++ = 0;
- *batch++ = 0;
- *batch++ = 0;
+ batch = gen8_emit_pipe_control(batch,
+ PIPE_CONTROL_CS_STALL |
+ PIPE_CONTROL_DC_FLUSH_ENABLE,
+ 0);
*batch++ = MI_LOAD_REGISTER_MEM_GEN8 | MI_SRM_LRM_GLOBAL_GTT;
*batch++ = i915_mmio_reg_offset(GEN8_L3SQCREG4);
@@ -957,15 +955,15 @@ static u32 *gen8_init_indirectctx_bb(struct intel_engine_cs *engine, u32 *batch)
if (IS_BROADWELL(engine->i915))
batch = gen8_emit_flush_coherentl3_wa(engine, batch);
- *batch++ = GFX_OP_PIPE_CONTROL(6);
- *batch++ = PIPE_CONTROL_FLUSH_L3 | PIPE_CONTROL_GLOBAL_GTT_IVB |
- PIPE_CONTROL_CS_STALL | PIPE_CONTROL_QW_WRITE;
/* WaClearSlmSpaceAtContextSwitch:bdw,chv */
/* Actual scratch location is at 128 bytes offset */
- *batch++ = i915_ggtt_offset(engine->scratch) + 2 * CACHELINE_BYTES;
- *batch++ = 0;
- *batch++ = 0;
- *batch++ = 0;
+ batch = gen8_emit_pipe_control(batch,
+ PIPE_CONTROL_FLUSH_L3 |
+ PIPE_CONTROL_GLOBAL_GTT_IVB |
+ PIPE_CONTROL_CS_STALL |
+ PIPE_CONTROL_QW_WRITE,
+ i915_ggtt_offset(engine->scratch) +
+ 2 * CACHELINE_BYTES);
/* Pad to end of cacheline */
while ((unsigned long)batch % CACHELINE_BYTES)
@@ -1013,14 +1011,13 @@ static u32 *gen9_init_indirectctx_bb(struct intel_engine_cs *engine, u32 *batch)
/* WaClearSlmSpaceAtContextSwitch:kbl */
/* Actual scratch location is at 128 bytes offset */
if (IS_KBL_REVID(engine->i915, 0, KBL_REVID_A0)) {
- *batch++ = GFX_OP_PIPE_CONTROL(6);
- *batch++ = PIPE_CONTROL_FLUSH_L3 | PIPE_CONTROL_GLOBAL_GTT_IVB |
- PIPE_CONTROL_CS_STALL | PIPE_CONTROL_QW_WRITE;
- *batch++ = i915_ggtt_offset(engine->scratch) +
- 2 * CACHELINE_BYTES;
- *batch++ = 0;
- *batch++ = 0;
- *batch++ = 0;
+ batch = gen8_emit_pipe_control(batch,
+ PIPE_CONTROL_FLUSH_L3 |
+ PIPE_CONTROL_GLOBAL_GTT_IVB |
+ PIPE_CONTROL_CS_STALL |
+ PIPE_CONTROL_QW_WRITE,
+ i915_ggtt_offset(engine->scratch)
+ + 2 * CACHELINE_BYTES);
}
/* WaMediaPoolStateCmdInWABB:bxt,glk */
@@ -1450,39 +1447,17 @@ static int gen8_emit_flush_render(struct drm_i915_gem_request *request,
if (IS_ERR(cs))
return PTR_ERR(cs);
- if (vf_flush_wa) {
- *cs++ = GFX_OP_PIPE_CONTROL(6);
- *cs++ = 0;
- *cs++ = 0;
- *cs++ = 0;
- *cs++ = 0;
- *cs++ = 0;
- }
+ if (vf_flush_wa)
+ cs = gen8_emit_pipe_control(cs, 0, 0);
- if (dc_flush_wa) {
- *cs++ = GFX_OP_PIPE_CONTROL(6);
- *cs++ = PIPE_CONTROL_DC_FLUSH_ENABLE;
- *cs++ = 0;
- *cs++ = 0;
- *cs++ = 0;
- *cs++ = 0;
- }
+ if (dc_flush_wa)
+ cs = gen8_emit_pipe_control(cs, PIPE_CONTROL_DC_FLUSH_ENABLE,
+ 0);
- *cs++ = GFX_OP_PIPE_CONTROL(6);
- *cs++ = flags;
- *cs++ = scratch_addr;
- *cs++ = 0;
- *cs++ = 0;
- *cs++ = 0;
+ cs = gen8_emit_pipe_control(cs, flags, scratch_addr);
- if (dc_flush_wa) {
- *cs++ = GFX_OP_PIPE_CONTROL(6);
- *cs++ = PIPE_CONTROL_CS_STALL;
- *cs++ = 0;
- *cs++ = 0;
- *cs++ = 0;
- *cs++ = 0;
- }
+ if (dc_flush_wa)
+ cs = gen8_emit_pipe_control(cs, PIPE_CONTROL_CS_STALL, 0);
intel_ring_advance(request, cs);
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index 629fe6584e61..d56f384938f7 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -334,35 +334,16 @@ gen7_render_ring_flush(struct drm_i915_gem_request *req, u32 mode)
}
static int
-gen8_emit_pipe_control(struct drm_i915_gem_request *req,
- u32 flags, u32 scratch_addr)
+gen8_render_ring_flush(struct drm_i915_gem_request *req, u32 mode)
{
+ u32 flags;
u32 *cs;
- cs = intel_ring_begin(req, 6);
+ cs = intel_ring_begin(req, mode & EMIT_INVALIDATE ? 12 : 6);
if (IS_ERR(cs))
return PTR_ERR(cs);
- *cs++ = GFX_OP_PIPE_CONTROL(6);
- *cs++ = flags;
- *cs++ = scratch_addr;
- *cs++ = 0;
- *cs++ = 0;
- *cs++ = 0;
- intel_ring_advance(req, cs);
-
- return 0;
-}
-
-static int
-gen8_render_ring_flush(struct drm_i915_gem_request *req, u32 mode)
-{
- u32 scratch_addr =
- i915_ggtt_offset(req->engine->scratch) + 2 * CACHELINE_BYTES;
- u32 flags = 0;
- int ret;
-
- flags |= PIPE_CONTROL_CS_STALL;
+ flags = PIPE_CONTROL_CS_STALL;
if (mode & EMIT_FLUSH) {
flags |= PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH;
@@ -381,15 +362,19 @@ gen8_render_ring_flush(struct drm_i915_gem_request *req, u32 mode)
flags |= PIPE_CONTROL_GLOBAL_GTT_IVB;
/* WaCsStallBeforeStateCacheInvalidate:bdw,chv */
- ret = gen8_emit_pipe_control(req,
- PIPE_CONTROL_CS_STALL |
- PIPE_CONTROL_STALL_AT_SCOREBOARD,
- 0);
- if (ret)
- return ret;
+ cs = gen8_emit_pipe_control(cs,
+ PIPE_CONTROL_CS_STALL |
+ PIPE_CONTROL_STALL_AT_SCOREBOARD,
+ 0);
}
- return gen8_emit_pipe_control(req, flags, scratch_addr);
+ cs = gen8_emit_pipe_control(cs, flags,
+ i915_ggtt_offset(req->engine->scratch) +
+ 2 * CACHELINE_BYTES);
+
+ intel_ring_advance(req, cs);
+
+ return 0;
}
static void ring_setup_phys_status_page(struct intel_engine_cs *engine)
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h
index 1d9fd4e42622..4ca5308e12bb 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.h
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.h
@@ -631,4 +631,15 @@ void intel_engine_reset_breadcrumbs(struct intel_engine_cs *engine);
void intel_engine_fini_breadcrumbs(struct intel_engine_cs *engine);
unsigned int intel_breadcrumbs_busy(struct drm_i915_private *i915);
+static inline u32 *gen8_emit_pipe_control(u32 *batch, u32 flags, u32 offset)
+{
+ memset(batch, 0, 6 * sizeof(u32));
+
+ batch[0] = GFX_OP_PIPE_CONTROL(6);
+ batch[1] = flags;
+ batch[2] = offset;
+
+ return batch + 6;
+}
+
#endif /* _INTEL_RINGBUFFER_H_ */
--
2.9.3
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2017-02-16 12:23 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-16 12:23 [PATCH 0/5] Assorted engine tidy Tvrtko Ursulin
2017-02-16 12:23 ` [PATCH 1/5] drm/i915: Make int __intel_ring_space static Tvrtko Ursulin
2017-02-16 13:12 ` Chris Wilson
2017-02-16 12:23 ` [PATCH 2/5] drm/i915: Simplify cleanup path in intel_engines_init Tvrtko Ursulin
2017-02-16 13:15 ` Chris Wilson
2017-02-16 12:23 ` [PATCH 3/5] drm/i915: Move common workaround code to intel_engine_cs Tvrtko Ursulin
2017-02-16 13:18 ` Chris Wilson
2017-02-16 12:23 ` [PATCH 4/5] drm/i915: Tidy workaround batch buffer emission Tvrtko Ursulin
2017-02-16 13:20 ` Chris Wilson
2017-02-16 13:23 ` Tvrtko Ursulin
2017-02-16 13:28 ` Chris Wilson
2017-02-16 13:47 ` Tvrtko Ursulin
2017-02-16 13:51 ` [PATCH v4 1/2] " Tvrtko Ursulin
2017-02-16 13:54 ` [PATCH v5 " Tvrtko Ursulin
2017-02-16 14:03 ` Chris Wilson
2017-02-17 7:58 ` [PATCH v6] " Tvrtko Ursulin
2017-02-17 8:16 ` Chris Wilson
2017-02-16 12:23 ` Tvrtko Ursulin [this message]
2017-02-16 18:22 ` ✓ Fi.CI.BAT: success for Assorted engine tidy (rev3) Patchwork
2017-02-17 8:22 ` ✗ Fi.CI.BAT: failure for Assorted engine tidy (rev4) Patchwork
2017-02-17 11:50 ` Tvrtko Ursulin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170216122325.31391-6-tvrtko.ursulin@linux.intel.com \
--to=tursulin@ursulin.net \
--cc=Intel-gfx@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox