1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * amd-pstate-trace.h - AMD Processor P-state Frequency Driver Tracer
4 *
5 * Copyright (C) 2021 Advanced Micro Devices, Inc. All Rights Reserved.
6 *
7 * Author: Huang Rui <ray.huang@amd.com>
8 */
9
10#if !defined(_AMD_PSTATE_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
11#define _AMD_PSTATE_TRACE_H
12
13#include <linux/cpufreq.h>
14#include <linux/tracepoint.h>
15#include <linux/trace_events.h>
16
17#undef TRACE_SYSTEM
18#define TRACE_SYSTEM amd_cpu
19
20#undef TRACE_INCLUDE_FILE
21#define TRACE_INCLUDE_FILE amd-pstate-trace
22
23#define TPS(x) tracepoint_string(x)
24
25TRACE_EVENT(amd_pstate_perf,
26
27 TP_PROTO(u8 min_perf,
28 u8 target_perf,
29 u8 capacity,
30 u64 freq,
31 u64 mperf,
32 u64 aperf,
33 u64 tsc,
34 unsigned int cpu_id,
35 bool fast_switch
36 ),
37
38 TP_ARGS(min_perf,
39 target_perf,
40 capacity,
41 freq,
42 mperf,
43 aperf,
44 tsc,
45 cpu_id,
46 fast_switch
47 ),
48
49 TP_STRUCT__entry(
50 __field(u8, min_perf)
51 __field(u8, target_perf)
52 __field(u8, capacity)
53 __field(unsigned long long, freq)
54 __field(unsigned long long, mperf)
55 __field(unsigned long long, aperf)
56 __field(unsigned long long, tsc)
57 __field(unsigned int, cpu_id)
58 __field(bool, fast_switch)
59 ),
60
61 TP_fast_assign(
62 __entry->min_perf = min_perf;
63 __entry->target_perf = target_perf;
64 __entry->capacity = capacity;
65 __entry->freq = freq;
66 __entry->mperf = mperf;
67 __entry->aperf = aperf;
68 __entry->tsc = tsc;
69 __entry->cpu_id = cpu_id;
70 __entry->fast_switch = fast_switch;
71 ),
72
73 TP_printk("amd_min_perf=%hhu amd_des_perf=%hhu amd_max_perf=%hhu freq=%llu mperf=%llu aperf=%llu tsc=%llu cpu_id=%u fast_switch=%s",
74 (u8)__entry->min_perf,
75 (u8)__entry->target_perf,
76 (u8)__entry->capacity,
77 (unsigned long long)__entry->freq,
78 (unsigned long long)__entry->mperf,
79 (unsigned long long)__entry->aperf,
80 (unsigned long long)__entry->tsc,
81 (unsigned int)__entry->cpu_id,
82 (__entry->fast_switch) ? "true" : "false"
83 )
84);
85
86TRACE_EVENT(amd_pstate_epp_perf,
87
88 TP_PROTO(unsigned int cpu_id,
89 u8 highest_perf,
90 u8 epp,
91 u8 min_perf,
92 u8 max_perf,
93 bool boost,
94 bool changed
95 ),
96
97 TP_ARGS(cpu_id,
98 highest_perf,
99 epp,
100 min_perf,
101 max_perf,
102 boost,
103 changed),
104
105 TP_STRUCT__entry(
106 __field(unsigned int, cpu_id)
107 __field(u8, highest_perf)
108 __field(u8, epp)
109 __field(u8, min_perf)
110 __field(u8, max_perf)
111 __field(bool, boost)
112 __field(bool, changed)
113 ),
114
115 TP_fast_assign(
116 __entry->cpu_id = cpu_id;
117 __entry->highest_perf = highest_perf;
118 __entry->epp = epp;
119 __entry->min_perf = min_perf;
120 __entry->max_perf = max_perf;
121 __entry->boost = boost;
122 __entry->changed = changed;
123 ),
124
125 TP_printk("cpu%u: [%hhu<->%hhu]/%hhu, epp=%hhu, boost=%u, changed=%u",
126 (unsigned int)__entry->cpu_id,
127 (u8)__entry->min_perf,
128 (u8)__entry->max_perf,
129 (u8)__entry->highest_perf,
130 (u8)__entry->epp,
131 (bool)__entry->boost,
132 (bool)__entry->changed
133 )
134);
135
136#endif /* _AMD_PSTATE_TRACE_H */
137
138/* This part must be outside protection */
139#undef TRACE_INCLUDE_PATH
140#define TRACE_INCLUDE_PATH .
141
142#include <trace/define_trace.h>
143