intel/perf: Fix return of read_oa_samples_until()

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 <lionel.g.landwerlin@intel.com>
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29421>
This commit is contained in:
José Roberto de Souza
2024-05-15 11:05:17 -07:00
committed by Marge Bot
parent 42ee8d80d9
commit 0442803eee

View File

@@ -964,6 +964,7 @@ read_oa_samples_until(struct intel_perf_context *perf_ctx,
exec_node_data(struct oa_sample_buf, tail_node, link); exec_node_data(struct oa_sample_buf, tail_node, link);
uint32_t last_timestamp = uint32_t last_timestamp =
tail_buf->len == 0 ? start_timestamp : tail_buf->last_timestamp; tail_buf->len == 0 ? start_timestamp : tail_buf->last_timestamp;
bool sample_read = false;
while (1) { while (1) {
struct oa_sample_buf *buf = get_free_sample_buf(perf_ctx); 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); exec_list_push_tail(&perf_ctx->free_sample_buffers, &buf->link);
if (len == 0) { if (len == 0) {
if (sample_read)
return OA_READ_STATUS_FINISHED;
DBG("Spurious EOF reading i915 perf samples\n"); DBG("Spurious EOF reading i915 perf samples\n");
return OA_READ_STATUS_ERROR; return OA_READ_STATUS_ERROR;
} }
if (errno != EAGAIN) { if (errno != EAGAIN) {
if (sample_read)
return OA_READ_STATUS_FINISHED;
DBG("Error reading i915 perf samples: %m\n"); DBG("Error reading i915 perf samples: %m\n");
return OA_READ_STATUS_ERROR; return OA_READ_STATUS_ERROR;
} }
@@ -1011,6 +1018,7 @@ read_oa_samples_until(struct intel_perf_context *perf_ctx,
last_timestamp = report[1]; last_timestamp = report[1];
offset += header->size; offset += header->size;
sample_read = true;
} }
buf->last_timestamp = last_timestamp; buf->last_timestamp = last_timestamp;