Mesa (master): intel/perf: streamline error handling in read_oa_samples_until

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Aug 10 14:00:43 UTC 2020


Module: Mesa
Branch: master
Commit: 9fa64803aadebf8663469832eb90b6a7fe572494
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9fa64803aadebf8663469832eb90b6a7fe572494

Author: Marcin Ślusarz <marcin.slusarz at intel.com>
Date:   Fri Jul 10 16:24:31 2020 +0200

intel/perf: streamline error handling in read_oa_samples_until

No functional changes.

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

---

 src/intel/perf/gen_perf_query.c | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/src/intel/perf/gen_perf_query.c b/src/intel/perf/gen_perf_query.c
index 3d4f922b2b3..309ebe024d3 100644
--- a/src/intel/perf/gen_perf_query.c
+++ b/src/intel/perf/gen_perf_query.c
@@ -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;



More information about the mesa-commit mailing list