[Intel-gfx] [PATCH v2] drm/core: Add drm_accurate_vblank_count_and_time, v2.

Ville Syrjälä ville.syrjala at linux.intel.com
Mon Apr 11 15:17:03 UTC 2016


On Mon, Apr 11, 2016 at 05:06:24PM +0200, Maarten Lankhorst wrote:
> Op 11-04-16 om 16:43 schreef Ville Syrjälä:
> > 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 at gmail.com>
> >> Cc: Ville Syrjälä <ville.syrjala at linux.intel.com>
> >> Signed-off-by: Maarten Lankhorst <maarten.lankhorst at 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?
> >
> No, I guess allowing a NULL pointer for tv_ret might help.

Or just killing the entire parameter.

-- 
Ville Syrjälä
Intel OTC


More information about the Intel-gfx mailing list