intel/perf: streamline error handling in read_oa_samples_until
authorMarcin Ślusarz <marcin.slusarz@intel.com>
Fri, 10 Jul 2020 14:24:31 +0000 (16:24 +0200)
committerMarge Bot <eric+marge@anholt.net>
Mon, 10 Aug 2020 13:41:29 +0000 (13:41 +0000)
No functional changes.

Signed-off-by: Marcin Ślusarz <marcin.slusarz@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5788>

src/intel/perf/gen_perf_query.c

index 3d4f922b2b3c7b2e33847b6715df9e4cd4653a76..309ebe024d308f8a3acbf261de681a4cbcb924d1 100644 (file)
@@ -938,20 +938,24 @@ read_oa_samples_until(struct gen_perf_context *perf_ctx,
       if (len <= 0) {
          exec_list_push_tail(&perf_ctx->free_sample_buffers, &buf->link);
 
-         if (len < 0) {
-            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 {
-               DBG("Error reading i915 perf samples: %m\n");
-            }
-         } else
+         if (len == 0) {
             DBG("Spurious EOF reading i915 perf samples\n");
+            return OA_READ_STATUS_ERROR;
+         }
+
+         if (errno != EAGAIN) {
+            DBG("Error reading i915 perf samples: %m\n");
+            return OA_READ_STATUS_ERROR;
+         }
+
+         if ((last_timestamp - start_timestamp) >= INT32_MAX)
+            return OA_READ_STATUS_UNFINISHED;
+
+         if ((last_timestamp - start_timestamp) <
+              (end_timestamp - start_timestamp))
+            return OA_READ_STATUS_UNFINISHED;
 
-         return OA_READ_STATUS_ERROR;
+         return OA_READ_STATUS_FINISHED;
       }
 
       buf->len = len;