All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Paulo Zanoni <przanoni@gmail.com>
Cc: Intel Graphics Development <intel-gfx@lists.freedesktop.org>,
	DRI Development <dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH 11/9] drm/i915: Opt out of vblank disable timer on >gen2
Date: Thu, 19 Nov 2015 23:15:55 +0200	[thread overview]
Message-ID: <20151119211555.GF4437@intel.com> (raw)
In-Reply-To: <20151119205330.GD4437@intel.com>

On Thu, Nov 19, 2015 at 10:53:30PM +0200, Ville Syrjälä wrote:
> On Thu, Nov 19, 2015 at 06:35:04PM -0200, Paulo Zanoni wrote:
> > 2015-11-19 18:06 GMT-02:00 Ville Syrjälä <ville.syrjala@linux.intel.com>:
> > > On Thu, Nov 19, 2015 at 05:44:51PM -0200, Paulo Zanoni wrote:
> > >> 2014-05-26 11:26 GMT-03:00  <ville.syrjala@linux.intel.com>:
> > >> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > >> >
> > >> > Now that the vblank races are plugged, we can opt out of using
> > >> > the vblank disable timer and just let vblank interrupts get
> > >> > disabled immediately when the last reference is dropped.
> > >> >
> > >> > Gen2 is the exception since it has no hardware frame counter.
> > >>
> > >> Hi
> > >>
> > >> Remember last week's FBC vblank optimization patch that had an
> > >> erroneous drm_crtc_vblank_get() instead of drm_crtc_vblank_count()?
> > >> After I fixed the bug in the patch I realized that it was the
> > >> unbalanced vblank_get() call that moved PC state residency up.
> > >>
> > >> I did some experiments, and on my specific BDW machine, after running
> > >> "powertop --auto-tune", I get about 15-25% PC7 residency without FBC.
> > >> If I revert this patch, the number jumps to 40-45%. With FBC, the PC7
> > >> residency goes from 60-70% to 85-90% when I revert this patch. I'm
> > >> running just an idle Cinnamon with an open terminal.
> > >>
> > >> So, since the commit message lacks more details, what are the
> > >> downsides of reverting this patch? What are the advantages of opting
> > >> out of the vblank timer? I see my desktop does tons and tons of vblank
> > >> get/put calls per second, so the disable timer makes a lot of sense.
> > >
> > > "Idle" desktop :(
> > 
> > My first realization of this little problem was when I was
> > implementing runtime PM :)
> > 
> > 
> > >
> > > Really the immediate disable should save power. Where are these tons of
> > > vblank get/puts coming from actually?
> > 
> > I'll take a finer look tomorrow, but I assume it's probably some
> > application redrawing. I see it does calm down sometimes, but that's
> > not enough to get better PC7 residency.
> > 
> > 
> > > I would assume you'd get a handful
> > > per frame at most, and that when you're actually doing something. On an
> > > idle system I would expect nothing at all happens during most frames.
> > >
> > > Not sure, but I guess it's possible the extra register accesses in the
> > > get/puts actually cause the display to exit low power states all the time,
> > > or something.
> > 
> > I tried replacing the register macros with the _FW version and that didn't help.
> 
> Well, that would just get rid of the unclaimed reg checks. Nothing more
> I think.
> 
> > 
> > 
> > >
> > > There's also this note in Bspec (for HSW at least):
> > 
> > I think this not is present on most (all?) gens.
> 
> Doesn't really prove anything.
> 
> > >  "Workaround : Do not enable and unmask this interrupt if the associated
> > >   pipe is disabled.  Do not leave this interrupt enabled and unmasked
> > >   after the associated pipe is disabled."
> > > which we took to mean that having the interrupt masked but enabled is
> > > fine.
> > 
> > I'm aware of this, but I think the problem is that the resources
> > drained by the constant enable+disable+enable+disable outweigh the
> > resources saved by turning off vblanks.
> 
> Well the CPU is awake anyway doing the get/put, so not sure why a a few
> extra register accesses there would have such a huge impact.
> 
> > Not sure if there's an extra
> > reason why BSpec asks us to immediately disable vblanks though...
> > 
> > So, to summarize, the main (only?) reason is the BSpec comment?
> 
> The point is not to wake up due to interrupts when we don't need them.
> 
> > 
> > 
> > > But maybe we'd actually have to frob IER too to avoid wasting
> > > power somehow?
> > 
> > With the interrupt masked on IMR, I don't think IER matters.
> 
> I'm not sure anyone actually verified that.

Well, I just tried this on HSW. And on that one IER didn't make a
difference to pc7 residency (~70%) at least. This was on an actually
idle system ;)

