<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p><br>
    </p>
    <br>
    <div class="moz-cite-prefix">On 12/7/2017 1:32 AM, Lionel Landwerlin
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:314be081-8216-9410-aefd-605d80beaf44@intel.com">I've put
      together some trival IGT tests :
<a class="moz-txt-link-freetext" href="https://github.com/djdeath/intel-gpu-tools/commits/wip/djdeath/cpu-timestamps">https://github.com/djdeath/intel-gpu-tools/commits/wip/djdeath/cpu-timestamps</a><br>
      With a few changes which I pointed in the review :
<a class="moz-txt-link-freetext" href="https://github.com/djdeath/linux/commit/d0e4cf4d3f464491b4ffe97d112284d1ce73656d">https://github.com/djdeath/linux/commit/d0e4cf4d3f464491b4ffe97d112284d1ce73656d</a><br>
      <br>
      Put together it seems to work relatively well.
      <br>
      There is still a small drift happening between the 2 timestamps.
      I've noticed over a 160ms of OA reports, there is a accumulated
      difference of ~35us between the GPU timestamp and cpu timestamps.
      <br>
      I may be doing something wrong with the scaling in the tests, or
      maybe there is an issue in the kernel, or both.
      <br>
    </blockquote>
    Went through the testcase. scaled_gpu_delta calculation is same as
    what timecounter does in kernel for calculating system_time
    corresponding<br>
    to gpu timestamp hence we don't see much of delta between these two
    times/time deltas.<br>
    Ideally we should be testing the system time delta by sampling
    system time and gpu timestamp atomically (which isn't feasible
    unless we do some precise adjustments)<br>
    I have attempted to check these two times/delta by sampling them in
    debugfs and reading over variable periods manually and checking the
    delta.<br>
<a class="moz-txt-link-freetext" href="https://github.com/sakamble/i915-timestamp-support/commit/03be3056752d7b05a02cd01f5c20b3fcfcf18395">https://github.com/sakamble/i915-timestamp-support/commit/03be3056752d7b05a02cd01f5c20b3fcfcf18395</a><br>
    <br>
    It is showing that delta is less than 10us in most cases for 30min
    and occasionally around 20-30us. Again this delta might be because
    of initial time setting as well.<br>
    timecounter initializing system time and gpu clocks as pair should
    be highly accurate for which I have currently taken 350us start
    offset.<br>
    <br>
    I think gpu timestamp clock is highly stable as seen in my testing
    on SKL. I think this clock is used for calculations in GuC too so
    will<br>
    be good to get confirmation about the stability of this clock from
    them and HW team.<br>
    <br>
    <address>   systemd-udevd-169   [001] ....     3.035812:
      i915_driver_load: sys start time: 1512308011156099790</address>
    <address>   systemd-udevd-169   [001] d...     3.036012:
      i915_cyclecounter_read: 52025098974</address>
    <address>             cat-1654  [001] ....    52.407957:
      i915_cyclecounter_read: 52617562292</address>
    <address>             cat-1654  [001] ....    52.407958:
      i915_timestamp_info: sys time: 1512308060527894638</address>
    <address>             cat-1654  [001] ....    52.407958:
      i915_timestamp_info: ts: 52617562292 device time:
      1512308060528043050</address>
    <address>             cat-1684  [001] ....   177.239733:
      i915_cyclecounter_read: 54115543581</address>
    <address>             cat-1684  [001] ....   177.239736:
      i915_timestamp_info: sys time: 1512308185359666602</address>
    <address>             cat-1684  [001] ....   177.239737:
      i915_timestamp_info: ts: 54115543581 device time:
      1512308185359817372</address>
    <address>             cat-1693  [001] ....   329.820374:
      i915_cyclecounter_read: 55946511277</address>
    <address>             cat-1693  [001] ....   329.820377:
      i915_timestamp_info: sys time: 1512308337940301732</address>
    <address>             cat-1693  [001] ....   329.820378:
      i915_timestamp_info: ts: 55946511277 device time:
      1512308337940458996</address>
    <address><br>
      <delta between system time delta and gpu time delta for above
      two samples (177, 329) = 6494ns></address>
    <address><br>
                   cat-1702  [001] ....   506.980313:
      i915_cyclecounter_read: 58072430542</address>
    <address>             cat-1702  [001] ....   506.980315:
      i915_timestamp_info: sys time: 1512308515100233102</address>
    <address>             cat-1702  [001] ....   506.980317:
      i915_timestamp_info: ts: 58072430542 device time:
      1512308515100398084</address>
    <address>             </address>
    <address><delta between system time delta and gpu time delta for
      above two samples (329, 506) = 6494ns></address>
    <blockquote type="cite"
      cite="mid:314be081-8216-9410-aefd-605d80beaf44@intel.com">
      <br>
      I'll build the GPUTop parts and see if the results make sense.
      <br>
      <br>
      Thanks!,
      <br>
      <br>
      -
      <br>
      Lionel
      <br>
      <br>
      On 15/11/17 12:13, Sagar Arun Kamble wrote:
      <br>
      <blockquote type="cite">We can compute system time corresponding
        to GPU timestamp by taking a
        <br>
        reference point (CPU monotonic time, GPU timestamp) and then
        adding
        <br>
        delta time computed using timecounter/cyclecounter support in
        kernel.
        <br>
        We have to configure cyclecounter with the GPU timestamp
        frequency.
        <br>
        Earlier approach that was based on cross-timestamp is not
        needed. It
        <br>
        was being used to approximate the frequency based on invalid
        assumptions
        <br>
        (possibly drift was being seen in the time due to precision
        issue).
        <br>
        The precision of time from GPU clocks is already in ns and
        timecounter
        <br>
        takes care of it as verified over variable durations.
        <br>
        <br>
        This series adds base timecounter/cyclecounter changes and
        changes to
        <br>
        get GPU and CPU timestamps in OA samples.
        <br>
        <br>
        Sagar Arun Kamble (1):
        <br>
           drm/i915/perf: Add support to correlate GPU timestamp with
        system time
        <br>
        <br>
        Sourab Gupta (3):
        <br>
           drm/i915/perf: Add support for collecting 64 bit timestamps
        with OA
        <br>
             reports
        <br>
           drm/i915/perf: Extract raw GPU timestamps from OA reports
        <br>
           drm/i915/perf: Send system clock monotonic time in perf
        samples
        <br>
        <br>
          drivers/gpu/drm/i915/i915_drv.h  |  11 ++++
        <br>
          drivers/gpu/drm/i915/i915_perf.c | 124
        ++++++++++++++++++++++++++++++++++++++-
        <br>
          drivers/gpu/drm/i915/i915_reg.h  |   6 ++
        <br>
          include/uapi/drm/i915_drm.h      |  14 +++++
        <br>
          4 files changed, 154 insertions(+), 1 deletion(-)
        <br>
        <br>
      </blockquote>
      <br>
    </blockquote>
    <br>
  </body>
</html>