summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/panthor/panthor_trace.h
blob: bd8652549ab4634f03cf7ce727dd1840798895c3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/* SPDX-License-Identifier: GPL-2.0 or MIT */
/* Copyright 2025 Collabora ltd. */

#undef TRACE_SYSTEM
#define TRACE_SYSTEM panthor

#if !defined(__PANTHOR_TRACE_H__) || defined(TRACE_HEADER_MULTI_READ)
#define __PANTHOR_TRACE_H__

#include <linux/tracepoint.h>
#include <linux/types.h>

#include "panthor_hw.h"

/**
 * gpu_power_status - called whenever parts of GPU hardware are turned on or off
 * @dev: pointer to the &struct device, for printing the device name
 * @shader_bitmap: bitmap where a high bit indicates the shader core at a given
 *                 bit index is on, and a low bit indicates a shader core is
 *                 either powered off or absent
 * @tiler_bitmap: bitmap where a high bit indicates the tiler unit at a given
 *                bit index is on, and a low bit indicates a tiler unit is
 *                either powered off or absent
 * @l2_bitmap: bitmap where a high bit indicates the L2 cache at a given bit
 *             index is on, and a low bit indicates the L2 cache is either
 *             powered off or absent
 */
TRACE_EVENT_FN(gpu_power_status,
	TP_PROTO(const struct device *dev, u64 shader_bitmap, u64 tiler_bitmap,
		 u64 l2_bitmap),
	TP_ARGS(dev, shader_bitmap, tiler_bitmap, l2_bitmap),
	TP_STRUCT__entry(
		__string(dev_name, dev_name(dev))
		__field(u64, shader_bitmap)
		__field(u64, tiler_bitmap)
		__field(u64, l2_bitmap)
	),
	TP_fast_assign(
		__assign_str(dev_name);
		__entry->shader_bitmap	= shader_bitmap;
		__entry->tiler_bitmap	= tiler_bitmap;
		__entry->l2_bitmap	= l2_bitmap;
	),
	TP_printk("%s: shader_bitmap=0x%llx tiler_bitmap=0x%llx l2_bitmap=0x%llx",
		  __get_str(dev_name), __entry->shader_bitmap, __entry->tiler_bitmap,
		  __entry->l2_bitmap
	),
	panthor_hw_power_status_register, panthor_hw_power_status_unregister
);

/**
 * gpu_job_irq - called after a job interrupt from firmware completes
 * @dev: pointer to the &struct device, for printing the device name
 * @events: bitmask of BIT(CSG id) | BIT(31) for a global event
 * @duration_ns: Nanoseconds between job IRQ handler entry and exit
 *
 * The panthor_job_irq_handler() function instrumented by this tracepoint exits
 * once it has queued the firmware interrupts for processing, not when the
 * firmware interrupts are fully processed. This tracepoint allows for debugging
 * issues with delays in the workqueue's processing of events.
 */
TRACE_EVENT(gpu_job_irq,
	TP_PROTO(const struct device *dev, u32 events, u32 duration_ns),
	TP_ARGS(dev, events, duration_ns),
	TP_STRUCT__entry(
		__string(dev_name, dev_name(dev))
		__field(u32, events)
		__field(u32, duration_ns)
	),
	TP_fast_assign(
		__assign_str(dev_name);
		__entry->events		= events;
		__entry->duration_ns	= duration_ns;
	),
	TP_printk("%s: events=0x%x duration_ns=%d", __get_str(dev_name),
		  __entry->events, __entry->duration_ns)
);

/**
 * gpu_cache_flush - emitted after cache flush completes
 * @dev: pointer to the &struct device, for printing the device name
 * @l2: "l2" flush flags
 * @lsc: "lsc" flush flags
 * @other: "other" flush flags
 * @duration_ns: how long the cache flush operation took, in nanoseconds
 * @ret: return status, 0 == success, negative errno on error
 *
 * Begins measuring after any initial lock contention around the locks needed
 * for flushing caches, but before the actual cache flush is requested. Stops
 * measuring and is emitted after flush operation is over.
 */
TRACE_EVENT(gpu_cache_flush,
	    TP_PROTO(const struct device *dev, u32 l2, u32 lsc, u32 other,
		     u32 duration_ns, int ret),
	    TP_ARGS(dev, l2, lsc, other, duration_ns, ret),
	    TP_STRUCT__entry(
		    __string(dev_name, dev_name(dev))
		    __field(u32, l2)
		    __field(u32, lsc)
		    __field(u32, other)
		    __field(u32, duration_ns)
		    __field(int, ret)
	    ),
	    TP_fast_assign(
		    __assign_str(dev_name);
		    __entry->l2          = l2;
		    __entry->lsc         = lsc;
		    __entry->other       = other;
		    __entry->duration_ns = duration_ns;
		    __entry->ret         = ret;
	    ),
	    TP_printk("%s: l2=0x%x lsc=0x%x other=0x%x duration_ns=%u ret=%d",
		      __get_str(dev_name), __entry->l2, __entry->lsc,
		      __entry->other, __entry->duration_ns, __entry->ret)
);

#endif /* __PANTHOR_TRACE_H__ */

#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH .
#undef TRACE_INCLUDE_FILE
#define TRACE_INCLUDE_FILE panthor_trace

#include <trace/define_trace.h>