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] drm/i915: Mark intel_wakeref_get() as a sleeper
Date: Thu, 21 Nov 2019 14:55:42 +0200	[thread overview]
Message-ID: <87lfs9xub5.fsf@gaia.fi.intel.com> (raw)
In-Reply-To: <20191121085914.120455-1-chris@chris-wilson.co.uk>

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

> Assume that intel_wakereg_get() may take the mutex, and perform other
> sleeping actions in the course of its callbacks and so use might_sleep()
> to ensure that all callers abide. Anything that cannot sleep has to use
> e.g. intel_wakeref_get_if_active() to guarantee its avoidance of the
> non-atomic paths.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

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

> ---
>  drivers/gpu/drm/i915/gt/intel_gt_pm.h           |  5 +++++
>  drivers/gpu/drm/i915/gt/intel_lrc.c             |  2 +-
>  .../gpu/drm/i915/gt/uc/intel_guc_submission.c   |  2 +-
>  drivers/gpu/drm/i915/intel_wakeref.h            | 17 +++++++++++++++--
>  4 files changed, 22 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/intel_gt_pm.h b/drivers/gpu/drm/i915/gt/intel_gt_pm.h
> index 990efc27a4e4..4a9e48c12bd4 100644
> --- a/drivers/gpu/drm/i915/gt/intel_gt_pm.h
> +++ b/drivers/gpu/drm/i915/gt/intel_gt_pm.h
> @@ -22,6 +22,11 @@ static inline void intel_gt_pm_get(struct intel_gt *gt)
>  	intel_wakeref_get(&gt->wakeref);
>  }
>  
> +static inline void __intel_gt_pm_get(struct intel_gt *gt)
> +{
> +	__intel_wakeref_get(&gt->wakeref);
> +}
> +
>  static inline bool intel_gt_pm_get_if_awake(struct intel_gt *gt)
>  {
>  	return intel_wakeref_get_if_active(&gt->wakeref);
> diff --git a/drivers/gpu/drm/i915/gt/intel_lrc.c b/drivers/gpu/drm/i915/gt/intel_lrc.c
> index b65bc06855b0..516306ebc839 100644
> --- a/drivers/gpu/drm/i915/gt/intel_lrc.c
> +++ b/drivers/gpu/drm/i915/gt/intel_lrc.c
> @@ -1121,7 +1121,7 @@ __execlists_schedule_in(struct i915_request *rq)
>  		BUILD_BUG_ON(NUM_CONTEXT_TAG > GEN12_MAX_CONTEXT_HW_ID);
>  	}
>  
> -	intel_gt_pm_get(engine->gt);
> +	__intel_gt_pm_get(engine->gt);
>  	execlists_context_status_change(rq, INTEL_CONTEXT_SCHEDULE_IN);
>  	intel_engine_context_in(engine);
>  
> diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
> index dcccbd640809..6f94af7ad1de 100644
> --- a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
> +++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
> @@ -529,7 +529,7 @@ static struct i915_request *schedule_in(struct i915_request *rq, int idx)
>  	 * required if we generalise the inflight tracking.
>  	 */
>  
> -	intel_gt_pm_get(rq->engine->gt);
> +	__intel_gt_pm_get(rq->engine->gt);
>  	return i915_request_get(rq);
>  }
>  
> diff --git a/drivers/gpu/drm/i915/intel_wakeref.h b/drivers/gpu/drm/i915/intel_wakeref.h
> index da6e8fd506e6..3897bfea72d9 100644
> --- a/drivers/gpu/drm/i915/intel_wakeref.h
> +++ b/drivers/gpu/drm/i915/intel_wakeref.h
> @@ -59,9 +59,7 @@ void __intel_wakeref_put_last(struct intel_wakeref *wf, unsigned long flags);
>  
>  /**
>   * intel_wakeref_get: Acquire the wakeref
> - * @i915: the drm_i915_private device
>   * @wf: the wakeref
> - * @fn: callback for acquired the wakeref, called only on first acquire.
>   *
>   * Acquire a hold on the wakeref. The first user to do so, will acquire
>   * the runtime pm wakeref and then call the @fn underneath the wakeref
> @@ -76,12 +74,27 @@ void __intel_wakeref_put_last(struct intel_wakeref *wf, unsigned long flags);
>  static inline int
>  intel_wakeref_get(struct intel_wakeref *wf)
>  {
> +	might_sleep();
>  	if (unlikely(!atomic_inc_not_zero(&wf->count)))
>  		return __intel_wakeref_get_first(wf);
>  
>  	return 0;
>  }
>  
> +/**
> + * __intel_wakeref_get: Acquire the wakeref, again
> + * @wf: the wakeref
> + *
> + * Increment the wakeref counter, but only valid if it is already held by
> + * the caller.
> + */
> +static inline void
> +__intel_wakeref_get(struct intel_wakeref *wf)
> +{
> +	INTEL_WAKEREF_BUG_ON(!atomic_read(&wf->count));
> +	atomic_inc(&wf->count);
> +}
> +
>  /**
>   * intel_wakeref_get_if_in_use: Acquire the wakeref
>   * @wf: the wakeref
> -- 
> 2.24.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

WARNING: multiple messages have this Message-ID (diff)
From: Mika Kuoppala <mika.kuoppala@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH] drm/i915: Mark intel_wakeref_get() as a sleeper
Date: Thu, 21 Nov 2019 14:55:42 +0200	[thread overview]
Message-ID: <87lfs9xub5.fsf@gaia.fi.intel.com> (raw)
Message-ID: <20191121125542.v-qlbaRTn3C5txQsM5uH4viWee7-ELKmD8-sctLhdy4@z> (raw)
In-Reply-To: <20191121085914.120455-1-chris@chris-wilson.co.uk>

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

> Assume that intel_wakereg_get() may take the mutex, and perform other
> sleeping actions in the course of its callbacks and so use might_sleep()
> to ensure that all callers abide. Anything that cannot sleep has to use
> e.g. intel_wakeref_get_if_active() to guarantee its avoidance of the
> non-atomic paths.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

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

> ---
>  drivers/gpu/drm/i915/gt/intel_gt_pm.h           |  5 +++++
>  drivers/gpu/drm/i915/gt/intel_lrc.c             |  2 +-
>  .../gpu/drm/i915/gt/uc/intel_guc_submission.c   |  2 +-
>  drivers/gpu/drm/i915/intel_wakeref.h            | 17 +++++++++++++++--
>  4 files changed, 22 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/intel_gt_pm.h b/drivers/gpu/drm/i915/gt/intel_gt_pm.h
> index 990efc27a4e4..4a9e48c12bd4 100644
> --- a/drivers/gpu/drm/i915/gt/intel_gt_pm.h
> +++ b/drivers/gpu/drm/i915/gt/intel_gt_pm.h
> @@ -22,6 +22,11 @@ static inline void intel_gt_pm_get(struct intel_gt *gt)
>  	intel_wakeref_get(&gt->wakeref);
>  }
>  
> +static inline void __intel_gt_pm_get(struct intel_gt *gt)
> +{
> +	__intel_wakeref_get(&gt->wakeref);
> +}
> +
>  static inline bool intel_gt_pm_get_if_awake(struct intel_gt *gt)
>  {
>  	return intel_wakeref_get_if_active(&gt->wakeref);
> diff --git a/drivers/gpu/drm/i915/gt/intel_lrc.c b/drivers/gpu/drm/i915/gt/intel_lrc.c
> index b65bc06855b0..516306ebc839 100644
> --- a/drivers/gpu/drm/i915/gt/intel_lrc.c
> +++ b/drivers/gpu/drm/i915/gt/intel_lrc.c
> @@ -1121,7 +1121,7 @@ __execlists_schedule_in(struct i915_request *rq)
>  		BUILD_BUG_ON(NUM_CONTEXT_TAG > GEN12_MAX_CONTEXT_HW_ID);
>  	}
>  
> -	intel_gt_pm_get(engine->gt);
> +	__intel_gt_pm_get(engine->gt);
>  	execlists_context_status_change(rq, INTEL_CONTEXT_SCHEDULE_IN);
>  	intel_engine_context_in(engine);
>  
> diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
> index dcccbd640809..6f94af7ad1de 100644
> --- a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
> +++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
> @@ -529,7 +529,7 @@ static struct i915_request *schedule_in(struct i915_request *rq, int idx)
>  	 * required if we generalise the inflight tracking.
>  	 */
>  
> -	intel_gt_pm_get(rq->engine->gt);
> +	__intel_gt_pm_get(rq->engine->gt);
>  	return i915_request_get(rq);
>  }
>  
> diff --git a/drivers/gpu/drm/i915/intel_wakeref.h b/drivers/gpu/drm/i915/intel_wakeref.h
> index da6e8fd506e6..3897bfea72d9 100644
> --- a/drivers/gpu/drm/i915/intel_wakeref.h
> +++ b/drivers/gpu/drm/i915/intel_wakeref.h
> @@ -59,9 +59,7 @@ void __intel_wakeref_put_last(struct intel_wakeref *wf, unsigned long flags);
>  
>  /**
>   * intel_wakeref_get: Acquire the wakeref
> - * @i915: the drm_i915_private device
>   * @wf: the wakeref
> - * @fn: callback for acquired the wakeref, called only on first acquire.
>   *
>   * Acquire a hold on the wakeref. The first user to do so, will acquire
>   * the runtime pm wakeref and then call the @fn underneath the wakeref
> @@ -76,12 +74,27 @@ void __intel_wakeref_put_last(struct intel_wakeref *wf, unsigned long flags);
>  static inline int
>  intel_wakeref_get(struct intel_wakeref *wf)
>  {
> +	might_sleep();
>  	if (unlikely(!atomic_inc_not_zero(&wf->count)))
>  		return __intel_wakeref_get_first(wf);
>  
>  	return 0;
>  }
>  
> +/**
> + * __intel_wakeref_get: Acquire the wakeref, again
> + * @wf: the wakeref
> + *
> + * Increment the wakeref counter, but only valid if it is already held by
> + * the caller.
> + */
> +static inline void
> +__intel_wakeref_get(struct intel_wakeref *wf)
> +{
> +	INTEL_WAKEREF_BUG_ON(!atomic_read(&wf->count));
> +	atomic_inc(&wf->count);
> +}
> +
>  /**
>   * intel_wakeref_get_if_in_use: Acquire the wakeref
>   * @wf: the wakeref
> -- 
> 2.24.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

  reply	other threads:[~2019-11-21 12:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-20 18:39 [PATCH] drm/i915: Mark intel_wakeref_get() as a sleeper Chris Wilson
2019-11-20 18:39 ` [Intel-gfx] " Chris Wilson
2019-11-21  0:34 ` ✗ Fi.CI.BAT: failure for " Patchwork
2019-11-21  0:34   ` [Intel-gfx] " Patchwork
2019-11-21  8:59 ` [PATCH] " Chris Wilson
2019-11-21  8:59   ` [Intel-gfx] " Chris Wilson
2019-11-21 12:55   ` Mika Kuoppala [this message]
2019-11-21 12:55     ` Mika Kuoppala
2019-11-21 10:55 ` ✓ Fi.CI.BAT: success for drm/i915: Mark intel_wakeref_get() as a sleeper (rev2) Patchwork
2019-11-21 10:55   ` [Intel-gfx] " 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=87lfs9xub5.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.