[PATCH] drm: Add high-precision time to vblank trace event

Daniel Vetter daniel at ffwll.ch
Wed Aug 14 17:15:18 UTC 2019


On Fri, Aug 09, 2019 at 05:36:39PM +0200, Heinrich wrote:
> Store the timestamp of the current vblank in the new field 'time' of the
> vblank trace event. If the timestamp is calculated by a driver that
> supports high-precision vblank timing, set the field 'high-prec' to
> 'true'.
> 
> User space can now access actual hardware vblank times via the tracing
> infrastructure. Tracing applications (such as GPUVis, see [0] for
> related discussion), can use the newly added information to conduct a
> more accurate analysis of display timing.
> 
> [0] https://github.com/mikesart/gpuvis/issues/30
> 
> Signed-off-by: Heinrich <heinrich.fink at daqri.com>

lgtm, and I think rather useful.

Reviewed-by: Daniel Vetter <daniel.vetter at ffwll.ch>

I think we should let this hang out on the m-l for 2 weeks or so in case
of comments and what not. Please ping me again (since most likely I'll
forget).

Also adding Keith, he's been playing around a lot lately with vblank
timestamps and stuff, might be interested in this too.

Thanks, Daniel



> ---
>  drivers/gpu/drm/drm_trace.h  | 14 ++++++++++----
>  drivers/gpu/drm/drm_vblank.c |  3 ++-
>  2 files changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_trace.h b/drivers/gpu/drm/drm_trace.h
> index baccc63db106..45f21d7fcfa1 100644
> --- a/drivers/gpu/drm/drm_trace.h
> +++ b/drivers/gpu/drm/drm_trace.h
> @@ -11,17 +11,23 @@
>  #define TRACE_INCLUDE_FILE drm_trace
>  
>  TRACE_EVENT(drm_vblank_event,
> -	    TP_PROTO(int crtc, unsigned int seq),
> -	    TP_ARGS(crtc, seq),
> +	    TP_PROTO(int crtc, unsigned int seq, ktime_t time, bool high_prec),
> +	    TP_ARGS(crtc, seq, time, high_prec),
>  	    TP_STRUCT__entry(
>  		    __field(int, crtc)
>  		    __field(unsigned int, seq)
> +		    __field(ktime_t, time)
> +		    __field(bool, high_prec)
>  		    ),
>  	    TP_fast_assign(
>  		    __entry->crtc = crtc;
>  		    __entry->seq = seq;
> -		    ),
> -	    TP_printk("crtc=%d, seq=%u", __entry->crtc, __entry->seq)
> +		    __entry->time = time;
> +		    __entry->high_prec = high_prec;
> +			),
> +	    TP_printk("crtc=%d, seq=%u, time=%lld, high-prec=%s",
> +			__entry->crtc, __entry->seq, __entry->time,
> +			__entry->high_prec ? "true" : "false")
>  );
>  
>  TRACE_EVENT(drm_vblank_event_queued,
> diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
> index a1b65d26d761..fb089a88b516 100644
> --- a/drivers/gpu/drm/drm_vblank.c
> +++ b/drivers/gpu/drm/drm_vblank.c
> @@ -1706,7 +1706,8 @@ static void drm_handle_vblank_events(struct drm_device *dev, unsigned int pipe)
>  		send_vblank_event(dev, e, seq, now);
>  	}
>  
> -	trace_drm_vblank_event(pipe, seq);
> +	trace_drm_vblank_event(pipe, seq, now,
> +			dev->driver->get_vblank_timestamp != NULL);
>  }
>  
>  /**
> -- 
> 2.23.0.rc1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


More information about the dri-devel mailing list