[Intel-gfx] [PATCH 15/16] drm/i915: Mechanism to forward clock monotonic time in perf samples

sourab gupta sourab.gupta at intel.com
Mon May 9 05:59:50 UTC 2016


On Sat, 2016-04-23 at 01:19 +0530, Chris Wilson wrote:
> On Fri, Apr 22, 2016 at 05:04:04PM +0530, sourab.gupta at intel.com wrote:
> > +static u64 get_current_gpu_ts(struct drm_i915_private *dev_priv)
> > +{
> > +	return	((u64)I915_READ(GT_TIMESTAMP_COUNT_UDW) << 32) |
> > +		I915_READ(GT_TIMESTAMP_COUNT);
> 
> return I915_READ64_2x32(GT_TIMESTAMP_COUNT, GT_TIMESTAMP_COUNT_UDW);

Thanks for pointing out. Will make this change.

> 
> > +static void i915_perf_get_clock(struct drm_i915_private *dev_priv,
> > +			u64 *clk_mono, u64 *gpu_time, u64 *gpu_ts)
> > +{
> > +	u64 remainder, ts_interval = NSEC_PER_SEC;
> > +	u32 gpu_freq = dev_priv->perf.timestamp_frequency;
> > +	unsigned long flags;
> > +
> > +	local_irq_save(flags);
> > +	*clk_mono = ktime_get_mono_fast_ns();
> > +	*gpu_ts = get_current_gpu_ts(dev_priv);
> > +	local_irq_restore(flags);
> > +
> > +	remainder = do_div(ts_interval, gpu_freq);
> > +	remainder *= *gpu_ts;
> > +	do_div(remainder, gpu_freq);
> > +
> > +	*gpu_time = ((*gpu_ts) * ts_interval) + remainder;
> > +}
> > +
> > +static void i915_perf_clock_sync_work(struct work_struct *work)
> > +{
> 
> Have you looked at cross-timestamps?

I was looking at the cross-timestamp patch set
(https://lkml.org/lkml/2016/1/4/541), but I'm not entirely sure the
cross timestamp stuff is solving the same problem. The cross timestamp
stuff is trying to "synchronously capture system/device timestamp(s)".
While here, we have a log of many recorded device timestamps and want to
correlate all of those with system timestamp (_CLOCK_MONOTONOC for now).
As we aren't reading system/device timestamps together for all
timestamps we have, our problem is more about deriving an accurate idea
of timestamp frequency to improve the accuracy when correlating between
the synchronization points. Maybe the cross timestamp stuff will help to
periodically read tightly correlated timestamp pairs synchronously which
can be used as basis for correlating the logged timestamps based on our
derived timestamp frequency. This idea can be evaluated once the cross
timestamp patches land in kernel.


> -Chris
> 




More information about the Intel-gfx mailing list