util/u_trace: protect against reentrant calls

With the Iris driver, the first tracepoint triggers the tracepoint for
"begin of command buffer" which leads to 2 tracepoints using the same
idx.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14254>
This commit is contained in:
Lionel Landwerlin
2021-12-18 16:48:00 +02:00
committed by Marge Bot
parent 13bdd8da5e
commit 8092d58e2e
+3 -4
View File
@@ -560,6 +560,7 @@ void *
u_trace_append(struct u_trace *ut, void *cs, const struct u_tracepoint *tp)
{
struct u_trace_chunk *chunk = get_chunk(ut, tp->payload_sz);
unsigned tp_idx = chunk->num_traces++;
assert(tp->payload_sz == ALIGN_NPOT(tp->payload_sz, 8));
@@ -571,15 +572,13 @@ u_trace_append(struct u_trace *ut, void *cs, const struct u_tracepoint *tp)
}
/* record a timestamp for the trace: */
ut->utctx->record_timestamp(ut, cs, chunk->timestamps, chunk->num_traces, tp->end_of_pipe);
ut->utctx->record_timestamp(ut, cs, chunk->timestamps, tp_idx, tp->end_of_pipe);
chunk->traces[chunk->num_traces] = (struct u_trace_event) {
chunk->traces[tp_idx] = (struct u_trace_event) {
.tp = tp,
.payload = payload,
};
chunk->num_traces++;
return payload;
}