freedreno: Avoid flushing deferred submits for u_trace
authorRob Clark <robdclark@chromium.org>
Sat, 17 Apr 2021 19:56:58 +0000 (12:56 -0700)
committerMarge Bot <eric+marge@anholt.net>
Wed, 28 Apr 2021 15:36:42 +0000 (15:36 +0000)
This is a bit ugly, but with userspace fences and deferred submits it is
better to poll until the timestamp buffer is ready.  Otherwise we could
be triggering deferred submits to flush sooner than they normally would,
changing the behavior of what we are trying to measure.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10444>

src/gallium/drivers/freedreno/freedreno_context.c

index 0c212ed..1fa4435 100644 (file)
@@ -477,6 +477,11 @@ fd_trace_read_ts(struct u_trace_context *utctx,
 
    /* Only need to stall on results for the first entry: */
    if (idx == 0) {
+      /* Avoid triggering deferred submits from flushing, since that
+       * changes the behavior of what we are trying to measure:
+       */
+      while (fd_bo_cpu_prep(ts_bo, ctx->pipe, FD_BO_PREP_NOSYNC))
+         usleep(10000);
       int ret = fd_bo_cpu_prep(ts_bo, ctx->pipe, FD_BO_PREP_READ);
       if (ret)
          return U_TRACE_NO_TIMESTAMP;