public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Jani Nikula <jani.nikula@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org, Paulo Zanoni <paulo.r.zanoni@intel.com>
Subject: Re: [PATCH 2/6] drm/i915: save some time when waiting the eDP timings
Date: Fri, 20 Dec 2013 15:24:34 +0100	[thread overview]
Message-ID: <20131220142434.GC23400@phenom.ffwll.local> (raw)
In-Reply-To: <87fvpnkgyg.fsf@intel.com>

On Fri, Dec 20, 2013 at 11:30:15AM +0200, Jani Nikula wrote:
> On Thu, 19 Dec 2013, Paulo Zanoni <przanoni@gmail.com> wrote:
> > From: Paulo Zanoni <paulo.r.zanoni@intel.com>
> >
> > The eDP spec defines some points where after you do action A, you have
> > to wait some time before action B. The thing is that in our driver
> > action B does not happen exactly after action A, but we still use
> > msleep() calls directly. What this patch does is that we record the
> > timestamp of when action A happened, then, just before action B, we
> > look at how much time has passed and only sleep the remaining amount
> > needed.
> >
> > With this change, I am able to save about 5-20ms (out of the total
> > 200ms) of the backlight_off delay and completely skip the 1ms
> > backlight_on delay. The 600ms vdd_off delay doesn't happen during
> > normal usage anymore due to a previous patch.
> >
> > v2: - Rename ironlake_wait_jiffies_delay to intel_wait_until_after and
> >       move it to intel_display.c
> >     - Fix the msleep call: diff is in jiffies
> > v3: - Use "tmp_jiffies" so we don't need to worry about the value of
> >       "jiffies" advancing while we're doing the math.
> > v4: - Rename function again.
> >     - Move function to i915_drv.h.
> >     - Store last_power_cycle at edp_panel_off too.
> >     - Use msecs_to_jiffies_timeout, then replace the msleep with an
> >       open-coded version that avoids the extra +1 jiffy.
> >     - Try to add units to every variable name so we don't confuse
> >       jiffies with milliseconds.
> >
> > Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
> > ---
> >  drivers/gpu/drm/i915/i915_drv.h  | 29 +++++++++++++++++++++++++++++
> >  drivers/gpu/drm/i915/intel_dp.c  | 27 ++++++++++++++++++++++++---
> >  drivers/gpu/drm/i915/intel_drv.h |  3 +++
> >  3 files changed, 56 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> > index cc8afff..7e9b436 100644
> > --- a/drivers/gpu/drm/i915/i915_drv.h
> > +++ b/drivers/gpu/drm/i915/i915_drv.h
> > @@ -2636,4 +2636,33 @@ timespec_to_jiffies_timeout(const struct timespec *value)
> >  	return min_t(unsigned long, MAX_JIFFY_OFFSET, j + 1);
> >  }
> >  
> > +/*
> > + * If you need to wait X milliseconds between events A and B, but event B
> > + * doesn't happen exactly after event A, you record the timestamp (jiffies) of
> > + * when event A happened, then just before event B you call this function and
> > + * pass the timestamp as the first argument, and X as the second argument.
> > + */
> > +static inline void
> > +wait_remaining_ms_from_jiffies(unsigned long timestamp_jiffies, int to_wait_ms)
> > +{
> > +	unsigned long target_jiffies, tmp_jiffies;
> > +	unsigned int remaining_ms;
> > +
> > +	/*
> > +	 * Don't re-read the value of "jiffies" every time since it may change
> > +	 * behind our back and break the math.
> > +	 */
> > +	tmp_jiffies = jiffies;
> > +	target_jiffies = timestamp_jiffies +
> > +			 msecs_to_jiffies_timeout(to_wait_ms);
> 
> Is it possible this gets called before the last_* timestamp fields are
> initialized, resulting to timestamp_jiffies being 0? Do we need to
> special case that? If not, perhaps add a WARN_ON(timestamp_jiffies == 0)
> so we maintain this precondition.

afaik jiffies are allowed to wrap around to 0 ...
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

  reply	other threads:[~2013-12-20 14:23 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-19 16:29 [PATCH 0/6] eDP panel power sequencing optimizations Paulo Zanoni
2013-12-19 16:29 ` [PATCH 1/6] drm/i915: init the DP panel power seq variables earlier Paulo Zanoni
2013-12-19 17:24   ` Jesse Barnes
2013-12-19 16:29 ` [PATCH 2/6] drm/i915: save some time when waiting the eDP timings Paulo Zanoni
2013-12-19 17:32   ` Jesse Barnes
2013-12-20  9:30   ` Jani Nikula
2013-12-20 14:24     ` Daniel Vetter [this message]
2014-01-03 18:27     ` Paulo Zanoni
2014-01-03 19:45       ` Paulo Zanoni
2014-01-17 13:09   ` Jani Nikula
2014-01-17 13:29     ` Daniel Vetter
2014-01-17 13:53       ` Daniel Vetter
2013-12-19 16:29 ` [PATCH 3/6] drm/i915: reset eDP timestamps on resume Paulo Zanoni
2013-12-19 17:35   ` Jesse Barnes
2014-01-03 19:46     ` Paulo Zanoni
2014-01-15 18:21       ` Jesse Barnes
2014-01-15 23:36         ` Daniel Vetter
2014-01-16 14:26           ` Paulo Zanoni
2014-01-17 20:17             ` Paulo Zanoni
2014-01-17 20:22               ` Chris Wilson
2014-01-17 21:11                 ` Paulo Zanoni
2014-01-17 21:21                   ` Chris Wilson
2014-01-17 21:34                     ` Daniel Vetter
2014-01-20 15:47                       ` Paulo Zanoni
2014-01-20 16:10                         ` Daniel Vetter
2013-12-19 16:29 ` [PATCH 4/6] drm/i915: remove a column of zeros from the eDP wait definitions Paulo Zanoni
2013-12-19 17:36   ` Jesse Barnes
2013-12-19 16:29 ` [PATCH 5/6] drm/i915: don't wait for power cycle when waiting for power off Paulo Zanoni
2013-12-19 17:38   ` Jesse Barnes
2013-12-19 18:34     ` Jesse Barnes
2013-12-19 16:29 ` [PATCH 6/6] drm/i915: set the backlight panel delays registers to 1 Paulo Zanoni
2013-12-19 17:39   ` Jesse Barnes
2014-01-17 13:57     ` Daniel Vetter
2014-01-20 16:12       ` Daniel Vetter
2014-01-28  7:57   ` Jani Nikula
2014-01-28  8:02     ` Daniel Vetter
2014-01-28  8:23       ` Jani Nikula

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=20131220142434.GC23400@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=paulo.r.zanoni@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