From 7689aca21f2e91cb2628c0bb3ac3479844b54b1c Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Wed, 17 Sep 2025 21:39:23 -0700 Subject: [PATCH] intel/ds: simplify clock sync emit In short, perfetto doesn't require the initial clock snapshot to be earlier than the timestamp to be converted. So we don't have to do complex handling for it. With this change: - renderstage event requires clock sync, so we'd only emit clock snapshots on the traceq thread that handles the callbacks - drops redundant sync_timestamp calls as well as sync_gpu_ts tracking - no need to reset next_clock_sync_ns when tracing is disabled, since a snapshot is always emitted right after the initial interned data emit upon tracing start Reviewed-by: Lionel Landwerlin Part-of: --- src/intel/ds/intel_driver_ds.cc | 24 +----------------------- src/intel/ds/intel_driver_ds.h | 8 -------- 2 files changed, 1 insertion(+), 31 deletions(-) diff --git a/src/intel/ds/intel_driver_ds.cc b/src/intel/ds/intel_driver_ds.cc index 020642a2335..c839ed952c7 100644 --- a/src/intel/ds/intel_driver_ds.cc +++ b/src/intel/ds/intel_driver_ds.cc @@ -147,7 +147,6 @@ sync_timestamp(IntelRenderpassDataSource::TraceContext &ctx, PERFETTO_LOG("sending clocks gpu=0x%08x", device->gpu_clock_id); - device->sync_gpu_ts = gpu_ts; device->next_clock_sync_ns = boottime + 1000000000ull; MesaRenderpassDataSource::EmitClockSync(ctx, @@ -231,7 +230,6 @@ setup_incremental_state(IntelRenderpassDataSource::TraceContext &ctx, } device->next_clock_sync_ns = 0; - sync_timestamp(ctx, device); } static void @@ -239,14 +237,6 @@ begin_event(struct intel_ds_queue *queue, uint64_t ts_ns, enum intel_ds_queue_stage stage_id) { uint32_t level = queue->stages[stage_id].level; - /* If we haven't managed to calibrate the alignment between GPU and CPU - * timestamps yet, then skip this trace, otherwise perfetto won't know - * what to do with it. - */ - if (!queue->device->sync_gpu_ts) { - queue->stages[stage_id].start_ns[level] = 0; - return; - } if (level >= (ARRAY_SIZE(queue->stages[stage_id].start_ns) - 1)) return; @@ -267,13 +257,6 @@ end_event(struct intel_ds_queue *queue, uint64_t ts_ns, { struct intel_ds_device *device = queue->device; - /* If we haven't managed to calibrate the alignment between GPU and CPU - * timestamps yet, then skip this trace, otherwise perfetto won't know - * what to do with it. - */ - if (!device->sync_gpu_ts) - return; - if (queue->stages[stage_id].level == 0) return; @@ -540,18 +523,13 @@ void intel_ds_end_submit(struct intel_ds_queue *queue, uint64_t start_ts) { - if (!u_trace_should_process(&queue->device->trace_context)) { - queue->device->sync_gpu_ts = 0; - queue->device->next_clock_sync_ns = 0; + if (!u_trace_should_process(&queue->device->trace_context)) return; - } uint64_t end_ts = perfetto::base::GetBootTimeNs().count(); uint32_t submission_id = queue->submission_id++; IntelRenderpassDataSource::Trace([=](IntelRenderpassDataSource::TraceContext tctx) { - sync_timestamp(tctx, queue->device); - auto packet = tctx.NewTracePacket(); packet->set_timestamp(start_ts); diff --git a/src/intel/ds/intel_driver_ds.h b/src/intel/ds/intel_driver_ds.h index 910d0d781b5..18d78c99176 100644 --- a/src/intel/ds/intel_driver_ds.h +++ b/src/intel/ds/intel_driver_ds.h @@ -116,14 +116,6 @@ struct intel_ds_device { /* Clock identifier for this device. */ uint32_t gpu_clock_id; - /* The timestamp at the point where we first emitted the clock_sync.. - * this will be a *later* timestamp that the first GPU traces (since - * we capture the first clock_sync from the CPU *after* the first GPU - * tracepoints happen). To avoid confusing perfetto we need to drop - * the GPU traces with timestamps before this. - */ - uint64_t sync_gpu_ts; - /* Next timestamp after which we should resend a clock correlation. */ uint64_t next_clock_sync_ns;