From 0442803eee764857f04758e3742d18a917ed50e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Roberto=20de=20Souza?= Date: Wed, 15 May 2024 11:05:17 -0700 Subject: [PATCH] intel/perf: Fix return of read_oa_samples_until() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit read_oa_samples_until() was returning OA_READ_STATUS_ERROR even if already read samples, then it tried again and KMD returned 0/empty or EAGAIN(as the read would block). This is not causing any issue because read_oa_samples_for_query() FALLTHROUGH OA_READ_STATUS_ERROR to OA_READ_STATUS_FINISHED but that I think it is worthy to fix it. Reviewed-by: Lionel Landwerlin Signed-off-by: José Roberto de Souza Part-of: --- src/intel/perf/intel_perf_query.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/intel/perf/intel_perf_query.c b/src/intel/perf/intel_perf_query.c index 5b094fd8519..eb5f999362a 100644 --- a/src/intel/perf/intel_perf_query.c +++ b/src/intel/perf/intel_perf_query.c @@ -964,6 +964,7 @@ read_oa_samples_until(struct intel_perf_context *perf_ctx, exec_node_data(struct oa_sample_buf, tail_node, link); uint32_t last_timestamp = tail_buf->len == 0 ? start_timestamp : tail_buf->last_timestamp; + bool sample_read = false; while (1) { struct oa_sample_buf *buf = get_free_sample_buf(perf_ctx); @@ -978,11 +979,17 @@ read_oa_samples_until(struct intel_perf_context *perf_ctx, exec_list_push_tail(&perf_ctx->free_sample_buffers, &buf->link); if (len == 0) { + if (sample_read) + return OA_READ_STATUS_FINISHED; + DBG("Spurious EOF reading i915 perf samples\n"); return OA_READ_STATUS_ERROR; } if (errno != EAGAIN) { + if (sample_read) + return OA_READ_STATUS_FINISHED; + DBG("Error reading i915 perf samples: %m\n"); return OA_READ_STATUS_ERROR; } @@ -1011,6 +1018,7 @@ read_oa_samples_until(struct intel_perf_context *perf_ctx, last_timestamp = report[1]; offset += header->size; + sample_read = true; } buf->last_timestamp = last_timestamp;