intel/perf: take into account that reports read can be fairly old
[mesa.git] / src / intel / perf / gen_perf.c
index 05103acfb217cb1e217232845b9b0bb35710b6b1..be7de571ff12899e4fd2d3700e336ad54edfad62 100644 (file)
@@ -1999,12 +1999,13 @@ read_oa_samples_until(struct gen_perf_context *perf_ctx,
          exec_list_push_tail(&perf_ctx->free_sample_buffers, &buf->link);
 
          if (len < 0) {
-            if (errno == EAGAIN)
-               return ((last_timestamp - start_timestamp) >=
+            if (errno == EAGAIN) {
+               return ((last_timestamp - start_timestamp) < INT32_MAX &&
+                       (last_timestamp - start_timestamp) >=
                        (end_timestamp - start_timestamp)) ?
                       OA_READ_STATUS_FINISHED :
                       OA_READ_STATUS_UNFINISHED;
-            else {
+            else {
                DBG("Error reading i915 perf samples: %m\n");
             }
          } else