From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2] drm/core: Add drm_accurate_vblank_count_and_time, v2.
Date: Mon, 11 Apr 2016 17:43:20 +0300 [thread overview]
Message-ID: <20160411144320.GG4329@intel.com> (raw)
In-Reply-To: <570B71A1.4050406@linux.intel.com>
On Mon, Apr 11, 2016 at 11:42:57AM +0200, Maarten Lankhorst wrote:
> This function is useful for gen2 intel devices which have no frame
> counter, but need a way to determine the current vblank count without
> racing with the vblank interrupt handler.
>
> intel_pipe_update_start checks if no vblank interrupt will occur
> during vblank evasion, but cannot check whether the vblank handler has
> run to completion. This function uses the timestamps to determine
> when the last vblank has happened, and interpolates from there.
>
> Changes since v1:
> - Take vblank_time_lock and don't use drm_vblank_count_and_time.
>
> Cc: Mario Kleiner <mario.kleiner.de@gmail.com>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> ---
> drivers/gpu/drm/drm_irq.c | 31 +++++++++++++++++++++++++++++++
> include/drm/drmP.h | 2 ++
> 2 files changed, 33 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
> index 3c1a6f18e71c..d3cecc1932e1 100644
> --- a/drivers/gpu/drm/drm_irq.c
> +++ b/drivers/gpu/drm/drm_irq.c
> @@ -303,6 +303,37 @@ static void drm_update_vblank_count(struct drm_device *dev, unsigned int pipe,
> store_vblank(dev, pipe, diff, &t_vblank, cur_vblank);
> }
>
> +/**
> + * drm_accurate_vblank_count_and_time - retrieve the master vblank counter
> + * @crtc: which counter to retrieve
> + * @tv_ret: last time counter was updated
> + *
> + * This function is similar to @drm_update_vblank_count_and_time but
> + * this function interpolates to handle a race with vblank irq's, and
> + * is only useful for crtc's that have no hw vblank counter.
> + */
> +
> +u32 drm_accurate_vblank_count_and_time(struct drm_crtc *crtc,
> + struct timeval *tv_ret)
> +{
> + struct drm_device *dev = crtc->dev;
> + u32 vblank, pipe = drm_crtc_index(crtc);
> + unsigned long flags;
> +
> + WARN(dev->max_vblank_count, "This function is only useful when a hw counter is unavailable.");
It's useful on everything if you actually want to trust the
software counter to not be stale.
> +
> + spin_lock_irqsave(&dev->vblank_time_lock, flags);
> + drm_update_vblank_count(dev, pipe, 0);
> +
> + vblank = dev->vblank[pipe].count;
> + *tv_ret = vblanktimestamp(dev, pipe, vblank);
Do we have a user in mind that would care about the timestamp?
> +
> + spin_unlock_irqrestore(&dev->vblank_time_lock, flags);
> +
> + return vblank;
> +}
> +EXPORT_SYMBOL(drm_accurate_vblank_count_and_time);
> +
> /*
> * Disable vblank irq's on crtc, make sure that last vblank count
> * of hardware and corresponding consistent software vblank counter
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index 31483c2fef51..1df65922c7c6 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -995,6 +995,8 @@ extern void drm_crtc_vblank_off(struct drm_crtc *crtc);
> extern void drm_crtc_vblank_reset(struct drm_crtc *crtc);
> extern void drm_crtc_vblank_on(struct drm_crtc *crtc);
> extern void drm_vblank_cleanup(struct drm_device *dev);
> +extern u32 drm_accurate_vblank_count_and_time(struct drm_crtc *crtc,
> + struct timeval *tv_ret);
> extern u32 drm_vblank_no_hw_counter(struct drm_device *dev, unsigned int pipe);
>
> extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
> --
> 2.1.0
>
--
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2016-04-11 14:43 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-29 13:38 [PATCH] drm/core: Add drm_accurate_vblank_count_and_time Maarten Lankhorst
2016-03-30 13:13 ` Ville Syrjälä
2016-03-30 13:41 ` Maarten Lankhorst
2016-03-30 13:45 ` Ville Syrjälä
2016-04-11 9:42 ` [PATCH v2] drm/core: Add drm_accurate_vblank_count_and_time, v2 Maarten Lankhorst
2016-04-11 14:43 ` Ville Syrjälä [this message]
2016-04-11 15:06 ` Maarten Lankhorst
2016-04-11 15:17 ` Ville Syrjälä
2016-04-12 14:32 ` [PATCH v3] drm/core: Add drm_accurate_vblank_count, v3 Maarten Lankhorst
2016-04-12 15:03 ` Ville Syrjälä
2016-04-12 16:43 ` [Intel-gfx] " kbuild test robot
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=20160411144320.GG4329@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=maarten.lankhorst@linux.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