Module: Mesa
Branch: main
Commit: 23f3aa34919f86d8011184eeb8ef6bc3a3393e0c
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=23f3aa34919f86d8011184eeb8ef6bc3a3393e0c

Author: Samuel Pitoiset <[email protected]>
Date:   Thu Apr 20 11:42:40 2023 +0200

ac/sqtt: add a helper for adding clock calibration records

Signed-off-by: Samuel Pitoiset <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22594>

---

 src/amd/common/ac_sqtt.c | 22 ++++++++++++++++++++++
 src/amd/common/ac_sqtt.h |  4 ++++
 2 files changed, 26 insertions(+)

diff --git a/src/amd/common/ac_sqtt.c b/src/amd/common/ac_sqtt.c
index e8e04480841..a80b268b58d 100644
--- a/src/amd/common/ac_sqtt.c
+++ b/src/amd/common/ac_sqtt.c
@@ -149,6 +149,28 @@ ac_sqtt_add_code_object_loader_event(struct 
ac_thread_trace_data *thread_trace_d
    return true;
 }
 
+bool
+ac_sqtt_add_clock_calibration(struct ac_thread_trace_data *thread_trace_data,
+                              uint64_t cpu_timestamp, uint64_t gpu_timestamp)
+{
+   struct rgp_clock_calibration *clock_calibration = 
&thread_trace_data->rgp_clock_calibration;
+   struct rgp_clock_calibration_record *record;
+
+   record = malloc(sizeof(struct rgp_clock_calibration_record));
+   if (!record)
+      return false;
+
+   record->cpu_timestamp = cpu_timestamp;
+   record->gpu_timestamp = gpu_timestamp;
+
+   simple_mtx_lock(&clock_calibration->lock);
+   list_addtail(&record->list, &clock_calibration->record);
+   clock_calibration->record_count++;
+   simple_mtx_unlock(&clock_calibration->lock);
+
+   return true;
+}
+
 /* See https://gitlab.freedesktop.org/mesa/mesa/-/issues/5260
  * On some HW SQTT can hang if we're not in one of the profiling pstates. */
 bool
diff --git a/src/amd/common/ac_sqtt.h b/src/amd/common/ac_sqtt.h
index 0b14eab965d..364d0144e0f 100644
--- a/src/amd/common/ac_sqtt.h
+++ b/src/amd/common/ac_sqtt.h
@@ -540,6 +540,10 @@ bool ac_sqtt_add_code_object_loader_event(struct 
ac_thread_trace_data *thread_tr
                                           uint64_t pipeline_hash,
                                           uint64_t base_address);
 
+bool ac_sqtt_add_clock_calibration(struct ac_thread_trace_data 
*thread_trace_data,
+                                   uint64_t cpu_timestamp,
+                                   uint64_t gpu_timestamp);
+
 bool ac_check_profile_state(const struct radeon_info *info);
 
 union rgp_sqtt_marker_cb_id ac_sqtt_get_next_cmdbuf_id(struct 
ac_thread_trace_data *data,

Reply via email to