From: Ben Widawsky <ben@bwidawsk.net>
To: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 01/13] drm/i915: add context parameter to i915_switch_context()
Date: Tue, 26 Feb 2013 10:31:34 -0800 [thread overview]
Message-ID: <20130226183134.GA8657@bwidawsk.net> (raw)
In-Reply-To: <1361876716-8625-2-git-send-email-mika.kuoppala@intel.com>
On Tue, Feb 26, 2013 at 01:05:04PM +0200, Mika Kuoppala wrote:
> In preparation for the next commit, return context that
> was switch to from i915_switch_context().
>
> Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
I'd suggest using ERR_PTR and PTR_ERR instead of the **ctx
> ---
> drivers/gpu/drm/i915/i915_drv.h | 3 ++-
> drivers/gpu/drm/i915/i915_gem.c | 2 +-
> drivers/gpu/drm/i915/i915_gem_context.c | 36 ++++++++++++++++++----------
> drivers/gpu/drm/i915/i915_gem_execbuffer.c | 2 +-
> 4 files changed, 27 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index e95337c..27459ec 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -1671,7 +1671,8 @@ void i915_gem_context_init(struct drm_device *dev);
> void i915_gem_context_fini(struct drm_device *dev);
> void i915_gem_context_close(struct drm_device *dev, struct drm_file *file);
> int i915_switch_context(struct intel_ring_buffer *ring,
> - struct drm_file *file, int to_id);
> + struct drm_file *file, int to_id,
> + struct i915_hw_context **ctx);
> int i915_gem_context_create_ioctl(struct drm_device *dev, void *data,
> struct drm_file *file);
> int i915_gem_context_destroy_ioctl(struct drm_device *dev, void *data,
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index 8413ffc..61610f3 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -2517,7 +2517,7 @@ int i915_gpu_idle(struct drm_device *dev)
>
> /* Flush everything onto the inactive list. */
> for_each_ring(ring, dev_priv, i) {
> - ret = i915_switch_context(ring, NULL, DEFAULT_CONTEXT_ID);
> + ret = i915_switch_context(ring, NULL, DEFAULT_CONTEXT_ID, NULL);
> if (ret)
> return ret;
>
> diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
> index 21177d9..4125919 100644
> --- a/drivers/gpu/drm/i915/i915_gem_context.c
> +++ b/drivers/gpu/drm/i915/i915_gem_context.c
> @@ -428,10 +428,9 @@ static int do_switch(struct i915_hw_context *to)
> /**
> * i915_switch_context() - perform a GPU context switch.
> * @ring: ring for which we'll execute the context switch
> - * @file_priv: file_priv associated with the context, may be NULL
> - * @id: context id number
> - * @seqno: sequence number by which the new context will be switched to
> - * @flags:
> + * @file: file associated with the context, may be NULL
> + * @to_id: context id number
> + * @ctx: i915_hw_context we switched to, may be NULL
> *
> * The context life cycle is simple. The context refcount is incremented and
> * decremented by 1 and create and destroy. If the context is in use by the GPU,
> @@ -440,29 +439,40 @@ static int do_switch(struct i915_hw_context *to)
> */
> int i915_switch_context(struct intel_ring_buffer *ring,
> struct drm_file *file,
> - int to_id)
> + int to_id,
> + struct i915_hw_context **ctx)
> {
> struct drm_i915_private *dev_priv = ring->dev->dev_private;
> - struct i915_hw_context *to;
> + struct i915_hw_context *to = NULL;
> + int ret = 0;
>
> if (dev_priv->hw_contexts_disabled)
> - return 0;
> + goto out;
>
> if (ring != &dev_priv->ring[RCS])
> - return 0;
> + goto out;
>
> if (to_id == DEFAULT_CONTEXT_ID) {
> to = ring->default_context;
> } else {
> - if (file == NULL)
> - return -EINVAL;
> + if (file == NULL) {
> + ret = -EINVAL;
> + goto out;
> + }
>
> to = i915_gem_context_get(file->driver_priv, to_id);
> - if (to == NULL)
> - return -ENOENT;
> + if (to == NULL) {
> + ret = -ENOENT;
> + goto out;
> + }
> }
>
> - return do_switch(to);
> + ret = do_switch(to);
> +out:
> + if (ctx)
> + *ctx = to;
> +
> + return ret;
> }
>
> int i915_gem_context_create_ioctl(struct drm_device *dev, void *data,
> diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
> index 2f2daeb..499d025 100644
> --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
> +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
> @@ -1017,7 +1017,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
> if (ret)
> goto err;
>
> - ret = i915_switch_context(ring, file, ctx_id);
> + ret = i915_switch_context(ring, file, ctx_id, NULL);
> if (ret)
> goto err;
>
> --
> 1.7.9.5
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Ben Widawsky, Intel Open Source Technology Center
next prev parent reply other threads:[~2013-02-26 18:29 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-26 11:05 [PATCH 00/13] arb robustness enablers Mika Kuoppala
2013-02-26 11:05 ` [PATCH 01/13] drm/i915: add context parameter to i915_switch_context() Mika Kuoppala
2013-02-26 18:31 ` Ben Widawsky [this message]
2013-02-26 11:05 ` [PATCH 02/13] drm/i915: reference count for i915_hw_contexts Mika Kuoppala
2013-02-26 21:45 ` Ben Widawsky
2013-02-26 11:05 ` [PATCH 03/13] drm/i915: pass seqno to i915_hangcheck_ring_idle Mika Kuoppala
2013-02-26 22:41 ` Ben Widawsky
2013-03-01 13:49 ` Mika Kuoppala
2013-02-26 11:05 ` [PATCH 04/13] drm/i915: track ring progression using seqnos Mika Kuoppala
2013-02-26 14:12 ` Chris Wilson
2013-02-26 15:09 ` Mika Kuoppala
2013-02-26 15:31 ` Chris Wilson
2013-02-26 11:05 ` [PATCH 05/13] drm/i915: introduce i915_hangcheck_ring_hung Mika Kuoppala
2013-02-26 23:03 ` Ben Widawsky
2013-02-26 11:05 ` [PATCH 06/13] drm/i915: detect hang using per ring hangcheck_score Mika Kuoppala
2013-02-26 14:16 ` Chris Wilson
2013-02-26 11:05 ` [PATCH 07/13] drm/i915: remove i915_hangcheck_hung Mika Kuoppala
2013-02-26 11:05 ` [PATCH 08/13] drm/i915: add struct ctx_reset_state Mika Kuoppala
2013-02-26 11:05 ` [PATCH 09/13] drm/i915: add reset_state for hw_contexts Mika Kuoppala
2013-02-27 1:47 ` Ian Romanick
2013-02-27 1:50 ` Ian Romanick
2013-02-27 9:13 ` Chris Wilson
2013-02-28 1:15 ` Ian Romanick
2013-02-28 11:14 ` Chris Wilson
2013-02-28 20:31 ` Ian Romanick
2013-02-27 10:11 ` Mika Kuoppala
2013-02-27 17:20 ` Jesse Barnes
2013-02-26 11:05 ` [PATCH 10/13] drm/i915: mark rings which were waiting when hang happened Mika Kuoppala
2013-02-26 11:05 ` [PATCH 11/13] drm/i915: add batch object and context to i915_add_request() Mika Kuoppala
2013-02-26 14:22 ` Chris Wilson
2013-02-26 11:05 ` [PATCH 12/13] drm/i915: find guilty batch buffer on ring resets Mika Kuoppala
2013-02-26 11:05 ` [PATCH 13/13] drm/i915: refuse to submit more batchbuffers from guilty context Mika Kuoppala
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=20130226183134.GA8657@bwidawsk.net \
--to=ben@bwidawsk.net \
--cc=intel-gfx@lists.freedesktop.org \
--cc=mika.kuoppala@linux.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox