All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/xe: Add reg read/write trace
@ 2024-04-18 22:22 Radhakrishna Sripada
  2024-04-18 23:44 ` ✓ CI.Patch_applied: success for " Patchwork
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Radhakrishna Sripada @ 2024-04-18 22:22 UTC (permalink / raw)
  To: intel-xe; +Cc: Radhakrishna Sripada

This will help debug register read/writes and provides
a way to trace all the mmio transactions.

Signed-off-by: Radhakrishna Sripada <radhakrishna.sripada@intel.com>
---
 drivers/gpu/drm/xe/xe_mmio.c  | 20 +++++++++++++++++---
 drivers/gpu/drm/xe/xe_trace.h | 28 ++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_mmio.c b/drivers/gpu/drm/xe/xe_mmio.c
index 334637511e75..659c19d4f0a6 100644
--- a/drivers/gpu/drm/xe/xe_mmio.c
+++ b/drivers/gpu/drm/xe/xe_mmio.c
@@ -22,6 +22,7 @@
 #include "xe_module.h"
 #include "xe_sriov.h"
 #include "xe_tile.h"
+#include "xe_trace.h"
 
 #define XEHP_MTCFG_ADDR		XE_REG(0x101800)
 #define TILE_COUNT		REG_GENMASK(15, 8)
@@ -423,21 +424,29 @@ int xe_mmio_init(struct xe_device *xe)
 u8 xe_mmio_read8(struct xe_gt *gt, struct xe_reg reg)
 {
 	struct xe_tile *tile = gt_to_tile(gt);
+	u8 val;
 
 	if (reg.addr < gt->mmio.adj_limit)
 		reg.addr += gt->mmio.adj_offset;
 
-	return readb((reg.ext ? tile->mmio_ext.regs : tile->mmio.regs) + reg.addr);
+	val = readb((reg.ext ? tile->mmio_ext.regs : tile->mmio.regs) + reg.addr);
+	trace_xe_reg_rw(false, reg, val, sizeof(val), true);
+
+	return val;
 }
 
 u16 xe_mmio_read16(struct xe_gt *gt, struct xe_reg reg)
 {
 	struct xe_tile *tile = gt_to_tile(gt);
+	u16 val;
 
 	if (reg.addr < gt->mmio.adj_limit)
 		reg.addr += gt->mmio.adj_offset;
 
-	return readw((reg.ext ? tile->mmio_ext.regs : tile->mmio.regs) + reg.addr);
+	val = readw((reg.ext ? tile->mmio_ext.regs : tile->mmio.regs) + reg.addr);
+	trace_xe_reg_rw(false, reg, val, sizeof(val), true);
+
+	return val;
 }
 
 void xe_mmio_write32(struct xe_gt *gt, struct xe_reg reg, u32 val)
@@ -447,17 +456,22 @@ void xe_mmio_write32(struct xe_gt *gt, struct xe_reg reg, u32 val)
 	if (reg.addr < gt->mmio.adj_limit)
 		reg.addr += gt->mmio.adj_offset;
 
+	trace_xe_reg_rw(true, reg, val, sizeof(val), true);
 	writel(val, (reg.ext ? tile->mmio_ext.regs : tile->mmio.regs) + reg.addr);
 }
 
 u32 xe_mmio_read32(struct xe_gt *gt, struct xe_reg reg)
 {
 	struct xe_tile *tile = gt_to_tile(gt);
+	u32 val;
 
 	if (reg.addr < gt->mmio.adj_limit)
 		reg.addr += gt->mmio.adj_offset;
 
-	return readl((reg.ext ? tile->mmio_ext.regs : tile->mmio.regs) + reg.addr);
+	val = readl((reg.ext ? tile->mmio_ext.regs : tile->mmio.regs) + reg.addr);
+	trace_xe_reg_rw(false, reg, val, sizeof(val), true);
+
+	return val;
 }
 
 u32 xe_mmio_rmw32(struct xe_gt *gt, struct xe_reg reg, u32 clr, u32 set)
diff --git a/drivers/gpu/drm/xe/xe_trace.h b/drivers/gpu/drm/xe/xe_trace.h
index 2d56cfc09e42..41d778dd43c6 100644
--- a/drivers/gpu/drm/xe/xe_trace.h
+++ b/drivers/gpu/drm/xe/xe_trace.h
@@ -621,6 +621,34 @@ DEFINE_EVENT_PRINT(xe_guc_ctb, xe_guc_ctb_g2h,
 
 );
 
+TRACE_EVENT_CONDITION(xe_reg_rw,
+	TP_PROTO(bool write, u32 reg, u64 val, int len, bool trace),
+
+	TP_ARGS(write, reg, val, len, trace),
+
+	TP_CONDITION(trace),
+
+	TP_STRUCT__entry(
+		__field(u64, val)
+		__field(u32, reg)
+		__field(u16, write)
+		__field(u16, len)
+		),
+
+	TP_fast_assign(
+		__entry->val = (u64)val;
+		__entry->reg = reg;
+		__entry->write = write;
+		__entry->len = len;
+		),
+
+	TP_printk("%s reg=0x%x, len=%d, val=(0x%x, 0x%x)",
+		__entry->write ? "write" : "read",
+		__entry->reg, __entry->len,
+		(u32)(__entry->val & 0xffffffff),
+		(u32)(__entry->val >> 32))
+);
+
 #endif
 
 /* This part must be outside protection */
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* ✓ CI.Patch_applied: success for drm/xe: Add reg read/write trace
  2024-04-18 22:22 [PATCH] drm/xe: Add reg read/write trace Radhakrishna Sripada
@ 2024-04-18 23:44 ` Patchwork
  2024-04-18 23:44 ` ✗ CI.checkpatch: warning " Patchwork
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Patchwork @ 2024-04-18 23:44 UTC (permalink / raw)
  To: Radhakrishna Sripada; +Cc: intel-xe

== Series Details ==

Series: drm/xe: Add reg read/write trace
URL   : https://patchwork.freedesktop.org/series/132626/
State : success

== Summary ==

=== Applying kernel patches on branch 'drm-tip' with base: ===
Base commit: cabe88f47c1f drm-tip: 2024y-04m-18d-20h-31m-50s UTC integration manifest
=== git am output follows ===
Applying: drm/xe: Add reg read/write trace



^ permalink raw reply	[flat|nested] 8+ messages in thread

* ✗ CI.checkpatch: warning for drm/xe: Add reg read/write trace
  2024-04-18 22:22 [PATCH] drm/xe: Add reg read/write trace Radhakrishna Sripada
  2024-04-18 23:44 ` ✓ CI.Patch_applied: success for " Patchwork
@ 2024-04-18 23:44 ` Patchwork
  2024-04-18 23:45 ` ✗ CI.KUnit: failure " Patchwork
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Patchwork @ 2024-04-18 23:44 UTC (permalink / raw)
  To: Radhakrishna Sripada; +Cc: intel-xe

== Series Details ==

Series: drm/xe: Add reg read/write trace
URL   : https://patchwork.freedesktop.org/series/132626/
State : warning

== Summary ==

