1 /* SPDX-License-Identifier: GPL-2.0 2 * 3 * Copyright 2022-2023 HabanaLabs, Ltd. 4 * All Rights Reserved. 5 * 6 */ 7 8 #undef TRACE_SYSTEM 9 #define TRACE_SYSTEM habanalabs 10 11 #if !defined(_TRACE_HABANALABS_H) || defined(TRACE_HEADER_MULTI_READ) 12 #define _TRACE_HABANALABS_H 13 14 #include <linux/tracepoint.h> 15 16 DECLARE_EVENT_CLASS(habanalabs_mmu_template, 17 TP_PROTO(struct device *dev, u64 virt_addr, u64 phys_addr, u32 page_size, bool flush_pte), 18 19 TP_ARGS(dev, virt_addr, phys_addr, page_size, flush_pte), 20 21 TP_STRUCT__entry( 22 __string(dname, dev_name(dev)) 23 __field(u64, virt_addr) 24 __field(u64, phys_addr) 25 __field(u32, page_size) 26 __field(u8, flush_pte) 27 ), 28 29 TP_fast_assign( 30 __assign_str(dname); 31 __entry->virt_addr = virt_addr; 32 __entry->phys_addr = phys_addr; 33 __entry->page_size = page_size; 34 __entry->flush_pte = flush_pte; 35 ), 36 37 TP_printk("%s: vaddr: %#llx, paddr: %#llx, psize: %#x, flush: %s", 38 __get_str(dname), 39 __entry->virt_addr, 40 __entry->phys_addr, 41 __entry->page_size, 42 __entry->flush_pte ? "true" : "false") 43 ); 44 45 DEFINE_EVENT(habanalabs_mmu_template, habanalabs_mmu_map, 46 TP_PROTO(struct device *dev, u64 virt_addr, u64 phys_addr, u32 page_size, bool flush_pte), 47 TP_ARGS(dev, virt_addr, phys_addr, page_size, flush_pte)); 48 49 DEFINE_EVENT(habanalabs_mmu_template, habanalabs_mmu_unmap, 50 TP_PROTO(struct device *dev, u64 virt_addr, u64 phys_addr, u32 page_size, bool flush_pte), 51 TP_ARGS(dev, virt_addr, phys_addr, page_size, flush_pte)); 52 53 DECLARE_EVENT_CLASS(habanalabs_dma_alloc_template, 54 TP_PROTO(struct device *dev, u64 cpu_addr, u64 dma_addr, size_t size, const char *caller), 55 56 TP_ARGS(dev, cpu_addr, dma_addr, size, caller), 57 58 TP_STRUCT__entry( 59 __string(dname, dev_name(dev)) 60 __field(u64, cpu_addr) 61 __field(u64, dma_addr) 62 __field(u32, size) 63 __field(const char *, caller) 64 ), 65 66 TP_fast_assign( 67 __assign_str(dname); 68 __entry->cpu_addr = cpu_addr; 69 __entry->dma_addr = dma_addr; 70 __entry->size = size; 71 __entry->caller = caller; 72 ), 73 74 TP_printk("%s: cpu_addr: %#llx, dma_addr: %#llx, size: %#x, caller: %s", 75 __get_str(dname), 76 __entry->cpu_addr, 77 __entry->dma_addr, 78 __entry->size, 79 __entry->caller) 80 ); 81 82 DEFINE_EVENT(habanalabs_dma_alloc_template, habanalabs_dma_alloc, 83 TP_PROTO(struct device *dev, u64 cpu_addr, u64 dma_addr, size_t size, const char *caller), 84 TP_ARGS(dev, cpu_addr, dma_addr, size, caller)); 85 86 DEFINE_EVENT(habanalabs_dma_alloc_template, habanalabs_dma_free, 87 TP_PROTO(struct device *dev, u64 cpu_addr, u64 dma_addr, size_t size, const char *caller), 88 TP_ARGS(dev, cpu_addr, dma_addr, size, caller)); 89 90 DECLARE_EVENT_CLASS(habanalabs_dma_map_template, 91 TP_PROTO(struct device *dev, u64 phys_addr, u64 dma_addr, size_t len, 92 enum dma_data_direction dir, const char *caller), 93 94 TP_ARGS(dev, phys_addr, dma_addr, len, dir, caller), 95 96 TP_STRUCT__entry( 97 __string(dname, dev_name(dev)) 98 __field(u64, phys_addr) 99 __field(u64, dma_addr) 100 __field(u32, len) 101 __field(int, dir) 102 __field(const char *, caller) 103 ), 104 105 TP_fast_assign( 106 __assign_str(dname); 107 __entry->phys_addr = phys_addr; 108 __entry->dma_addr = dma_addr; 109 __entry->len = len; 110 __entry->dir = dir; 111 __entry->caller = caller; 112 ), 113 114 TP_printk("%s: phys_addr: %#llx, dma_addr: %#llx, len: %#x, dir: %d, caller: %s", 115 __get_str(dname), 116 __entry->phys_addr, 117 __entry->dma_addr, 118 __entry->len, 119 __entry->dir, 120 __entry->caller) 121 ); 122 123 DEFINE_EVENT(habanalabs_dma_map_template, habanalabs_dma_map_page, 124 TP_PROTO(struct device *dev, u64 phys_addr, u64 dma_addr, size_t len, 125 enum dma_data_direction dir, const char *caller), 126 TP_ARGS(dev, phys_addr, dma_addr, len, dir, caller)); 127 128 DEFINE_EVENT(habanalabs_dma_map_template, habanalabs_dma_unmap_page, 129 TP_PROTO(struct device *dev, u64 phys_addr, u64 dma_addr, size_t len, 130 enum dma_data_direction dir, const char *caller), 131 TP_ARGS(dev, phys_addr, dma_addr, len, dir, caller)); 132 133 DECLARE_EVENT_CLASS(habanalabs_comms_template, 134 TP_PROTO(struct device *dev, char *op_str), 135 136 TP_ARGS(dev, op_str), 137 138 TP_STRUCT__entry( 139 __string(dname, dev_name(dev)) 140 __field(char *, op_str) 141 ), 142 143 TP_fast_assign( 144 __assign_str(dname); 145 __entry->op_str = op_str; 146 ), 147 148 TP_printk("%s: cms: %s", 149 __get_str(dname), 150 __entry->op_str) 151 ); 152 153 DEFINE_EVENT(habanalabs_comms_template, habanalabs_comms_protocol_cmd, 154 TP_PROTO(struct device *dev, char *op_str), 155 TP_ARGS(dev, op_str)); 156 157 DEFINE_EVENT(habanalabs_comms_template, habanalabs_comms_send_cmd, 158 TP_PROTO(struct device *dev, char *op_str), 159 TP_ARGS(dev, op_str)); 160 161 DEFINE_EVENT(habanalabs_comms_template, habanalabs_comms_wait_status, 162 TP_PROTO(struct device *dev, char *op_str), 163 TP_ARGS(dev, op_str)); 164 165 DEFINE_EVENT(habanalabs_comms_template, habanalabs_comms_wait_status_done, 166 TP_PROTO(struct device *dev, char *op_str), 167 TP_ARGS(dev, op_str)); 168 169 DECLARE_EVENT_CLASS(habanalabs_reg_access_template, 170 TP_PROTO(struct device *dev, u32 addr, u32 val), 171 172 TP_ARGS(dev, addr, val), 173 174 TP_STRUCT__entry( 175 __string(dname, dev_name(dev)) 176 __field(u32, addr) 177 __field(u32, val) 178 ), 179 180 TP_fast_assign( 181 __assign_str(dname); 182 __entry->addr = addr; 183 __entry->val = val; 184 ), 185 186 TP_printk("%s: addr: %#x, val: %#x", 187 __get_str(dname), 188 __entry->addr, 189 __entry->val) 190 ); 191 192 DEFINE_EVENT(habanalabs_reg_access_template, habanalabs_rreg32, 193 TP_PROTO(struct device *dev, u32 addr, u32 val), 194 TP_ARGS(dev, addr, val)); 195 196 DEFINE_EVENT(habanalabs_reg_access_template, habanalabs_wreg32, 197 TP_PROTO(struct device *dev, u32 addr, u32 val), 198 TP_ARGS(dev, addr, val)); 199 200 DEFINE_EVENT(habanalabs_reg_access_template, habanalabs_elbi_read, 201 TP_PROTO(struct device *dev, u32 addr, u32 val), 202 TP_ARGS(dev, addr, val)); 203 204 DEFINE_EVENT(habanalabs_reg_access_template, habanalabs_elbi_write, 205 TP_PROTO(struct device *dev, u32 addr, u32 val), 206 TP_ARGS(dev, addr, val)); 207 208 #endif /* if !defined(_TRACE_HABANALABS_H) || defined(TRACE_HEADER_MULTI_READ) */ 209 210 /* This part must be outside protection */ 211 #include <trace/define_trace.h> 212