public inbox for intel-gfx@lists.freedesktop.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 1/2] drm/i915/evict: Always switch away from the	current context
Date: Fri, 15 Jul 2016 16:15:34 +0300	[thread overview]
Message-ID: <87wpknnitl.fsf@gaia.fi.intel.com> (raw)
In-Reply-To: <1468584144-12392-1-git-send-email-chris@chris-wilson.co.uk>

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

> Currently execlists is exempt from emitting a request to switch each
> ring away from the current context over to the dev_priv->kernel_context
> (for whatever reason, just under execlists the GGTT is unlikely to be as
> fragmented, however the switch may help in some extreme cases). Extract
> the switcher and enable it for execlsts as well, as we need to do so in
> a later patch to force the context switch before suspend. (And since for
> that switch we explicitly require the disposable kernel context, rename
> the extracted function.)
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Mika Kuoppala <mika.kuoppala@intel.com>

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

> ---
>  drivers/gpu/drm/i915/i915_drv.h         |  1 +
>  drivers/gpu/drm/i915/i915_gem_context.c | 29 +++++++++++++++++++++++++++
>  drivers/gpu/drm/i915/i915_gem_evict.c   | 35 ++-------------------------------
>  3 files changed, 32 insertions(+), 33 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index 1ec523d29789..cd1ccc47ee8b 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -3525,6 +3525,7 @@ void i915_gem_context_reset(struct drm_device *dev);
>  int i915_gem_context_open(struct drm_device *dev, struct drm_file *file);
>  void i915_gem_context_close(struct drm_device *dev, struct drm_file *file);
>  int i915_switch_context(struct drm_i915_gem_request *req);
> +int i915_gem_switch_to_kernel_context(struct drm_i915_private *dev_priv);
>  void i915_gem_context_free(struct kref *ctx_ref);
>  struct drm_i915_gem_object *
>  i915_gem_alloc_context_obj(struct drm_device *dev, size_t size);
> diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
> index 3c97f0e7a003..3b636161256c 100644
> --- a/drivers/gpu/drm/i915/i915_gem_context.c
> +++ b/drivers/gpu/drm/i915/i915_gem_context.c
> @@ -926,6 +926,35 @@ int i915_switch_context(struct drm_i915_gem_request *req)
>  	return do_rcs_switch(req);
>  }
>  
> +int i915_gem_switch_to_kernel_context(struct drm_i915_private *dev_priv)
> +{
> +	struct intel_engine_cs *engine;
> +
> +	for_each_engine(engine, dev_priv) {
> +		struct drm_i915_gem_request *req;
> +		int ret;
> +
> +		if (engine->last_context == NULL)
> +			continue;
> +
> +		if (engine->last_context == dev_priv->kernel_context)
> +			continue;
> +
> +		req = i915_gem_request_alloc(engine, dev_priv->kernel_context);
> +		if (IS_ERR(req))
> +			return PTR_ERR(req);
> +
> +		ret = 0;
> +		if (!i915.enable_execlists)
> +			ret = i915_switch_context(req);
> +		i915_add_request_no_flush(req);
> +		if (ret)
> +			return ret;
> +	}
> +
> +	return 0;
> +}
> +
>  static bool contexts_enabled(struct drm_device *dev)
>  {
>  	return i915.enable_execlists || to_i915(dev)->hw_context_size;
> diff --git a/drivers/gpu/drm/i915/i915_gem_evict.c b/drivers/gpu/drm/i915/i915_gem_evict.c
> index 3c1280ec7ff6..b1194c7c0a48 100644
> --- a/drivers/gpu/drm/i915/i915_gem_evict.c
> +++ b/drivers/gpu/drm/i915/i915_gem_evict.c
> @@ -33,37 +33,6 @@
>  #include "intel_drv.h"
>  #include "i915_trace.h"
>  
> -static int switch_to_pinned_context(struct drm_i915_private *dev_priv)
> -{
> -	struct intel_engine_cs *engine;
> -
> -	if (i915.enable_execlists)
> -		return 0;
> -
> -	for_each_engine(engine, dev_priv) {
> -		struct drm_i915_gem_request *req;
> -		int ret;
> -
> -		if (engine->last_context == NULL)
> -			continue;
> -
> -		if (engine->last_context == dev_priv->kernel_context)
> -			continue;
> -
> -		req = i915_gem_request_alloc(engine, dev_priv->kernel_context);
> -		if (IS_ERR(req))
> -			return PTR_ERR(req);
> -
> -		ret = i915_switch_context(req);
> -		i915_add_request_no_flush(req);
> -		if (ret)
> -			return ret;
> -	}
> -
> -	return 0;
> -}
> -
> -
>  static bool
>  mark_free(struct i915_vma *vma, struct list_head *unwind)
>  {
> @@ -184,7 +153,7 @@ none:
>  		struct drm_i915_private *dev_priv = to_i915(dev);
>  
>  		if (i915_is_ggtt(vm)) {
> -			ret = switch_to_pinned_context(dev_priv);
> +			ret = i915_gem_switch_to_kernel_context(dev_priv);
>  			if (ret)
>  				return ret;
>  		}
> @@ -303,7 +272,7 @@ int i915_gem_evict_vm(struct i915_address_space *vm, bool do_idle)
>  		struct drm_i915_private *dev_priv = to_i915(vm->dev);
>  
>  		if (i915_is_ggtt(vm)) {
> -			ret = switch_to_pinned_context(dev_priv);
> +			ret = i915_gem_switch_to_kernel_context(dev_priv);
>  			if (ret)
>  				return ret;
>  		}
> -- 
> 2.8.1
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

      parent reply	other threads:[~2016-07-15 13:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-15 12:02 [PATCH 1/2] drm/i915/evict: Always switch away from the current context Chris Wilson
2016-07-15 12:02 ` [PATCH 2/2] drm/i915: Flush logical context image out to memory upon suspend Chris Wilson
2016-07-15 12:03   ` [PATCH v2] " Chris Wilson
2016-07-15 12:51     ` Ville Syrjälä
2016-07-15 12:36 ` ✗ Ro.CI.BAT: failure for series starting with [1/2] drm/i915/evict: Always switch away from the current context (rev2) Patchwork
2016-07-15 13:15 ` Mika Kuoppala [this message]

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=87wpknnitl.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox