| 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* |
| 3 | * Copyright © 2024 Intel Corporation |
| 4 | */ |
| 5 | |
| 6 | #undef TRACE_SYSTEM |
| 7 | #define TRACE_SYSTEM xe |
| 8 | |
| 9 | #if !defined(_XE_TRACE_GUC_H_) || defined(TRACE_HEADER_MULTI_READ) |
| 10 | #define _XE_TRACE_GUC_H_ |
| 11 | |
| 12 | #include <linux/tracepoint.h> |
| 13 | #include <linux/types.h> |
| 14 | |
| 15 | #include "xe_device_types.h" |
| 16 | #include "xe_guc_exec_queue_types.h" |
| 17 | #include "xe_guc_engine_activity_types.h" |
| 18 | |
| 19 | #define __dev_name_xe(xe) dev_name((xe)->drm.dev) |
| 20 | |
| 21 | DECLARE_EVENT_CLASS(xe_guc_ct_flow_control, |
| 22 | TP_PROTO(struct xe_device *xe, u32 _head, u32 _tail, u32 size, u32 space, u32 len), |
| 23 | TP_ARGS(xe, _head, _tail, size, space, len), |
| 24 | |
| 25 | TP_STRUCT__entry( |
| 26 | __string(dev, __dev_name_xe(xe)) |
| 27 | __field(u32, _head) |
| 28 | __field(u32, _tail) |
| 29 | __field(u32, size) |
| 30 | __field(u32, space) |
| 31 | __field(u32, len) |
| 32 | ), |
| 33 | |
| 34 | TP_fast_assign( |
| 35 | __assign_str(dev); |
| 36 | __entry->_head = _head; |
| 37 | __entry->_tail = _tail; |
| 38 | __entry->size = size; |
| 39 | __entry->space = space; |
| 40 | __entry->len = len; |
| 41 | ), |
| 42 | |
| 43 | TP_printk("h2g flow control: dev=%s, head=%u, tail=%u, size=%u, space=%u, len=%u" , |
| 44 | __get_str(dev), __entry->_head, __entry->_tail, __entry->size, |
| 45 | __entry->space, __entry->len) |
| 46 | ); |
| 47 | |
| 48 | DEFINE_EVENT(xe_guc_ct_flow_control, xe_guc_ct_h2g_flow_control, |
| 49 | TP_PROTO(struct xe_device *xe, u32 _head, u32 _tail, u32 size, u32 space, u32 len), |
| 50 | TP_ARGS(xe, _head, _tail, size, space, len) |
| 51 | ); |
| 52 | |
| 53 | DEFINE_EVENT_PRINT(xe_guc_ct_flow_control, xe_guc_ct_g2h_flow_control, |
| 54 | TP_PROTO(struct xe_device *xe, u32 _head, u32 _tail, u32 size, u32 space, u32 len), |
| 55 | TP_ARGS(xe, _head, _tail, size, space, len), |
| 56 | |
| 57 | TP_printk("g2h flow control: dev=%s, head=%u, tail=%u, size=%u, space=%u, len=%u" , |
| 58 | __get_str(dev), __entry->_head, __entry->_tail, __entry->size, |
| 59 | __entry->space, __entry->len) |
| 60 | ); |
| 61 | |
| 62 | DECLARE_EVENT_CLASS(xe_guc_ctb, |
| 63 | TP_PROTO(struct xe_device *xe, u8 gt_id, u32 action, u32 len, u32 _head, u32 tail), |
| 64 | TP_ARGS(xe, gt_id, action, len, _head, tail), |
| 65 | |
| 66 | TP_STRUCT__entry( |
| 67 | __string(dev, __dev_name_xe(xe)) |
| 68 | __field(u8, gt_id) |
| 69 | __field(u32, action) |
| 70 | __field(u32, len) |
| 71 | __field(u32, tail) |
| 72 | __field(u32, _head) |
| 73 | ), |
| 74 | |
| 75 | TP_fast_assign( |
| 76 | __assign_str(dev); |
| 77 | __entry->gt_id = gt_id; |
| 78 | __entry->action = action; |
| 79 | __entry->len = len; |
| 80 | __entry->tail = tail; |
| 81 | __entry->_head = _head; |
| 82 | ), |
| 83 | |
| 84 | TP_printk("H2G CTB: dev=%s, gt%d: action=0x%x, len=%d, tail=%d, head=%d\n" , |
| 85 | __get_str(dev), __entry->gt_id, __entry->action, __entry->len, |
| 86 | __entry->tail, __entry->_head) |
| 87 | ); |
| 88 | |
| 89 | DEFINE_EVENT(xe_guc_ctb, xe_guc_ctb_h2g, |
| 90 | TP_PROTO(struct xe_device *xe, u8 gt_id, u32 action, u32 len, u32 _head, u32 tail), |
| 91 | TP_ARGS(xe, gt_id, action, len, _head, tail) |
| 92 | ); |
| 93 | |
| 94 | DEFINE_EVENT_PRINT(xe_guc_ctb, xe_guc_ctb_g2h, |
| 95 | TP_PROTO(struct xe_device *xe, u8 gt_id, u32 action, u32 len, u32 _head, u32 tail), |
| 96 | TP_ARGS(xe, gt_id, action, len, _head, tail), |
| 97 | |
| 98 | TP_printk("G2H CTB: dev=%s, gt%d: action=0x%x, len=%d, tail=%d, head=%d\n" , |
| 99 | __get_str(dev), __entry->gt_id, __entry->action, __entry->len, |
| 100 | __entry->tail, __entry->_head) |
| 101 | |
| 102 | ); |
| 103 | |
| 104 | TRACE_EVENT(xe_guc_engine_activity, |
| 105 | TP_PROTO(struct xe_device *xe, struct engine_activity *ea, const char *name, |
| 106 | u16 instance), |
| 107 | TP_ARGS(xe, ea, name, instance), |
| 108 | |
| 109 | TP_STRUCT__entry( |
| 110 | __string(dev, __dev_name_xe(xe)) |
| 111 | __string(name, name) |
| 112 | __field(u32, global_change_num) |
| 113 | __field(u32, guc_tsc_frequency_hz) |
| 114 | __field(u32, lag_latency_usec) |
| 115 | __field(u16, instance) |
| 116 | __field(u16, change_num) |
| 117 | __field(u16, quanta_ratio) |
| 118 | __field(u32, last_update_tick) |
| 119 | __field(u64, active_ticks) |
| 120 | __field(u64, active) |
| 121 | __field(u64, total) |
| 122 | __field(u64, quanta) |
| 123 | __field(u64, last_cpu_ts) |
| 124 | ), |
| 125 | |
| 126 | TP_fast_assign( |
| 127 | __assign_str(dev); |
| 128 | __assign_str(name); |
| 129 | __entry->global_change_num = ea->metadata.global_change_num; |
| 130 | __entry->guc_tsc_frequency_hz = ea->metadata.guc_tsc_frequency_hz; |
| 131 | __entry->lag_latency_usec = ea->metadata.lag_latency_usec; |
| 132 | __entry->instance = instance; |
| 133 | __entry->change_num = ea->activity.change_num; |
| 134 | __entry->quanta_ratio = ea->activity.quanta_ratio; |
| 135 | __entry->last_update_tick = ea->activity.last_update_tick; |
| 136 | __entry->active_ticks = ea->activity.active_ticks; |
| 137 | __entry->active = ea->active; |
| 138 | __entry->total = ea->total; |
| 139 | __entry->quanta = ea->quanta; |
| 140 | __entry->last_cpu_ts = ea->last_cpu_ts; |
| 141 | ), |
| 142 | |
| 143 | TP_printk("dev=%s engine %s:%d Active=%llu, quanta=%llu, last_cpu_ts=%llu\n" |
| 144 | "Activity metadata: global_change_num=%u, guc_tsc_frequency_hz=%u lag_latency_usec=%u\n" |
| 145 | "Activity data: change_num=%u, quanta_ratio=0x%x, last_update_tick=%u, active_ticks=%llu\n" , |
| 146 | __get_str(dev), __get_str(name), __entry->instance, |
| 147 | (__entry->active + __entry->total), __entry->quanta, __entry->last_cpu_ts, |
| 148 | __entry->global_change_num, __entry->guc_tsc_frequency_hz, |
| 149 | __entry->lag_latency_usec, __entry->change_num, __entry->quanta_ratio, |
| 150 | __entry->last_update_tick, __entry->active_ticks) |
| 151 | ); |
| 152 | #endif |
| 153 | |
| 154 | /* This part must be outside protection */ |
| 155 | #undef TRACE_INCLUDE_PATH |
| 156 | #undef TRACE_INCLUDE_FILE |
| 157 | #define TRACE_INCLUDE_PATH ../../drivers/gpu/drm/xe |
| 158 | #define TRACE_INCLUDE_FILE xe_trace_guc |
| 159 | #include <trace/define_trace.h> |
| 160 | |