xref: /linux/drivers/gpu/drm/panthor/panthor_trace.h (revision 7d1f84f1b94e79cb95d974ab3ec54cb3a4d64f5b)
1 /* SPDX-License-Identifier: GPL-2.0 or MIT */
2 /* Copyright 2025 Collabora ltd. */
3 
4 #undef TRACE_SYSTEM
5 #define TRACE_SYSTEM panthor
6 
7 #if !defined(__PANTHOR_TRACE_H__) || defined(TRACE_HEADER_MULTI_READ)
8 #define __PANTHOR_TRACE_H__
9 
10 #include <linux/tracepoint.h>
11 #include <linux/types.h>
12 
13 #include "panthor_hw.h"
14 
15 /**
16  * gpu_power_status - called whenever parts of GPU hardware are turned on or off
17  * @dev: pointer to the &struct device, for printing the device name
18  * @shader_bitmap: bitmap where a high bit indicates the shader core at a given
19  *                 bit index is on, and a low bit indicates a shader core is
20  *                 either powered off or absent
21  * @tiler_bitmap: bitmap where a high bit indicates the tiler unit at a given
22  *                bit index is on, and a low bit indicates a tiler unit is
23  *                either powered off or absent
24  * @l2_bitmap: bitmap where a high bit indicates the L2 cache at a given bit
25  *             index is on, and a low bit indicates the L2 cache is either
26  *             powered off or absent
27  */
28 TRACE_EVENT_FN(gpu_power_status,
29 	TP_PROTO(const struct device *dev, u64 shader_bitmap, u64 tiler_bitmap,
30 		 u64 l2_bitmap),
31 	TP_ARGS(dev, shader_bitmap, tiler_bitmap, l2_bitmap),
32 	TP_STRUCT__entry(
33 		__string(dev_name, dev_name(dev))
34 		__field(u64, shader_bitmap)
35 		__field(u64, tiler_bitmap)
36 		__field(u64, l2_bitmap)
37 	),
38 	TP_fast_assign(
39 		__assign_str(dev_name);
40 		__entry->shader_bitmap	= shader_bitmap;
41 		__entry->tiler_bitmap	= tiler_bitmap;
42 		__entry->l2_bitmap	= l2_bitmap;
43 	),
44 	TP_printk("%s: shader_bitmap=0x%llx tiler_bitmap=0x%llx l2_bitmap=0x%llx",
45 		  __get_str(dev_name), __entry->shader_bitmap, __entry->tiler_bitmap,
46 		  __entry->l2_bitmap
47 	),
48 	panthor_hw_power_status_register, panthor_hw_power_status_unregister
49 );
50 
51 /**
52  * gpu_job_irq - called after a job interrupt from firmware completes
53  * @dev: pointer to the &struct device, for printing the device name
54  * @events: bitmask of BIT(CSG id) | BIT(31) for a global event
55  * @duration_ns: Nanoseconds between job IRQ handler entry and exit
56  *
57  * The panthor_job_irq_handler() function instrumented by this tracepoint exits
58  * once it has queued the firmware interrupts for processing, not when the
59  * firmware interrupts are fully processed. This tracepoint allows for debugging
60  * issues with delays in the workqueue's processing of events.
61  */
62 TRACE_EVENT(gpu_job_irq,
63 	TP_PROTO(const struct device *dev, u32 events, u32 duration_ns),
64 	TP_ARGS(dev, events, duration_ns),
65 	TP_STRUCT__entry(
66 		__string(dev_name, dev_name(dev))
67 		__field(u32, events)
68 		__field(u32, duration_ns)
69 	),
70 	TP_fast_assign(
71 		__assign_str(dev_name);
72 		__entry->events		= events;
73 		__entry->duration_ns	= duration_ns;
74 	),
75 	TP_printk("%s: events=0x%x duration_ns=%d", __get_str(dev_name),
76 		  __entry->events, __entry->duration_ns)
77 );
78 
79 /**
80  * gpu_cache_flush - emitted after cache flush completes
81  * @dev: pointer to the &struct device, for printing the device name
82  * @l2: "l2" flush flags
83  * @lsc: "lsc" flush flags
84  * @other: "other" flush flags
85  * @duration_ns: how long the cache flush operation took, in nanoseconds
86  * @ret: return status, 0 == success, negative errno on error
87  *
88  * Begins measuring after any initial lock contention around the locks needed
89  * for flushing caches, but before the actual cache flush is requested. Stops
90  * measuring and is emitted after flush operation is over.
91  */
92 TRACE_EVENT(gpu_cache_flush,
93 	    TP_PROTO(const struct device *dev, u32 l2, u32 lsc, u32 other,
94 		     u32 duration_ns, int ret),
95 	    TP_ARGS(dev, l2, lsc, other, duration_ns, ret),
96 	    TP_STRUCT__entry(
97 		    __string(dev_name, dev_name(dev))
98 		    __field(u32, l2)
99 		    __field(u32, lsc)
100 		    __field(u32, other)
101 		    __field(u32, duration_ns)
102 		    __field(int, ret)
103 	    ),
104 	    TP_fast_assign(
105 		    __assign_str(dev_name);
106 		    __entry->l2          = l2;
107 		    __entry->lsc         = lsc;
108 		    __entry->other       = other;
109 		    __entry->duration_ns = duration_ns;
110 		    __entry->ret         = ret;
111 	    ),
112 	    TP_printk("%s: l2=0x%x lsc=0x%x other=0x%x duration_ns=%u ret=%d",
113 		      __get_str(dev_name), __entry->l2, __entry->lsc,
114 		      __entry->other, __entry->duration_ns, __entry->ret)
115 );
116 
117 #endif /* __PANTHOR_TRACE_H__ */
118 
119 #undef TRACE_INCLUDE_PATH
120 #define TRACE_INCLUDE_PATH .
121 #undef TRACE_INCLUDE_FILE
122 #define TRACE_INCLUDE_FILE panthor_trace
123 
124 #include <trace/define_trace.h>
125