+ KERNEL=/kernel
+ git clone https://gitlab.freedesktop.org/drm/maintainer-tools mt
Cloning into 'mt'...
warning: redirecting to https://gitlab.freedesktop.org/drm/maintainer-tools.git/
+ git -C mt rev-list -n1 origin/master
0daf0be5bb95eb0a0e42275e00a0e42d8d8fd543
+ cd /kernel
+ git config --global --add safe.directory /kernel
+ git log -n1
commit 9858e33a836f10c429b48c683275ac187251a748
Author: Radhakrishna Sripada <radhakrishna.sripada@intel.com>
Date:   Thu Apr 18 15:22:43 2024 -0700

    drm/xe: Add reg read/write trace
    
    This will help debug register read/writes and provides
    a way to trace all the mmio transactions.
    
    Signed-off-by: Radhakrishna Sripada <radhakrishna.sripada@intel.com>
+ /mt/dim checkpatch cabe88f47c1f688f4493de88acc532bf584efe3c drm-intel
9858e33a836f drm/xe: Add reg read/write trace
-:88: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis
#88: FILE: drivers/gpu/drm/xe/xe_trace.h:625:
+TRACE_EVENT_CONDITION(xe_reg_rw,
+	TP_PROTO(bool write, u32 reg, u64 val, int len, bool trace),

-:94: CHECK:OPEN_ENDED_LINE: Lines should not end with a '('
#94: FILE: drivers/gpu/drm/xe/xe_trace.h:631:
+	TP_STRUCT__entry(

-:101: CHECK:OPEN_ENDED_LINE: Lines should not end with a '('
#101: FILE: drivers/gpu/drm/xe/xe_trace.h:638:
+	TP_fast_assign(

-:109: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis
#109: FILE: drivers/gpu/drm/xe/xe_trace.h:646:
+	TP_printk("%s reg=0x%x, len=%d, val=(0x%x, 0x%x)",
+		__entry->write ? "write" : "read",

total: 0 errors, 0 warnings, 4 checks, 95 lines checked



^ permalink raw reply	[flat|nested] 8+ messages in thread

* ✗ CI.KUnit: failure for drm/xe: Add reg read/write trace
  2024-04-18 22:22 [PATCH] drm/xe: Add reg read/write trace Radhakrishna Sripada
  2024-04-18 23:44 ` ✓ CI.Patch_applied: success for " Patchwork
  2024-04-18 23:44 ` ✗ CI.checkpatch: warning " Patchwork
@ 2024-04-18 23:45 ` Patchwork
  2024-04-19 11:46 ` [PATCH] " Jani Nikula
  2024-04-19 16:37 ` Ville Syrjälä
  4 siblings, 0 replies; 8+ messages in thread
From: Patchwork @ 2024-04-18 23:45 UTC (permalink / raw)
  To: Radhakrishna Sripada; +Cc: intel-xe

== Series Details ==

Series: drm/xe: Add reg read/write trace
URL   : https://patchwork.freedesktop.org/series/132626/
State : failure

== Summary ==

+ trap cleanup EXIT
+ /kernel/tools/testing/kunit/kunit.py run --kunitconfig /kernel/drivers/gpu/drm/xe/.kunitconfig
ERROR:root:../arch/x86/um/user-offsets.c:17:6: warning: no previous prototype for ‘foo’ [-Wmissing-prototypes]
   17 | void foo(void)
      |      ^~~
In file included from ../arch/um/kernel/asm-offsets.c:1:
../arch/x86/um/shared/sysdep/kernel-offsets.h:9:6: warning: no previous prototype for ‘foo’ [-Wmissing-prototypes]
    9 | void foo(void)
      |      ^~~
../arch/x86/um/fault.c:18:5: warning: no previous prototype for ‘arch_fixup’ [-Wmissing-prototypes]
   18 | int arch_fixup(unsigned long address, struct uml_pt_regs *regs)
      |     ^~~~~~~~~~
../arch/x86/um/bugs_64.c:9:6: warning: no previous prototype for ‘arch_check_bugs’ [-Wmissing-prototypes]
    9 | void arch_check_bugs(void)
      |      ^~~~~~~~~~~~~~~
../arch/x86/um/bugs_64.c:13:6: warning: no previous prototype for ‘arch_examine_signal’ [-Wmissing-prototypes]
   13 | void arch_examine_signal(int sig, struct uml_pt_regs *regs)
      |      ^~~~~~~~~~~~~~~~~~~
../arch/x86/um/os-Linux/mcontext.c:7:6: warning: no previous prototype for ‘get_regs_from_mc’ [-Wmissing-prototypes]
    7 | void get_regs_from_mc(struct uml_pt_regs *regs, mcontext_t *mc)
      |      ^~~~~~~~~~~~~~~~
../arch/x86/um/os-Linux/registers.c:146:15: warning: no previous prototype for ‘get_thread_reg’ [-Wmissing-prototypes]
  146 | unsigned long get_thread_reg(int reg, jmp_buf *buf)
      |               ^~~~~~~~~~~~~~
../arch/x86/um/vdso/um_vdso.c:16:5: warning: no previous prototype for ‘__vdso_clock_gettime’ [-Wmissing-prototypes]
   16 | int __vdso_clock_gettime(clockid_t clock, struct __kernel_old_timespec *ts)
      |     ^~~~~~~~~~~~~~~~~~~~
../arch/x86/um/vdso/um_vdso.c:30:5: warning: no previous prototype for ‘__vdso_gettimeofday’ [-Wmissing-prototypes]
   30 | int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz)
      |     ^~~~~~~~~~~~~~~~~~~
../arch/x86/um/vdso/um_vdso.c:44:21: warning: no previous prototype for ‘__vdso_time’ [-Wmissing-prototypes]
   44 | __kernel_old_time_t __vdso_time(__kernel_old_time_t *t)
      |                     ^~~~~~~~~~~
../arch/x86/um/vdso/um_vdso.c:57:1: warning: no previous prototype for ‘__vdso_getcpu’ [-Wmissing-prototypes]
   57 | __vdso_getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *unused)
      | ^~~~~~~~~~~~~
../arch/um/os-Linux/skas/process.c:107:6: warning: no previous prototype for ‘wait_stub_done’ [-Wmissing-prototypes]
  107 | void wait_stub_done(int pid)
      |      ^~~~~~~~~~~~~~
../arch/um/os-Linux/skas/process.c:683:6: warning: no previous prototype for ‘__switch_mm’ [-Wmissing-prototypes]
  683 | void __switch_mm(struct mm_id *mm_idp)
      |      ^~~~~~~~~~~
../arch/x86/um/ptrace_64.c:111:5: warning: no previous prototype for ‘poke_user’ [-Wmissing-prototypes]
  111 | int poke_user(struct task_struct *child, long addr, long data)
      |     ^~~~~~~~~
../arch/x86/um/ptrace_64.c:171:5: warning: no previous prototype for ‘peek_user’ [-Wmissing-prototypes]
  171 | int peek_user(struct task_struct *child, long addr, long data)
      |     ^~~~~~~~~
../arch/um/kernel/skas/mmu.c:17:5: warning: no previous prototype for ‘init_new_context’ [-Wmissing-prototypes]
   17 | int init_new_context(struct task_struct *task, struct mm_struct *mm)
      |     ^~~~~~~~~~~~~~~~
../arch/um/kernel/skas/mmu.c:60:6: warning: no previous prototype for ‘destroy_context’ [-Wmissing-prototypes]
   60 | void destroy_context(struct mm_struct *mm)
      |      ^~~~~~~~~~~~~~~
../arch/x86/um/signal.c:560:6: warning: no previous prototype for ‘sys_rt_sigreturn’ [-Wmissing-prototypes]
  560 | long sys_rt_sigreturn(void)
      |      ^~~~~~~~~~~~~~~~
../arch/um/kernel/skas/process.c:36:12: warning: no previous prototype for ‘start_uml’ [-Wmissing-prototypes]
   36 | int __init start_uml(void)
      |            ^~~~~~~~~
../arch/um/os-Linux/main.c:187:7: warning: no previous prototype for ‘__wrap_malloc’ [-Wmissing-prototypes]
  187 | void *__wrap_malloc(int size)
      |       ^~~~~~~~~~~~~
../arch/um/os-Linux/main.c:208:7: warning: no previous prototype for ‘__wrap_calloc’ [-Wmissing-prototypes]
  208 | void *__wrap_calloc(int n, int size)
      |       ^~~~~~~~~~~~~
../arch/um/os-Linux/main.c:222:6: warning: no previous prototype for ‘__wrap_free’ [-Wmissing-prototypes]
  222 | void __wrap_free(void *ptr)
      |      ^~~~~~~~~~~
../arch/um/os-Linux/mem.c:28:6: warning: no previous prototype for ‘kasan_map_memory’ [-Wmissing-prototypes]
   28 | void kasan_map_memory(void *start, size_t len)
      |      ^~~~~~~~~~~~~~~~
../arch/um/os-Linux/mem.c:212:13: warning: no previous prototype for ‘check_tmpexec’ [-Wmissing-prototypes]
  212 | void __init check_tmpexec(void)
      |             ^~~~~~~~~~~~~
../arch/um/os-Linux/signal.c:75:6: warning: no previous prototype for ‘sig_handler’ [-Wmissing-prototypes]
   75 | void sig_handler(int sig, struct siginfo *si, mcontext_t *mc)
      |      ^~~~~~~~~~~
../arch/um/os-Linux/signal.c:111:6: warning: no previous prototype for ‘timer_alarm_handler’ [-Wmissing-prototypes]
  111 | void timer_alarm_handler(int sig, struct siginfo *unused_si, mcontext_t *mc)
      |      ^~~~~~~~~~~~~~~~~~~
../arch/um/os-Linux/start_up.c:301:12: warning: no previous prototype for ‘parse_iomem’ [-Wmissing-prototypes]
  301 | int __init parse_iomem(char *str, int *add)
      |            ^~~~~~~~~~~
../arch/um/kernel/mem.c:202:8: warning: no previous prototype for ‘pgd_alloc’ [-Wmissing-prototypes]
  202 | pgd_t *pgd_alloc(struct mm_struct *mm)
      |        ^~~~~~~~~
../arch/um/kernel/mem.c:215:7: warning: no previous prototype for ‘uml_kmalloc’ [-Wmissing-prototypes]
  215 | void *uml_kmalloc(int size, int flags)
      |       ^~~~~~~~~~~
../arch/um/kernel/process.c:51:5: warning: no previous prototype for ‘pid_to_processor_id’ [-Wmissing-prototypes]
   51 | int pid_to_processor_id(int pid)
      |     ^~~~~~~~~~~~~~~~~~~
../arch/um/kernel/process.c:87:7: warning: no previous prototype for ‘__switch_to’ [-Wmissing-prototypes]
   87 | void *__switch_to(struct task_struct *from, struct task_struct *to)
      |       ^~~~~~~~~~~
../arch/um/kernel/process.c:140:6: warning: no previous prototype for ‘fork_handler’ [-Wmissing-prototypes]
  140 | void fork_handler(void)
      |      ^~~~~~~~~~~~
../arch/um/kernel/process.c:217:6: warning: no previous prototype for ‘arch_cpu_idle’ [-Wmissing-prototypes]
  217 | void arch_cpu_idle(void)
      |      ^~~~~~~~~~~~~
../arch/um/kernel/process.c:253:5: warning: no previous prototype for ‘copy_to_user_proc’ [-Wmissing-prototypes]
  253 | int copy_to_user_proc(void __user *to, void *from, int size)
      |     ^~~~~~~~~~~~~~~~~
../arch/um/kernel/process.c:263:5: warning: no previous prototype for ‘clear_user_proc’ [-Wmissing-prototypes]
  263 | int clear_user_proc(void __user *buf, int size)
      |     ^~~~~~~~~~~~~~~
../arch/um/kernel/process.c:271:6: warning: no previous prototype for ‘set_using_sysemu’ [-Wmissing-prototypes]
  271 | void set_using_sysemu(int value)
      |      ^~~~~~~~~~~~~~~~
../arch/um/kernel/process.c:278:5: warning: no previous prototype for ‘get_using_sysemu’ [-Wmissing-prototypes]
  278 | int get_using_sysemu(void)
      |     ^~~~~~~~~~~~~~~~
../arch/um/kernel/process.c:316:12: warning: no previous prototype for ‘make_proc_sysemu’ [-Wmissing-prototypes]
  316 | int __init make_proc_sysemu(void)
      |            ^~~~~~~~~~~~~~~~
../arch/um/kernel/process.c:348:15: warning: no previous prototype for ‘arch_align_stack’ [-Wmissing-prototypes]
  348 | unsigned long arch_align_stack(unsigned long sp)
      |               ^~~~~~~~~~~~~~~~
../arch/x86/um/syscalls_64.c:48:6: warning: no previous prototype for ‘arch_switch_to’ [-Wmissing-prototypes]
   48 | void arch_switch_to(struct task_struct *to)
      |      ^~~~~~~~~~~~~~
../arch/um/kernel/reboot.c:45:6: warning: no previous prototype for ‘machine_restart’ [-Wmissing-prototypes]
   45 | void machine_restart(char * __unused)
      |      ^~~~~~~~~~~~~~~
../arch/um/kernel/reboot.c:51:6: warning: no previous prototype for ‘machine_power_off’ [-Wmissing-prototypes]
   51 | void machine_power_off(void)
      |      ^~~~~~~~~~~~~~~~~
../arch/um/kernel/reboot.c:57:6: warning: no previous prototype for ‘machine_halt’ [-Wmissing-prototypes]
   57 | void machine_halt(void)
      |      ^~~~~~~~~~~~
../arch/um/kernel/tlb.c:579:6: warning: no previous prototype for ‘flush_tlb_mm_range’ [-Wmissing-prototypes]
  579 | void flush_tlb_mm_range(struct mm_struct *mm, unsigned long start,
      |      ^~~~~~~~~~~~~~~~~~
../arch/um/kernel/tlb.c:594:6: warning: no previous prototype for ‘force_flush_all’ [-Wmissing-prototypes]
  594 | void force_flush_all(void)
      |      ^~~~~~~~~~~~~~~
../arch/um/kernel/um_arch.c:408:19: warning: no previous prototype for ‘read_initrd’ [-Wmissing-prototypes]
  408 | int __init __weak read_initrd(void)
      |                   ^~~~~~~~~~~
../arch/um/kernel/um_arch.c:461:7: warning: no previous prototype for ‘text_poke’ [-Wmissing-prototypes]
  461 | void *text_poke(void *addr, const void *opcode, size_t len)
      |       ^~~~~~~~~
../arch/um/kernel/um_arch.c:473:6: warning: no previous prototype for ‘text_poke_sync’ [-Wmissing-prototypes]
  473 | void text_poke_sync(void)
      |      ^~~~~~~~~~~~~~
../arch/um/kernel/kmsg_dump.c:60:12: warning: no previous prototype for ‘kmsg_dumper_stdout_init’ [-Wmissing-prototypes]
   60 | int __init kmsg_dumper_stdout_init(void)
      |            ^~~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/xe_mmio.c: In function ‘xe_mmio_read8’:
../drivers/gpu/drm/xe/xe_mmio.c:433:25: error: incompatible type for argument 2 of ‘trace_xe_reg_rw’
  433 |  trace_xe_reg_rw(false, reg, val, sizeof(val), true);
      |                         ^~~
      |                         |
      |                         struct xe_reg
In file included from ../drivers/gpu/drm/xe/xe_trace.h:12,
                 from ../drivers/gpu/drm/xe/xe_mmio.c:25:
../drivers/gpu/drm/xe/xe_trace.h:625:27: note: expected ‘u32’ {aka ‘unsigned int’} but argument is of type ‘struct xe_reg’
  625 |  TP_PROTO(bool write, u32 reg, u64 val, int len, bool trace),
      |                       ~~~~^~~
../include/linux/tracepoint.h:256:34: note: in definition of macro ‘__DECLARE_TRACE’
  256 |  static inline void trace_##name(proto)    \
      |                                  ^~~~~
../include/linux/tracepoint.h:439:24: note: in expansion of macro ‘PARAMS’
  439 |  __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args),  \
      |                        ^~~~~~
../include/linux/tracepoint.h:578:2: note: in expansion of macro ‘DECLARE_TRACE_CONDITION’
  578 |  DECLARE_TRACE_CONDITION(name, PARAMS(proto),  \
      |  ^~~~~~~~~~~~~~~~~~~~~~~
../include/linux/tracepoint.h:578:32: note: in expansion of macro ‘PARAMS’
  578 |  DECLARE_TRACE_CONDITION(name, PARAMS(proto),  \
      |                                ^~~~~~
../drivers/gpu/drm/xe/xe_trace.h:624:1: note: in expansion of macro ‘TRACE_EVENT_CONDITION’
  624 | TRACE_EVENT_CONDITION(xe_reg_rw,
      | ^~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/xe_trace.h:625:2: note: in expansion of macro ‘TP_PROTO’
  625 |  TP_PROTO(bool write, u32 reg, u64 val, int len, bool trace),
      |  ^~~~~~~~
../drivers/gpu/drm/xe/xe_mmio.c: In function ‘xe_mmio_read16’:
../drivers/gpu/drm/xe/xe_mmio.c:447:25: error: incompatible type for argument 2 of ‘trace_xe_reg_rw’
  447 |  trace_xe_reg_rw(false, reg, val, sizeof(val), true);
      |                         ^~~
      |                         |
      |                         struct xe_reg
In file included from ../drivers/gpu/drm/xe/xe_trace.h:12,
                 from ../drivers/gpu/drm/xe/xe_mmio.c:25:
../drivers/gpu/drm/xe/xe_trace.h:625:27: note: expected ‘u32’ {aka ‘unsigned int’} but argument is of type ‘struct xe_reg’
  625 |  TP_PROTO(bool write, u32 reg, u64 val, int len, bool trace),
      |                       ~~~~^~~
../include/linux/tracepoint.h:256:34: note: in definition of macro ‘__DECLARE_TRACE’
  256 |  static inline void trace_##name(proto)    \
      |                                  ^~~~~
../include/linux/tracepoint.h:439:24: note: in expansion of macro ‘PARAMS’
  439 |  __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args),  \
      |                        ^~~~~~
../include/linux/tracepoint.h:578:2: note: in expansion of macro ‘DECLARE_TRACE_CONDITION’
  578 |  DECLARE_TRACE_CONDITION(name, PARAMS(proto),  \
      |  ^~~~~~~~~~~~~~~~~~~~~~~
../include/linux/tracepoint.h:578:32: note: in expansion of macro ‘PARAMS’
  578 |  DECLARE_TRACE_CONDITION(name, PARAMS(proto),  \
      |                                ^~~~~~
../drivers/gpu/drm/xe/xe_trace.h:624:1: note: in expansion of macro ‘TRACE_EVENT_CONDITION’
  624 | TRACE_EVENT_CONDITION(xe_reg_rw,
      | ^~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/xe_trace.h:625:2: note: in expansion of macro ‘TP_PROTO’
  625 |  TP_PROTO(bool write, u32 reg, u64 val, int len, bool trace),
      |  ^~~~~~~~
../drivers/gpu/drm/xe/xe_mmio.c: In function ‘xe_mmio_write32’:
../drivers/gpu/drm/xe/xe_mmio.c:459:24: error: incompatible type for argument 2 of ‘trace_xe_reg_rw’
  459 |  trace_xe_reg_rw(true, reg, val, sizeof(val), true);
      |                        ^~~
      |                        |
      |                        struct xe_reg
In file included from ../drivers/gpu/drm/xe/xe_trace.h:12,
                 from ../drivers/gpu/drm/xe/xe_mmio.c:25:
../drivers/gpu/drm/xe/xe_trace.h:625:27: note: expected ‘u32’ {aka ‘unsigned int’} but argument is of type ‘struct xe_reg’
  625 |  TP_PROTO(bool write, u32 reg, u64 val, int len, bool trace),
      |                       ~~~~^~~
../include/linux/tracepoint.h:256:34: note: in definition of macro ‘__DECLARE_TRACE’
  256 |  static inline void trace_##name(proto)    \
      |                                  ^~~~~
../include/linux/tracepoint.h:439:24: note: in expansion of macro ‘PARAMS’
  439 |  __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args),  \
      |                        ^~~~~~
../include/linux/tracepoint.h:578:2: note: in expansion of macro ‘DECLARE_TRACE_CONDITION’
  578 |  DECLARE_TRACE_CONDITION(name, PARAMS(proto),  \
      |  ^~~~~~~~~~~~~~~~~~~~~~~
../include/linux/tracepoint.h:578:32: note: in expansion of macro ‘PARAMS’
  578 |  DECLARE_TRACE_CONDITION(name, PARAMS(proto),  \
      |                                ^~~~~~
../drivers/gpu/drm/xe/xe_trace.h:624:1: note: in expansion of macro ‘TRACE_EVENT_CONDITION’
  624 | TRACE_EVENT_CONDITION(xe_reg_rw,
      | ^~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/xe_trace.h:625:2: note: in expansion of macro ‘TP_PROTO’
  625 |  TP_PROTO(bool write, u32 reg, u64 val, int len, bool trace),
      |  ^~~~~~~~
../drivers/gpu/drm/xe/xe_mmio.c: In function ‘xe_mmio_read32’:
../drivers/gpu/drm/xe/xe_mmio.c:472:25: error: incompatible type for argument 2 of ‘trace_xe_reg_rw’
  472 |  trace_xe_reg_rw(false, reg, val, sizeof(val), true);
      |                         ^~~
      |                         |
      |                         struct xe_reg
In file included from ../drivers/gpu/drm/xe/xe_trace.h:12,
                 from ../drivers/gpu/drm/xe/xe_mmio.c:25:
../drivers/gpu/drm/xe/xe_trace.h:625:27: note: expected ‘u32’ {aka ‘unsigned int’} but argument is of type ‘struct xe_reg’
  625 |  TP_PROTO(bool write, u32 reg, u64 val, int len, bool trace),
      |                       ~~~~^~~
../include/linux/tracepoint.h:256:34: note: in definition of macro ‘__DECLARE_TRACE’
  256 |  static inline void trace_##name(proto)    \
      |                                  ^~~~~
../include/linux/tracepoint.h:439:24: note: in expansion of macro ‘PARAMS’
  439 |  __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args),  \
      |                        ^~~~~~
../include/linux/tracepoint.h:578:2: note: in expansion of macro ‘DECLARE_TRACE_CONDITION’
  578 |  DECLARE_TRACE_CONDITION(name, PARAMS(proto),  \
      |  ^~~~~~~~~~~~~~~~~~~~~~~
../include/linux/tracepoint.h:578:32: note: in expansion of macro ‘PARAMS’
  578 |  DECLARE_TRACE_CONDITION(name, PARAMS(proto),  \
      |                                ^~~~~~
../drivers/gpu/drm/xe/xe_trace.h:624:1: note: in expansion of macro ‘TRACE_EVENT_CONDITION’
  624 | TRACE_EVENT_CONDITION(xe_reg_rw,
      | ^~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/xe_trace.h:625:2: note: in expansion of macro ‘TP_PROTO’
  625 |  TP_PROTO(bool write, u32 reg, u64 val, int len, bool trace),
      |  ^~~~~~~~
make[7]: *** [../scripts/Makefile.build:244: drivers/gpu/drm/xe/xe_mmio.o] Error 1
make[7]: *** Waiting for unfinished jobs....
../lib/iomap.c:156:5: warning: no previous prototype for ‘ioread64_lo_hi’ [-Wmissing-prototypes]
  156 | u64 ioread64_lo_hi(const void __iomem *addr)
      |     ^~~~~~~~~~~~~~
../lib/iomap.c:163:5: warning: no previous prototype for ‘ioread64_hi_lo’ [-Wmissing-prototypes]
  163 | u64 ioread64_hi_lo(const void __iomem *addr)
      |     ^~~~~~~~~~~~~~
../lib/iomap.c:170:5: warning: no previous prototype for ‘ioread64be_lo_hi’ [-Wmissing-prototypes]
  170 | u64 ioread64be_lo_hi(const void __iomem *addr)
      |     ^~~~~~~~~~~~~~~~
../lib/iomap.c:178:5: warning: no previous prototype for ‘ioread64be_hi_lo’ [-Wmissing-prototypes]
  178 | u64 ioread64be_hi_lo(const void __iomem *addr)
      |     ^~~~~~~~~~~~~~~~
../lib/iomap.c:264:6: warning: no previous prototype for ‘iowrite64_lo_hi’ [-Wmissing-prototypes]
  264 | void iowrite64_lo_hi(u64 val, void __iomem *addr)
      |      ^~~~~~~~~~~~~~~
../lib/iomap.c:272:6: warning: no previous prototype for ‘iowrite64_hi_lo’ [-Wmissing-prototypes]
  272 | void iowrite64_hi_lo(u64 val, void __iomem *addr)
      |      ^~~~~~~~~~~~~~~
../lib/iomap.c:280:6: warning: no previous prototype for ‘iowrite64be_lo_hi’ [-Wmissing-prototypes]
  280 | void iowrite64be_lo_hi(u64 val, void __iomem *addr)
      |      ^~~~~~~~~~~~~~~~~
../lib/iomap.c:288:6: warning: no previous prototype for ‘iowrite64be_hi_lo’ [-Wmissing-prototypes]
  288 | void iowrite64be_hi_lo(u64 val, void __iomem *addr)
      |      ^~~~~~~~~~~~~~~~~
make[6]: *** [../scripts/Makefile.build:485: drivers/gpu/drm/xe] Error 2
make[6]: *** Waiting for unfinished jobs....
make[5]: *** [../scripts/Makefile.build:485: drivers/gpu/drm] Error 2
make[4]: *** [../scripts/Makefile.build:485: drivers/gpu] Error 2
make[3]: *** [../scripts/Makefile.build:485: drivers] Error 2
make[2]: *** [/kernel/Makefile:1919: .] Error 2
make[1]: *** [/kernel/Makefile:240: __sub-make] Error 2
make: *** [Makefile:240: __sub-make] Error 2

[23:44:54] Configuring KUnit Kernel ...
Generating .config ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
[23:44:58] Building KUnit Kernel ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
Building with:
$ make ARCH=um O=.kunit --jobs=48
+ cleanup
++ stat -c %u:%g /kernel
+ chown -R 1003:1003 /kernel



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm/xe: Add reg read/write trace
  2024-04-18 22:22 [PATCH] drm/xe: Add reg read/write trace Radhakrishna Sripada
                   ` (2 preceding siblings ...)
  2024-04-18 23:45 ` ✗ CI.KUnit: failure " Patchwork
@ 2024-04-19 11:46 ` Jani Nikula
  2024-04-23 21:25   ` Sripada, Radhakrishna
  2024-04-19 16:37 ` Ville Syrjälä
  4 siblings, 1 reply; 8+ messages in thread
From: Jani Nikula @ 2024-04-19 11:46 UTC (permalink / raw)
  To: Radhakrishna Sripada, intel-xe; +Cc: Radhakrishna Sripada, Lucas De Marchi

On Thu, 18 Apr 2024, Radhakrishna Sripada <radhakrishna.sripada@intel.com> wrote:
> This will help debug register read/writes and provides
> a way to trace all the mmio transactions.
>
> Signed-off-by: Radhakrishna Sripada <radhakrishna.sripada@intel.com>
> ---
>  drivers/gpu/drm/xe/xe_mmio.c  | 20 +++++++++++++++++---
>  drivers/gpu/drm/xe/xe_trace.h | 28 ++++++++++++++++++++++++++++
>  2 files changed, 45 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_mmio.c b/drivers/gpu/drm/xe/xe_mmio.c
> index 334637511e75..659c19d4f0a6 100644
> --- a/drivers/gpu/drm/xe/xe_mmio.c
> +++ b/drivers/gpu/drm/xe/xe_mmio.c
> @@ -22,6 +22,7 @@
>  #include "xe_module.h"
>  #include "xe_sriov.h"
>  #include "xe_tile.h"
> +#include "xe_trace.h"
>  
>  #define XEHP_MTCFG_ADDR		XE_REG(0x101800)
>  #define TILE_COUNT		REG_GENMASK(15, 8)
> @@ -423,21 +424,29 @@ int xe_mmio_init(struct xe_device *xe)
>  u8 xe_mmio_read8(struct xe_gt *gt, struct xe_reg reg)
>  {
>  	struct xe_tile *tile = gt_to_tile(gt);
> +	u8 val;
>  
>  	if (reg.addr < gt->mmio.adj_limit)
>  		reg.addr += gt->mmio.adj_offset;
>  
> -	return readb((reg.ext ? tile->mmio_ext.regs : tile->mmio.regs) + reg.addr);
> +	val = readb((reg.ext ? tile->mmio_ext.regs : tile->mmio.regs) + reg.addr);
> +	trace_xe_reg_rw(false, reg, val, sizeof(val), true);
> +
> +	return val;
>  }
>  
>  u16 xe_mmio_read16(struct xe_gt *gt, struct xe_reg reg)
>  {
>  	struct xe_tile *tile = gt_to_tile(gt);
> +	u16 val;
>  
>  	if (reg.addr < gt->mmio.adj_limit)
>  		reg.addr += gt->mmio.adj_offset;
>  
> -	return readw((reg.ext ? tile->mmio_ext.regs : tile->mmio.regs) + reg.addr);
> +	val = readw((reg.ext ? tile->mmio_ext.regs : tile->mmio.regs) + reg.addr);
> +	trace_xe_reg_rw(false, reg, val, sizeof(val), true);
> +
> +	return val;
>  }
>  
>  void xe_mmio_write32(struct xe_gt *gt, struct xe_reg reg, u32 val)
> @@ -447,17 +456,22 @@ void xe_mmio_write32(struct xe_gt *gt, struct xe_reg reg, u32 val)
>  	if (reg.addr < gt->mmio.adj_limit)
>  		reg.addr += gt->mmio.adj_offset;
>  
> +	trace_xe_reg_rw(true, reg, val, sizeof(val), true);
>  	writel(val, (reg.ext ? tile->mmio_ext.regs : tile->mmio.regs) + reg.addr);
>  }
>  
>  u32 xe_mmio_read32(struct xe_gt *gt, struct xe_reg reg)
>  {
>  	struct xe_tile *tile = gt_to_tile(gt);
> +	u32 val;
>  
>  	if (reg.addr < gt->mmio.adj_limit)
>  		reg.addr += gt->mmio.adj_offset;
>  
> -	return readl((reg.ext ? tile->mmio_ext.regs : tile->mmio.regs) + reg.addr);
> +	val = readl((reg.ext ? tile->mmio_ext.regs : tile->mmio.regs) + reg.addr);
> +	trace_xe_reg_rw(false, reg, val, sizeof(val), true);
> +
> +	return val;
>  }
>  
>  u32 xe_mmio_rmw32(struct xe_gt *gt, struct xe_reg reg, u32 clr, u32 set)
> diff --git a/drivers/gpu/drm/xe/xe_trace.h b/drivers/gpu/drm/xe/xe_trace.h
> index 2d56cfc09e42..41d778dd43c6 100644
> --- a/drivers/gpu/drm/xe/xe_trace.h
> +++ b/drivers/gpu/drm/xe/xe_trace.h
> @@ -621,6 +621,34 @@ DEFINE_EVENT_PRINT(xe_guc_ctb, xe_guc_ctb_g2h,
>  
>  );
>  
> +TRACE_EVENT_CONDITION(xe_reg_rw,
> +	TP_PROTO(bool write, u32 reg, u64 val, int len, bool trace),
> +
> +	TP_ARGS(write, reg, val, len, trace),
> +
> +	TP_CONDITION(trace),
> +
> +	TP_STRUCT__entry(
> +		__field(u64, val)
> +		__field(u32, reg)
> +		__field(u16, write)
> +		__field(u16, len)
> +		),
> +
> +	TP_fast_assign(
> +		__entry->val = (u64)val;
> +		__entry->reg = reg;
> +		__entry->write = write;
> +		__entry->len = len;
> +		),
> +
> +	TP_printk("%s reg=0x%x, len=%d, val=(0x%x, 0x%x)",
> +		__entry->write ? "write" : "read",
> +		__entry->reg, __entry->len,
> +		(u32)(__entry->val & 0xffffffff),
> +		(u32)(__entry->val >> 32))
> +);
> +

Btw xe_trace.h already has all the makings of a catch all header that
has to include everything to get stuff done, and then all the places
doing tracing end up depending on everything. Change some innocuous
header somewhere, and you need to rebuild the entire driver. We have
that in i915, and it was slightly mitigated by separating display
traces, but it's still bad.

It might be a good idea to split this up to xe_<feature>_trace.h files
instead. Failing at that, maybe stop adding new stuff to it?


BR,
Jani.


>  #endif
>  
>  /* This part must be outside protection */

-- 
Jani Nikula, Intel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm/xe: Add reg read/write trace
  2024-04-18 22:22 [PATCH] drm/xe: Add reg read/write trace Radhakrishna Sripada
                   ` (3 preceding siblings ...)
  2024-04-19 11:46 ` [PATCH] " Jani Nikula
@ 2024-04-19 16:37 ` Ville Syrjälä
  4 siblings, 0 replies; 8+ messages in thread
From: Ville Syrjälä @ 2024-04-19 16:37 UTC (permalink / raw)
  To: Radhakrishna Sripada; +Cc: intel-xe

On Thu, Apr 18, 2024 at 03:22:43PM -0700, Radhakrishna Sripada wrote:
> This will help debug register read/writes and provides
> a way to trace all the mmio transactions.
> 
> Signed-off-by: Radhakrishna Sripada <radhakrishna.sripada@intel.com>
> ---
>  drivers/gpu/drm/xe/xe_mmio.c  | 20 +++++++++++++++++---
>  drivers/gpu/drm/xe/xe_trace.h | 28 ++++++++++++++++++++++++++++
>  2 files changed, 45 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_mmio.c b/drivers/gpu/drm/xe/xe_mmio.c
> index 334637511e75..659c19d4f0a6 100644
> --- a/drivers/gpu/drm/xe/xe_mmio.c
> +++ b/drivers/gpu/drm/xe/xe_mmio.c
> @@ -22,6 +22,7 @@
>  #include "xe_module.h"
>  #include "xe_sriov.h"
>  #include "xe_tile.h"
> +#include "xe_trace.h"
>  
>  #define XEHP_MTCFG_ADDR		XE_REG(0x101800)
>  #define TILE_COUNT		REG_GENMASK(15, 8)
> @@ -423,21 +424,29 @@ int xe_mmio_init(struct xe_device *xe)
>  u8 xe_mmio_read8(struct xe_gt *gt, struct xe_reg reg)
>  {
>  	struct xe_tile *tile = gt_to_tile(gt);
> +	u8 val;
>  
>  	if (reg.addr < gt->mmio.adj_limit)
>  		reg.addr += gt->mmio.adj_offset;
>  
> -	return readb((reg.ext ? tile->mmio_ext.regs : tile->mmio.regs) + reg.addr);
> +	val = readb((reg.ext ? tile->mmio_ext.regs : tile->mmio.regs) + reg.addr);
> +	trace_xe_reg_rw(false, reg, val, sizeof(val), true);
> +
> +	return val;
>  }
>  
>  u16 xe_mmio_read16(struct xe_gt *gt, struct xe_reg reg)
>  {
>  	struct xe_tile *tile = gt_to_tile(gt);
> +	u16 val;
>  
>  	if (reg.addr < gt->mmio.adj_limit)
>  		reg.addr += gt->mmio.adj_offset;
>  
> -	return readw((reg.ext ? tile->mmio_ext.regs : tile->mmio.regs) + reg.addr);
> +	val = readw((reg.ext ? tile->mmio_ext.regs : tile->mmio.regs) + reg.addr);
> +	trace_xe_reg_rw(false, reg, val, sizeof(val), true);
> +
> +	return val;
>  }
>  
>  void xe_mmio_write32(struct xe_gt *gt, struct xe_reg reg, u32 val)
> @@ -447,17 +456,22 @@ void xe_mmio_write32(struct xe_gt *gt, struct xe_reg reg, u32 val)
>  	if (reg.addr < gt->mmio.adj_limit)
>  		reg.addr += gt->mmio.adj_offset;
>  
> +	trace_xe_reg_rw(true, reg, val, sizeof(val), true);
>  	writel(val, (reg.ext ? tile->mmio_ext.regs : tile->mmio.regs) + reg.addr);
>  }
>  
>  u32 xe_mmio_read32(struct xe_gt *gt, struct xe_reg reg)
>  {
>  	struct xe_tile *tile = gt_to_tile(gt);
> +	u32 val;
>  
>  	if (reg.addr < gt->mmio.adj_limit)
>  		reg.addr += gt->mmio.adj_offset;
>  
> -	return readl((reg.ext ? tile->mmio_ext.regs : tile->mmio.regs) + reg.addr);
> +	val = readl((reg.ext ? tile->mmio_ext.regs : tile->mmio.regs) + reg.addr);
> +	trace_xe_reg_rw(false, reg, val, sizeof(val), true);
> +
> +	return val;
>  }
>  
>  u32 xe_mmio_rmw32(struct xe_gt *gt, struct xe_reg reg, u32 clr, u32 set)
> diff --git a/drivers/gpu/drm/xe/xe_trace.h b/drivers/gpu/drm/xe/xe_trace.h
> index 2d56cfc09e42..41d778dd43c6 100644
> --- a/drivers/gpu/drm/xe/xe_trace.h
> +++ b/drivers/gpu/drm/xe/xe_trace.h
> @@ -621,6 +621,34 @@ DEFINE_EVENT_PRINT(xe_guc_ctb, xe_guc_ctb_g2h,
>  
>  );
>  
> +TRACE_EVENT_CONDITION(xe_reg_rw,
> +	TP_PROTO(bool write, u32 reg, u64 val, int len, bool trace),
> +
> +	TP_ARGS(write, reg, val, len, trace),
> +
> +	TP_CONDITION(trace),
> +
> +	TP_STRUCT__entry(
> +		__field(u64, val)
> +		__field(u32, reg)
> +		__field(u16, write)
> +		__field(u16, len)
> +		),
> +
> +	TP_fast_assign(
> +		__entry->val = (u64)val;
> +		__entry->reg = reg;
> +		__entry->write = write;
> +		__entry->len = len;
> +		),
> +
> +	TP_printk("%s reg=0x%x, len=%d, val=(0x%x, 0x%x)",

Someone should do something about all the i915 and xe
tracepoints that lack the device information. Currently
those are somewhat useless on any multi-gpu system (unless
you can guarantee only gpu is actually doing something).

> +		__entry->write ? "write" : "read",
> +		__entry->reg, __entry->len,
> +		(u32)(__entry->val & 0xffffffff),
> +		(u32)(__entry->val >> 32))
> +);
> +
>  #endif
>  
>  /* This part must be outside protection */
> -- 
> 2.34.1

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH] drm/xe: Add reg read/write trace
  2024-04-19 11:46 ` [PATCH] " Jani Nikula
@ 2024-04-23 21:25   ` Sripada, Radhakrishna
  2024-04-24  8:59     ` Jani Nikula
  0 siblings, 1 reply; 8+ messages in thread
From: Sripada, Radhakrishna @ 2024-04-23 21:25 UTC (permalink / raw)
  To: Jani Nikula, intel-xe; +Cc: De Marchi, Lucas

Hi Jani,

After this patch the following will be the main trace declarations
xe_gt_tlb_invalidation_fence, xe_bo, xe_exec_queue, xe_sched_job, xe_sched_msg,
xe_hw_fence, xe_vma, xe_vm, xe_guc_ct_flow_control, xe_guc_ctb, xe_reg_rw

Would it be ok if we can group them like the following.

xe_trace_bo.h : xe_bo, xe_vma, xe_vm
xe_trace_gt.h: xe_gt_tlb_invalidation_fence, xe_exec_queue, xe_sched_job, xe_sched_msg, xe_hw_fence, xe_reg_rw
xe_trace_guc.h: xe_guc_ct_flow_control, xe_guc_ctb

Does this grouping seem ok?

Regards,
Radhakrishna Sripada 

> -----Original Message-----
> From: Jani Nikula <jani.nikula@linux.intel.com>
> Sent: Friday, April 19, 2024 4:46 AM
> To: Sripada, Radhakrishna <radhakrishna.sripada@intel.com>; intel-
> xe@lists.freedesktop.org
> Cc: Sripada, Radhakrishna <radhakrishna.sripada@intel.com>; De Marchi, Lucas
> <lucas.demarchi@intel.com>
> Subject: Re: [PATCH] drm/xe: Add reg read/write trace
> 
> On Thu, 18 Apr 2024, Radhakrishna Sripada <radhakrishna.sripada@intel.com>
> wrote:
> > This will help debug register read/writes and provides
> > a way to trace all the mmio transactions.
> >
> > Signed-off-by: Radhakrishna Sripada <radhakrishna.sripada@intel.com>
> > ---
> >  drivers/gpu/drm/xe/xe_mmio.c  | 20 +++++++++++++++++---
> >  drivers/gpu/drm/xe/xe_trace.h | 28 ++++++++++++++++++++++++++++
> >  2 files changed, 45 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/xe/xe_mmio.c b/drivers/gpu/drm/xe/xe_mmio.c
> > index 334637511e75..659c19d4f0a6 100644
> > --- a/drivers/gpu/drm/xe/xe_mmio.c
> > +++ b/drivers/gpu/drm/xe/xe_mmio.c
> > @@ -22,6 +22,7 @@
> >  #include "xe_module.h"
> >  #include "xe_sriov.h"
> >  #include "xe_tile.h"
> > +#include "xe_trace.h"
> >
> >  #define XEHP_MTCFG_ADDR		XE_REG(0x101800)
> >  #define TILE_COUNT		REG_GENMASK(15, 8)
> > @@ -423,21 +424,29 @@ int xe_mmio_init(struct xe_device *xe)
> >  u8 xe_mmio_read8(struct xe_gt *gt, struct xe_reg reg)
> >  {
> >  	struct xe_tile *tile = gt_to_tile(gt);
> > +	u8 val;
> >
> >  	if (reg.addr < gt->mmio.adj_limit)
> >  		reg.addr += gt->mmio.adj_offset;
> >
> > -	return readb((reg.ext ? tile->mmio_ext.regs : tile->mmio.regs) +
> reg.addr);
> > +	val = readb((reg.ext ? tile->mmio_ext.regs : tile->mmio.regs) + reg.addr);
> > +	trace_xe_reg_rw(false, reg, val, sizeof(val), true);
> > +
> > +	return val;
> >  }
> >
> >  u16 xe_mmio_read16(struct xe_gt *gt, struct xe_reg reg)
> >  {
> >  	struct xe_tile *tile = gt_to_tile(gt);
> > +	u16 val;
> >
> >  	if (reg.addr < gt->mmio.adj_limit)
> >  		reg.addr += gt->mmio.adj_offset;
> >
> > -	return readw((reg.ext ? tile->mmio_ext.regs : tile->mmio.regs) +
> reg.addr);
> > +	val = readw((reg.ext ? tile->mmio_ext.regs : tile->mmio.regs) + reg.addr);
> > +	trace_xe_reg_rw(false, reg, val, sizeof(val), true);
> > +
> > +	return val;
> >  }
> >
> >  void xe_mmio_write32(struct xe_gt *gt, struct xe_reg reg, u32 val)
> > @@ -447,17 +456,22 @@ void xe_mmio_write32(struct xe_gt *gt, struct
> xe_reg reg, u32 val)
> >  	if (reg.addr < gt->mmio.adj_limit)
> >  		reg.addr += gt->mmio.adj_offset;
> >
> > +	trace_xe_reg_rw(true, reg, val, sizeof(val), true);
> >  	writel(val, (reg.ext ? tile->mmio_ext.regs : tile->mmio.regs) + reg.addr);
> >  }
> >
> >  u32 xe_mmio_read32(struct xe_gt *gt, struct xe_reg reg)
> >  {
> >  	struct xe_tile *tile = gt_to_tile(gt);
> > +	u32 val;
> >
> >  	if (reg.addr < gt->mmio.adj_limit)
> >  		reg.addr += gt->mmio.adj_offset;
> >
> > -	return readl((reg.ext ? tile->mmio_ext.regs : tile->mmio.regs) +
> reg.addr);
> > +	val = readl((reg.ext ? tile->mmio_ext.regs : tile->mmio.regs) + reg.addr);
> > +	trace_xe_reg_rw(false, reg, val, sizeof(val), true);
> > +
> > +	return val;
> >  }
> >
> >  u32 xe_mmio_rmw32(struct xe_gt *gt, struct xe_reg reg, u32 clr, u32 set)
> > diff --git a/drivers/gpu/drm/xe/xe_trace.h b/drivers/gpu/drm/xe/xe_trace.h
> > index 2d56cfc09e42..41d778dd43c6 100644
> > --- a/drivers/gpu/drm/xe/xe_trace.h
> > +++ b/drivers/gpu/drm/xe/xe_trace.h
> > @@ -621,6 +621,34 @@ DEFINE_EVENT_PRINT(xe_guc_ctb, xe_guc_ctb_g2h,
> >
> >  );
> >
> > +TRACE_EVENT_CONDITION(xe_reg_rw,
> > +	TP_PROTO(bool write, u32 reg, u64 val, int len, bool trace),
> > +
> > +	TP_ARGS(write, reg, val, len, trace),
> > +
> > +	TP_CONDITION(trace),
> > +
> > +	TP_STRUCT__entry(
> > +		__field(u64, val)
> > +		__field(u32, reg)
> > +		__field(u16, write)
> > +		__field(u16, len)
> > +		),
> > +
> > +	TP_fast_assign(
> > +		__entry->val = (u64)val;
> > +		__entry->reg = reg;
> > +		__entry->write = write;
> > +		__entry->len = len;
> > +		),
> > +
> > +	TP_printk("%s reg=0x%x, len=%d, val=(0x%x, 0x%x)",
> > +		__entry->write ? "write" : "read",
> > +		__entry->reg, __entry->len,
> > +		(u32)(__entry->val & 0xffffffff),
> > +		(u32)(__entry->val >> 32))
> > +);
> > +
> 
> Btw xe_trace.h already has all the makings of a catch all header that
> has to include everything to get stuff done, and then all the places
> doing tracing end up depending on everything. Change some innocuous
> header somewhere, and you need to rebuild the entire driver. We have
> that in i915, and it was slightly mitigated by separating display
> traces, but it's still bad.
> 
> It might be a good idea to split this up to xe_<feature>_trace.h files
> instead. Failing at that, maybe stop adding new stuff to it?
> 
> 
> BR,
> Jani.
> 
> 
> >  #endif
> >
> >  /* This part must be outside protection */
> 
> --
> Jani Nikula, Intel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH] drm/xe: Add reg read/write trace
  2024-04-23 21:25   ` Sripada, Radhakrishna
@ 2024-04-24  8:59     ` Jani Nikula
  0 siblings, 0 replies; 8+ messages in thread
From: Jani Nikula @ 2024-04-24  8:59 UTC (permalink / raw)
  To: Sripada, Radhakrishna, intel-xe; +Cc: De Marchi, Lucas

On Tue, 23 Apr 2024, "Sripada, Radhakrishna" <radhakrishna.sripada@intel.com> wrote:
> Hi Jani,
>
> After this patch the following will be the main trace declarations
> xe_gt_tlb_invalidation_fence, xe_bo, xe_exec_queue, xe_sched_job, xe_sched_msg,
> xe_hw_fence, xe_vma, xe_vm, xe_guc_ct_flow_control, xe_guc_ctb, xe_reg_rw
>
> Would it be ok if we can group them like the following.
>
> xe_trace_bo.h : xe_bo, xe_vma, xe_vm
> xe_trace_gt.h: xe_gt_tlb_invalidation_fence, xe_exec_queue, xe_sched_job, xe_sched_msg, xe_hw_fence, xe_reg_rw
> xe_trace_guc.h: xe_guc_ct_flow_control, xe_guc_ctb
>
> Does this grouping seem ok?

I have no clue. I'm just pointing out a header dependency problem.

BR,
Jani.

-- 
Jani Nikula, Intel

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-04-24  8:59 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-18 22:22 [PATCH] drm/xe: Add reg read/write trace Radhakrishna Sripada
2024-04-18 23:44 ` ✓ CI.Patch_applied: success for " Patchwork
2024-04-18 23:44 ` ✗ CI.checkpatch: warning " Patchwork
2024-04-18 23:45 ` ✗ CI.KUnit: failure " Patchwork
2024-04-19 11:46 ` [PATCH] " Jani Nikula
2024-04-23 21:25   ` Sripada, Radhakrishna
2024-04-24  8:59     ` Jani Nikula
2024-04-19 16:37 ` Ville Syrjälä

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.