> 
> > 
> > >
> > >> I also wish there was some easy way to check how this patch (or its
> > >> revert) affect a bunch of different workloads...
> > >>
> > >> (Also CCing Chris for insightful comments on performance)
> > >
> > > IIRC Chris had a patch to not disable the interrupt immediately when
> > > the refcount drops to 0, but instead delay the disable until the next
> > > interrupt actually happens. But I guess it didn't go in? Probably I
> > > should have reviewed it but didn't. It sounds like a decent idea to
> > > me in any case for the active use case.
> > >
> > >>
> > >> Thanks,
> > >> Paulo
> > >>
> > >> >
> > >> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > >> > ---
> > >> >  drivers/gpu/drm/i915/i915_irq.c | 8 ++++++++
> > >> >  1 file changed, 8 insertions(+)
> > >> >
> > >> > diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
> > >> > index 28bae6e..4b2e7af 100644
> > >> > --- a/drivers/gpu/drm/i915/i915_irq.c
> > >> > +++ b/drivers/gpu/drm/i915/i915_irq.c
> > >> > @@ -4364,6 +4364,14 @@ void intel_irq_init(struct drm_device *dev)
> > >> >                 dev->max_vblank_count = 0xffffff; /* only 24 bits of frame count */
> > >> >         }
> > >> >
> > >> > +       /*
> > >> > +        * Opt out of the vblank disable timer on everything except gen2.
> > >> > +        * Gen2 doesn't have a hardware frame counter and so depends on
> > >> > +        * vblank interrupts to produce sane vblank seuquence numbers.
> > >> > +        */
> > >> > +       if (!IS_GEN2(dev))
> > >> > +               dev->vblank_disable_immediate = true;
> > >> > +
> > >> >         if (drm_core_check_feature(dev, DRIVER_MODESET)) {
> > >> >                 dev->driver->get_vblank_timestamp = i915_get_vblank_timestamp;
> > >> >                 dev->driver->get_scanout_position = i915_get_crtc_scanoutpos;
> > >> > --
> > >> > 1.8.5.5
> > >> >
> > >> > _______________________________________________
> > >> > Intel-gfx mailing list
> > >> > Intel-gfx@lists.freedesktop.org
> > >> > http://lists.freedesktop.org/mailman/listinfo/intel-gfx
> > >>
> > >>
> > >>
> > >> --
> > >> Paulo Zanoni
> > >
> > > --
> > > Ville Syrjälä
> > > Intel OTC
> > 
> > 
> > 
> > -- 
> > Paulo Zanoni
> 
> -- 
> Ville Syrjälä
> Intel OTC
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2015-11-19 21:15 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-26 11:46 [PATCH 0/9] drm: More vblank on/off work ville.syrjala
2014-05-26 11:46 ` [PATCH 1/9] drm: Always reject drm_vblank_get() after drm_vblank_off() ville.syrjala
2014-05-26 13:21   ` Daniel Vetter
2014-05-26 13:32     ` Ville Syrjälä
2014-05-26 13:47       ` Daniel Vetter
2014-05-26 11:46 ` [PATCH 2/9] drm/i915: Warn if drm_vblank_get() still works " ville.syrjala
2014-05-26 13:22   ` Daniel Vetter
2014-05-26 13:36     ` Ville Syrjälä
2014-05-26 13:48       ` Daniel Vetter
2014-05-26 13:49     ` [PATCH v2 " ville.syrjala
2014-05-26 13:54       ` Daniel Vetter
2014-05-26 11:46 ` [PATCH 3/9] drm: Don't clear vblank timestamps when vblank interrupt is disabled ville.syrjala
2014-05-26 13:24   ` Daniel Vetter
2014-05-26 11:46 ` [PATCH 4/9] drm: Move drm_update_vblank_count() ville.syrjala
2014-05-26 11:46 ` [PATCH 5/9] drm: Have the vblank counter account for the time between vblank irq disable and drm_vblank_off() ville.syrjala
2014-05-26 13:27   ` Daniel Vetter
2014-05-26 11:46 ` [PATCH 6/9] drm: Avoid random vblank counter jumps if the hardware counter has been reset ville.syrjala
2014-05-26 13:28   ` Daniel Vetter
2014-05-26 11:46 ` [PATCH 7/9] drm: Disable vblank interrupt immediately when drm_vblank_offdelay==0 ville.syrjala
2014-05-26 13:02   ` [Intel-gfx] " Daniel Vetter
2014-05-26 14:26     ` [PATCH 10/9] drm: Add dev->vblank_disable_immediate flag ville.syrjala
2014-05-26 14:26       ` [PATCH 11/9] drm/i915: Opt out of vblank disable timer on >gen2 ville.syrjala
2014-05-26 15:31         ` Daniel Vetter
2014-05-26 19:27         ` Daniel Vetter
2015-11-19 19:44         ` [Intel-gfx] " Paulo Zanoni
2015-11-19 20:06           ` Ville Syrjälä
2015-11-19 20:35             ` Paulo Zanoni
2015-11-19 20:53               ` Ville Syrjälä
2015-11-19 21:15                 ` Ville Syrjälä [this message]
2015-11-19 21:27             ` Chris Wilson
2014-06-20  0:41       ` [PATCH 10/9] drm: Add dev->vblank_disable_immediate flag Matt Roper
2014-07-29 17:31         ` [Intel-gfx] " Ville Syrjälä
2014-07-29 17:57           ` Daniel Vetter
2014-05-26 16:06     ` [PATCH v2 1/9] drm: Always reject drm_vblank_get() after drm_vblank_off() ville.syrjala
2014-05-26 11:46 ` [PATCH 8/9] drm: Reduce the amount of dev->vblank[crtc] in the code ville.syrjala
2014-05-26 13:31   ` Daniel Vetter
2014-05-26 11:46 ` [PATCH v2 9/9] drm/i915: Leave interrupts enabled while disabling crtcs during suspend ville.syrjala
2014-05-26 15:49   ` Daniel Vetter
2014-06-20 18:10   ` Matt Roper
2014-06-02  8:15 ` [PATCH 12/9] drm: Fix deadlock between event_lock and vbl_lock/vblank_time_lock ville.syrjala
2014-06-02  8:15   ` [PATCH 13/9] drm: Fix race between drm_vblank_off() and drm_queue_vblank_event() ville.syrjala
2014-06-02  8:15   ` [PATCH 14/9] drm: Kick start vblank interrupts at drm_vblank_on() ville.syrjala
2014-06-20 18:29     ` Matt Roper
2014-06-26 16:32 ` [PATCH 0/9] drm: More vblank on/off work Jesse Barnes

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=20151119211555.GF4437@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=przanoni@gmail.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 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.