All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mika Kuoppala <mika.kuoppala@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH v2] drm/i915/tgl: Suspend pre-parser across GTT invalidations
Date: Fri, 20 Sep 2019 11:14:36 +0300	[thread overview]
Message-ID: <87a7azpeoj.fsf@gaia.fi.intel.com> (raw)
In-Reply-To: <20190919151811.9526-1-chris@chris-wilson.co.uk>

Chris Wilson <chris@chris-wilson.co.uk> writes:

> Before we execute a batch, we must first issue any and all TLB
> invalidations so that batch picks up the new page table entries.
> Tigerlake's preparser is weakening our post-sync CS_STALL inside the
> invalidate pipe-control and allowing the loading of the batch buffer
> before we have setup its page table (and so it loads the wrong page and
> executes indefinitely).
>
> The igt_cs_tlb indicates that this issue can only be observed on rcs,
> even though the preparser is common to all engines. Alternatively, we
> could do TLB shootdown via mmio on updating the GTT.
>
> By inserting the pre-parser disable inside EMIT_INVALIDATE, we will also
> accidentally fixup execution that writes into subsequent batches, such
> as gem_exec_whisper and even relocations performed on the GPU. We should
> be careful not to allow this disable to become baked into the uABI!
>
> Testcase: igt/i915_selftests/live_gtt/igt_cs_tlb
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
> Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/gt/intel_lrc.c | 75 ++++++++++++++++++++++++++++-
>  1 file changed, 74 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/intel_lrc.c b/drivers/gpu/drm/i915/gt/intel_lrc.c
> index a99166a2d2eb..60b7b163c3d0 100644
> --- a/drivers/gpu/drm/i915/gt/intel_lrc.c
> +++ b/drivers/gpu/drm/i915/gt/intel_lrc.c
> @@ -2807,6 +2807,79 @@ static int gen11_emit_flush_render(struct i915_request *request,
>  	return 0;
>  }
>  
> +static u32 preparser_disable(bool state)
> +{
> +	return MI_ARB_CHECK | 1 << 8 | state;
> +}

Descriptive enough, so no need to define the mask.

Acked-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>

> +
> +static int gen12_emit_flush_render(struct i915_request *request,
> +				   u32 mode)
> +{
> +	struct intel_engine_cs *engine = request->engine;
> +	const u32 scratch_addr =
> +		intel_gt_scratch_offset(engine->gt,
> +					INTEL_GT_SCRATCH_FIELD_RENDER_FLUSH);
> +
> +	if (mode & EMIT_FLUSH) {
> +		u32 flags = 0;
> +		u32 *cs;
> +
> +		flags |= PIPE_CONTROL_TILE_CACHE_FLUSH;
> +		flags |= PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH;
> +		flags |= PIPE_CONTROL_DEPTH_CACHE_FLUSH;
> +		flags |= PIPE_CONTROL_DC_FLUSH_ENABLE;
> +		flags |= PIPE_CONTROL_FLUSH_ENABLE;
> +
> +		flags |= PIPE_CONTROL_QW_WRITE;
> +		flags |= PIPE_CONTROL_GLOBAL_GTT_IVB;
> +
> +		flags |= PIPE_CONTROL_CS_STALL;
> +
> +		cs = intel_ring_begin(request, 6);
> +		if (IS_ERR(cs))
> +			return PTR_ERR(cs);
> +
> +		cs = gen8_emit_pipe_control(cs, flags, scratch_addr);
> +		intel_ring_advance(request, cs);
> +	}
> +
> +	if (mode & EMIT_INVALIDATE) {
> +		u32 flags = 0;
> +		u32 *cs;
> +
> +		flags |= PIPE_CONTROL_COMMAND_CACHE_INVALIDATE;
> +		flags |= PIPE_CONTROL_TLB_INVALIDATE;
> +		flags |= PIPE_CONTROL_INSTRUCTION_CACHE_INVALIDATE;
> +		flags |= PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE;
> +		flags |= PIPE_CONTROL_VF_CACHE_INVALIDATE;
> +		flags |= PIPE_CONTROL_CONST_CACHE_INVALIDATE;
> +		flags |= PIPE_CONTROL_STATE_CACHE_INVALIDATE;
> +
> +		flags |= PIPE_CONTROL_GLOBAL_GTT_IVB;
> +		flags |= PIPE_CONTROL_QW_WRITE;
> +
> +		flags |= PIPE_CONTROL_CS_STALL;
> +
> +		cs = intel_ring_begin(request, 8);
> +		if (IS_ERR(cs))
> +			return PTR_ERR(cs);
> +
> +		/*
> +		 * Prevent the pre-parser from skipping past the TLB
> +		 * invalidate and loading a stale page for the batch
> +		 * buffer / request payload.
> +		 */
> +		*cs++ = preparser_disable(true);
> +
> +		cs = gen8_emit_pipe_control(cs, flags, scratch_addr);
> +
> +		*cs++ = preparser_disable(false);
> +		intel_ring_advance(request, cs);
> +	}
> +
> +	return 0;
> +}
> +
>  /*
>   * Reserve space for 2 NOOPs at the end of each request to be
>   * used as a workaround for not being allowed to do lite
> @@ -3072,7 +3145,7 @@ static void rcs_submission_override(struct intel_engine_cs *engine)
>  {
>  	switch (INTEL_GEN(engine->i915)) {
>  	case 12:
> -		engine->emit_flush = gen11_emit_flush_render;
> +		engine->emit_flush = gen12_emit_flush_render;
>  		engine->emit_fini_breadcrumb = gen12_emit_fini_breadcrumb_rcs;
>  		break;
>  	case 11:
> -- 
> 2.23.0
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2019-09-20  8:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-19 15:18 [PATCH v2] drm/i915/tgl: Suspend pre-parser across GTT invalidations Chris Wilson
2019-09-19 20:48 ` ✓ Fi.CI.BAT: success for drm/i915/tgl: Suspend pre-parser across GTT invalidations (rev2) Patchwork
2019-09-20  8:14 ` Mika Kuoppala [this message]
2019-09-20  9:26   ` [PATCH v2] drm/i915/tgl: Suspend pre-parser across GTT invalidations Chris Wilson
2019-09-20  8:53 ` ✓ Fi.CI.IGT: success for drm/i915/tgl: Suspend pre-parser across GTT invalidations (rev2) Patchwork

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=87a7azpeoj.fsf@gaia.fi.intel.com \
    --to=mika.kuoppala@linux.intel.com \
    --cc=chris@chris-wilson.co.uk \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.