Intel-GFX Archive on 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 1/2] drm/i915/selftests: Pinned the mock kernel context
Date: Wed, 23 May 2018 15:41:18 +0300	[thread overview]
Message-ID: <87y3ga8ryp.fsf@gaia.fi.intel.com> (raw)
In-Reply-To: <20180523095126.8115-1-chris@chris-wilson.co.uk>

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

> The driver assumes that the kernel context is pinned and always
> available for use from any process or atomic context. Make it so for
> selftesting as well!
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
>  drivers/gpu/drm/i915/selftests/mock_engine.c    |  7 +++++++
>  .../gpu/drm/i915/selftests/mock_gem_device.c    | 17 +++++++----------
>  2 files changed, 14 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/selftests/mock_engine.c b/drivers/gpu/drm/i915/selftests/mock_engine.c
> index f1ac7453053e..c2a0451336cf 100644
> --- a/drivers/gpu/drm/i915/selftests/mock_engine.c
> +++ b/drivers/gpu/drm/i915/selftests/mock_engine.c
> @@ -212,8 +212,13 @@ struct intel_engine_cs *mock_engine(struct drm_i915_private *i915,
>  	if (!engine->base.buffer)
>  		goto err_breadcrumbs;
>  
> +	if (IS_ERR(intel_context_pin(i915->kernel_context, &engine->base)))
> +		goto err_ring;
> +
>  	return &engine->base;
>  
> +err_ring:
> +	mock_ring_free(engine->base.buffer);
>  err_breadcrumbs:
>  	intel_engine_fini_breadcrumbs(&engine->base);
>  	i915_timeline_fini(&engine->base.timeline);
> @@ -254,6 +259,8 @@ void mock_engine_free(struct intel_engine_cs *engine)
>  	if (ce)
>  		intel_context_unpin(ce);
>  
> +	__intel_context_unpin(engine->i915->kernel_context, engine);
> +
>  	mock_ring_free(engine->buffer);
>  
>  	intel_engine_fini_breadcrumbs(engine);
> diff --git a/drivers/gpu/drm/i915/selftests/mock_gem_device.c b/drivers/gpu/drm/i915/selftests/mock_gem_device.c
> index 94baedfa0f74..c97075c5ccaf 100644
> --- a/drivers/gpu/drm/i915/selftests/mock_gem_device.c
> +++ b/drivers/gpu/drm/i915/selftests/mock_gem_device.c
> @@ -136,8 +136,6 @@ static struct dev_pm_domain pm_domain = {
>  struct drm_i915_private *mock_gem_device(void)
>  {
>  	struct drm_i915_private *i915;
> -	struct intel_engine_cs *engine;
> -	enum intel_engine_id id;
>  	struct pci_dev *pdev;
>  	int err;
>  
> @@ -233,13 +231,13 @@ struct drm_i915_private *mock_gem_device(void)
>  	mock_init_ggtt(i915);
>  
>  	mkwrite_device_info(i915)->ring_mask = BIT(0);
> -	i915->engine[RCS] = mock_engine(i915, "mock", RCS);
> -	if (!i915->engine[RCS])
> -		goto err_unlock;
> -
>  	i915->kernel_context = mock_context(i915, NULL);
>  	if (!i915->kernel_context)
> -		goto err_engine;
> +		goto err_unlock;
> +
> +	i915->engine[RCS] = mock_engine(i915, "mock", RCS);
> +	if (!i915->engine[RCS])
> +		goto err_context;
>  
>  	mutex_unlock(&i915->drm.struct_mutex);
>  
> @@ -247,9 +245,8 @@ struct drm_i915_private *mock_gem_device(void)
>  
>  	return i915;
>  
> -err_engine:
> -	for_each_engine(engine, i915, id)
> -		mock_engine_free(engine);
> +err_context:
> +	i915_gem_contexts_fini(i915);

For me it looks like there has been hw_ida leak in
this error path, now plugged by this patch.

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

>  err_unlock:
>  	mutex_unlock(&i915->drm.struct_mutex);
>  	kmem_cache_destroy(i915->priorities);
> -- 
> 2.17.0
>
> _______________________________________________
> 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:[~2018-05-23 12:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-23  9:51 [PATCH 1/2] drm/i915/selftests: Pinned the mock kernel context Chris Wilson
2018-05-23  9:51 ` [PATCH 2/2] drm/i915: Look for an active kernel context before switching Chris Wilson
2018-05-23 10:31 ` ✓ Fi.CI.BAT: success for series starting with [1/2] drm/i915/selftests: Pinned the mock kernel context Patchwork
2018-05-23 12:41 ` Mika Kuoppala [this message]
2018-05-23 12:45 ` ✓ Fi.CI.IGT: " 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=87y3ga8ryp.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