All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Widawsky <ben@bwidawsk.net>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: intel-gfx@lists.freedesktop.org, Mika Kuoppala <mika.kuoppala@intel.com>
Subject: Re: [PATCH] drm/i915: Only mark the ctx as initialised after a SET_CONTEXT operation
Date: Fri, 30 May 2014 10:44:53 -0700	[thread overview]
Message-ID: <20140530174452.GA5039@bwidawsk.net> (raw)
In-Reply-To: <1401455790-10682-1-git-send-email-chris@chris-wilson.co.uk>

On Fri, May 30, 2014 at 02:16:30PM +0100, Chris Wilson wrote:
> Fallout from
> 
> commit 46470fc932ac8a0e8317a220b3f4ea4ed903338e
> Author: Mika Kuoppala <mika.kuoppala@linux.intel.com>
> Date:   Wed May 21 19:01:06 2014 +0300
> 
>     drm/i915: Add null state batch to active list
> 
> undid the earlier fix of only marking the ctx as initialised after it is
> saved by the hardware during a SET_CONTEXT operation.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Damien Lespiau <damien.lespiau@intel.com>
> Cc: Mika Kuoppala <mika.kuoppala@intel.com>
> Cc: Ben Widawsky <ben@bwidawsk.net>
> ---
>  drivers/gpu/drm/i915/i915_gem_context.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
> index 5a71ef1975b3..34a0b49e6add 100644
> --- a/drivers/gpu/drm/i915/i915_gem_context.c
> +++ b/drivers/gpu/drm/i915/i915_gem_context.c
> @@ -641,6 +641,7 @@ static int do_switch(struct intel_engine_cs *ring,
>  	struct intel_context *from = ring->last_context;
>  	struct i915_hw_ppgtt *ppgtt = ctx_to_ppgtt(to);
>  	u32 hw_flags = 0;
> +	bool uninitialized = false;
>  	int ret, i;
>  
>  	if (from != NULL && ring == &dev_priv->ring[RCS]) {
> @@ -739,18 +740,19 @@ static int do_switch(struct intel_engine_cs *ring,
>  		i915_gem_context_unreference(from);
>  	}
>  
> +	uninitialized = !to->is_initialized && from == NULL;
> +	to->is_initialized = true;

Aren't you missing some error paths if you do this?  I think we need to
set the state after we've successfully emitted the MI_SET_CONTEXT
command (though really, until we move the ringbuffer tail, it's all
lies, on that note, I'm scared to look at if reset dtrt).

> +
>  done:
>  	i915_gem_context_reference(to);
>  	ring->last_context = to;
>  
> -	if (ring->id == RCS && !to->is_initialized && from == NULL) {
> +	if (uninitialized) {
>  		ret = i915_gem_render_state_init(ring);
>  		if (ret)
>  			DRM_ERROR("init render state: %d\n", ret);
>  	}
>  
> -	to->is_initialized = true;
> -
>  	return 0;
>  
>  unpin_out:

I just realized the from == NULL check is something which seems fragile
to me given how much churn we might see with init/reset paths. It'd
probably be good to eventually switch to some global state in dev_priv
which we can track across init/reset/fini

Otherwise it looks correct to me.

-- 
Ben Widawsky, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2014-05-30 17:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-30 13:16 [PATCH] drm/i915: Only mark the ctx as initialised after a SET_CONTEXT operation Chris Wilson
2014-05-30 17:44 ` Ben Widawsky [this message]
2014-05-30 17:49   ` Chris Wilson
2014-06-10 10:34 ` Chris Wilson
2014-06-10 13:17   ` Daniel Vetter
2014-06-23  9:55 ` Jani Nikula
2014-06-23 15:51   ` Ben Widawsky
2014-06-24 13:20     ` Jani Nikula

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=20140530174452.GA5039@bwidawsk.net \
    --to=ben@bwidawsk.net \
    --cc=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=mika.kuoppala@intel.com \
    /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.