public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Imre Deak <imre.deak@intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH v2 01/11] drm/i915: Add support for tracking wakerefs w/o power-on guarantee
Date: Thu, 9 May 2019 12:58:12 +0300	[thread overview]
Message-ID: <20190509095812.GA11264@ideak-desk.fi.intel.com> (raw)
In-Reply-To: <155738898459.28545.5203093508965874850@skylake-alporthouse-com>

On Thu, May 09, 2019 at 09:03:04AM +0100, Chris Wilson wrote:
> Quoting Imre Deak (2019-05-09 07:19:44)
> > It's useful to track runtime PM refs that don't guarantee a device
> > power-on state to the rest of the driver. One such case is holding a
> > reference that will be put asynchronously, during which normal users
> > without their own reference shouldn't access the HW. A follow-up patch
> > will add support for disabling display power domains asynchronously
> > which needs this.
> > 
> > For this we can split wakeref_count into a low half-word tracking
> > all references (raw-wakerefs) and a high half-word tracking
> > references guaranteeing a power-on state (wakelocks).
> > 
> > Follow-up patches will make use of the API added here.
> > 
> > While at it add the missing docbook header for the unchecked
> > display-power and runtime_pm put functions.
> > 
> > No functional changes, except for printing leaked raw-wakerefs
> > and wakelocks separately in intel_runtime_pm_cleanup().
> > 
> > v2:
> > - Track raw wakerefs/wakelocks in the low/high half-word of
> >   wakeref_count, instead of adding a new counter. (Chris)
> > 
> > Cc: Chris Wilson <chris@chris-wilson.co.uk>
> > Signed-off-by: Imre Deak <imre.deak@intel.com>
> > ---
> >  drivers/gpu/drm/i915/intel_drv.h        |  52 +++++++-
> >  drivers/gpu/drm/i915/intel_runtime_pm.c | 150 ++++++++++++++++++------
> >  2 files changed, 160 insertions(+), 42 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> > index 247893ed1543..772ed0fedb39 100644
> > --- a/drivers/gpu/drm/i915/intel_drv.h
> > +++ b/drivers/gpu/drm/i915/intel_drv.h
> > @@ -1619,6 +1619,24 @@ unsigned int i9xx_plane_max_stride(struct intel_plane *plane,
> >                                    unsigned int rotation);
> >  
> >  /* intel_runtime_pm.c */
> 
> #define struct_member(T, member) (((T *)0)->member)
> 
> and stick that in i915_utils.h.

Ok.

> There's a few repetitions in include/linux so maybe worth
> centralising.

For reference, the corresponding spatch, found a few tens of uses across
the tree (not sure if 'identifier I;' is the best way to denote a struct
member):

@nc@
type T;
identifier I;
@@

- ((T *)NULL)->I
+ struct_member(T, I)

> 
> > +#define BITS_PER_WAKEREF       \
> > +       BITS_PER_TYPE(((struct i915_runtime_pm *)NULL)->wakeref_count)
> > +#define INTEL_RPM_WAKELOCK_SHIFT       (BITS_PER_WAKEREF / 2)
> > +#define INTEL_RPM_WAKELOCK_BIAS                (1 << INTEL_RPM_WAKELOCK_SHIFT)
> > +#define INTEL_RPM_RAW_WAKEREF_MASK     (INTEL_RPM_WAKELOCK_BIAS - 1)
> 
> 
> > +static void
> > +intel_runtime_pm_acquire(struct drm_i915_private *i915, bool wakelock)
> > +{
> > +       struct i915_runtime_pm *rpm = &i915->runtime_pm;
> > +
> > +       if (wakelock) {
> > +               atomic_add(1 + INTEL_RPM_WAKELOCK_BIAS, &rpm->wakeref_count);
> > +               assert_rpm_wakelock_held(i915);
> > +       } else {
> > +               atomic_inc(&rpm->wakeref_count);
> > +               assert_rpm_raw_wakeref_held(i915);
> > +       }
> > +}
> > +
> > +static void
> > +intel_runtime_pm_release(struct drm_i915_private *i915, int wakelock)
> > +{
> > +       struct i915_runtime_pm *rpm = &i915->runtime_pm;
> > +
> > +       if (wakelock) {
> > +               assert_rpm_wakelock_held(i915);
> > +               atomic_sub(INTEL_RPM_WAKELOCK_BIAS, &rpm->wakeref_count);
> > +       } else {
> > +               assert_rpm_raw_wakeref_held(i915);
> > +       }
> > +
> > +       __intel_wakeref_dec_and_check_tracking(i915);
> 
> Creating a atomic_sub_and_lock_irqsave() would restore the onion?

Yep. One day I may go through the architecture maze/header magic I
suspect that involves, or if someone could add it I'd be happy to use
that instead.

> 
> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
> -Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2019-05-09  9:58 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-09  6:19 [PATCH v2 00/11] drm/i915: Add support for asynchronous display power disabling Imre Deak
2019-05-09  6:19 ` [PATCH v2 01/11] drm/i915: Add support for tracking wakerefs w/o power-on guarantee Imre Deak
2019-05-09  8:03   ` Chris Wilson
2019-05-09  9:58     ` Imre Deak [this message]
2019-05-09  6:19 ` [PATCH v2 02/11] drm/i915: Force printing wakeref tacking during pm_cleanup Imre Deak
2019-05-09  8:05   ` Chris Wilson
2019-05-09  6:19 ` [PATCH v2 03/11] drm/i915: Verify power domains state during suspend in all cases Imre Deak
2019-05-09  8:05   ` Chris Wilson
2019-05-09  6:19 ` [PATCH v2 04/11] drm/i915: Add support for asynchronous display power disabling Imre Deak
2019-05-09  8:17   ` Chris Wilson
2019-05-09 10:46     ` Imre Deak
2019-05-09  6:19 ` [PATCH v2 05/11] drm/i915: Disable power asynchronously during DP AUX transfers Imre Deak
2019-05-09  6:19 ` [PATCH v2 06/11] drm/i915: WARN for eDP encoders in intel_dp_detect_dpcd() Imre Deak
2019-05-09  6:19 ` [PATCH v2 07/11] drm/i915: Remove the unneeded AUX power ref from intel_dp_detect() Imre Deak
2019-05-09 15:57   ` Ville Syrjälä
2019-05-09 16:10     ` Imre Deak
2019-05-09  6:19 ` [PATCH v2 08/11] drm/i915: Remove the unneeded AUX power ref from intel_dp_hpd_pulse() Imre Deak
2019-05-09 15:50   ` Ville Syrjälä
2019-05-09 16:06     ` Imre Deak
2019-05-09  6:19 ` [PATCH v2 09/11] drm/i915: Replace use of PLLS power domain with DISPLAY_CORE domain Imre Deak
2019-05-09  6:19 ` [PATCH v2 10/11] drm/i915: Avoid taking the PPS lock for non-eDP/VLV/CHV Imre Deak
2019-05-09  6:19 ` [PATCH v2 11/11] drm/i915: Assert that TypeC ports are not used for eDP Imre Deak
2019-05-09  8:42 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Add support for asynchronous display power disabling (rev3) Patchwork
2019-05-09  9:09 ` ✓ Fi.CI.BAT: success " Patchwork
2019-05-09 10:21 ` ✓ Fi.CI.IGT: " Patchwork
2019-05-09 16:25 ` [PATCH v2 00/11] drm/i915: Add support for asynchronous display power disabling Ville Syrjälä

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=20190509095812.GA11264@ideak-desk.fi.intel.com \
    --to=imre.deak@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