<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 10/29/2024 10:43 PM, Lucas De Marchi
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:20241029214351.776293-2-lucas.demarchi@intel.com">
      <pre wrap="" class="moz-quote-pre">Help debugging when LRC timestamp is updated for a exec queue.

Reviewed-by: Jonathan Cavitt <a class="moz-txt-link-rfc2396E" href="mailto:jonathan.cavitt@intel.com"><jonathan.cavitt@intel.com></a>
Signed-off-by: Lucas De Marchi <a class="moz-txt-link-rfc2396E" href="mailto:lucas.demarchi@intel.com"><lucas.demarchi@intel.com></a></pre>
    </blockquote>
    <span style="padding: 0px; tab-size: 8; white-space: pre-wrap;"
    class="hljs diff colorediffs language-diff">
Reviewed-by: Nirmoy Das </span><a class="moz-txt-link-rfc2396E"
    href="mailto:nirmoy.das@intel.com" style="white-space: pre-wrap;"><nirmoy.das@intel.com></a><span
    style="padding: 0px; tab-size: 8; white-space: pre-wrap;"
    class="hljs diff colorediffs language-diff"></span>
    <blockquote type="cite"
      cite="mid:20241029214351.776293-2-lucas.demarchi@intel.com">
      <pre wrap="" class="moz-quote-pre">
---
 drivers/gpu/drm/xe/Makefile       |  1 +
 drivers/gpu/drm/xe/xe_lrc.c       |  3 ++
 drivers/gpu/drm/xe/xe_trace_lrc.c |  9 ++++++
 drivers/gpu/drm/xe/xe_trace_lrc.h | 52 +++++++++++++++++++++++++++++++
 4 files changed, 65 insertions(+)
 create mode 100644 drivers/gpu/drm/xe/xe_trace_lrc.c
 create mode 100644 drivers/gpu/drm/xe/xe_trace_lrc.h

diff --git a/drivers/gpu/drm/xe/Makefile b/drivers/gpu/drm/xe/Makefile
index bc7a04ce69fd0..21d69935c3365 100644
--- a/drivers/gpu/drm/xe/Makefile
+++ b/drivers/gpu/drm/xe/Makefile
@@ -101,6 +101,7 @@ xe-y += xe_bb.o \
        xe_trace.o \
        xe_trace_bo.o \
        xe_trace_guc.o \
+       xe_trace_lrc.o \
        xe_ttm_sys_mgr.o \
        xe_ttm_stolen_mgr.o \
        xe_ttm_vram_mgr.o \
diff --git a/drivers/gpu/drm/xe/xe_lrc.c b/drivers/gpu/drm/xe/xe_lrc.c
index 4f64c7f4e68de..4b65da77c6e09 100644
--- a/drivers/gpu/drm/xe/xe_lrc.c
+++ b/drivers/gpu/drm/xe/xe_lrc.c
@@ -25,6 +25,7 @@
 #include "xe_map.h"
 #include "xe_memirq.h"
 #include "xe_sriov.h"
+#include "xe_trace_lrc.h"
 #include "xe_vm.h"
 #include "xe_wa.h"
 
@@ -1758,5 +1759,7 @@ u32 xe_lrc_update_timestamp(struct xe_lrc *lrc, u32 *old_ts)
 
        lrc->ctx_timestamp = xe_lrc_ctx_timestamp(lrc);
 
+       trace_xe_lrc_update_timestamp(lrc, *old_ts);
+
        return lrc->ctx_timestamp;
 }
diff --git a/drivers/gpu/drm/xe/xe_trace_lrc.c b/drivers/gpu/drm/xe/xe_trace_lrc.c
new file mode 100644
index 0000000000000..ab9b7e2970bc2
--- /dev/null
+++ b/drivers/gpu/drm/xe/xe_trace_lrc.c
@@ -0,0 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright Â© 2024 Intel Corporation
+ */
+
+#ifndef __CHECKER__
+#define CREATE_TRACE_POINTS
+#include "xe_trace_lrc.h"
+#endif
diff --git a/drivers/gpu/drm/xe/xe_trace_lrc.h b/drivers/gpu/drm/xe/xe_trace_lrc.h
new file mode 100644
index 0000000000000..5c669a0b21808
--- /dev/null
+++ b/drivers/gpu/drm/xe/xe_trace_lrc.h
@@ -0,0 +1,52 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright Â© 2024 Intel Corporation
+ */
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM xe
+
+#if !defined(_XE_TRACE_LRC_H_) || defined(TRACE_HEADER_MULTI_READ)
+#define _XE_TRACE_LRC_H_
+
+#include <linux/tracepoint.h>
+#include <linux/types.h>
+
+#include "xe_gt_types.h"
+#include "xe_lrc.h"
+#include "xe_lrc_types.h"
+
+#define __dev_name_lrc(lrc)    dev_name(gt_to_xe((lrc)->fence_ctx.gt)->drm.dev)
+
+TRACE_EVENT(xe_lrc_update_timestamp,
+           TP_PROTO(struct xe_lrc *lrc, uint32_t old),
+           TP_ARGS(lrc, old),
+           TP_STRUCT__entry(
+                    __field(struct xe_lrc *, lrc)
+                    __field(u32, old)
+                    __field(u32, new)
+                    __string(name, lrc->fence_ctx.name)
+                    __string(device_id, __dev_name_lrc(lrc))
+           ),
+
+           TP_fast_assign(
+                  __entry->lrc      = lrc;
+                  __entry->old = old;
+                  __entry->new = lrc->ctx_timestamp;
+                  __assign_str(name);
+                  __assign_str(device_id);
+                  ),
+           TP_printk("lrc=:%p lrc->name=%s old=%u new=%u device_id:%s",
+                     __entry->lrc, __get_str(name),
+                     __entry->old, __entry->new,
+                     __get_str(device_id))
+);
+
+#endif
+
+/* This part must be outside protection */
+#undef TRACE_INCLUDE_PATH
+#undef TRACE_INCLUDE_FILE
+#define TRACE_INCLUDE_PATH ../../drivers/gpu/drm/xe
+#define TRACE_INCLUDE_FILE xe_trace_lrc
+#include <trace/define_trace.h>
</pre>
    </blockquote>
  </body>
</html>