1 /* SPDX-License-Identifier: GPL-2.0 */ 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #undef TRACE_SYSTEM 2 #undef TRACE_SYSTEM 3 #define TRACE_SYSTEM spi 3 #define TRACE_SYSTEM spi 4 4 5 #if !defined(_TRACE_SPI_H) || defined(TRACE_HE 5 #if !defined(_TRACE_SPI_H) || defined(TRACE_HEADER_MULTI_READ) 6 #define _TRACE_SPI_H 6 #define _TRACE_SPI_H 7 7 8 #include <linux/ktime.h> 8 #include <linux/ktime.h> 9 #include <linux/tracepoint.h> 9 #include <linux/tracepoint.h> 10 10 11 DECLARE_EVENT_CLASS(spi_controller, 11 DECLARE_EVENT_CLASS(spi_controller, 12 12 13 TP_PROTO(struct spi_controller *contro 13 TP_PROTO(struct spi_controller *controller), 14 14 15 TP_ARGS(controller), 15 TP_ARGS(controller), 16 16 17 TP_STRUCT__entry( 17 TP_STRUCT__entry( 18 __field( int, 18 __field( int, bus_num ) 19 ), 19 ), 20 20 21 TP_fast_assign( 21 TP_fast_assign( 22 __entry->bus_num = controller- 22 __entry->bus_num = controller->bus_num; 23 ), 23 ), 24 24 25 TP_printk("spi%d", (int)__entry->bus_n 25 TP_printk("spi%d", (int)__entry->bus_num) 26 26 27 ); 27 ); 28 28 29 DEFINE_EVENT(spi_controller, spi_controller_id 29 DEFINE_EVENT(spi_controller, spi_controller_idle, 30 30 31 TP_PROTO(struct spi_controller *contro 31 TP_PROTO(struct spi_controller *controller), 32 32 33 TP_ARGS(controller) 33 TP_ARGS(controller) 34 34 35 ); 35 ); 36 36 37 DEFINE_EVENT(spi_controller, spi_controller_bu 37 DEFINE_EVENT(spi_controller, spi_controller_busy, 38 38 39 TP_PROTO(struct spi_controller *contro 39 TP_PROTO(struct spi_controller *controller), 40 40 41 TP_ARGS(controller) 41 TP_ARGS(controller) 42 42 43 ); 43 ); 44 44 45 TRACE_EVENT(spi_setup, 45 TRACE_EVENT(spi_setup, 46 TP_PROTO(struct spi_device *spi, int s 46 TP_PROTO(struct spi_device *spi, int status), 47 TP_ARGS(spi, status), 47 TP_ARGS(spi, status), 48 48 49 TP_STRUCT__entry( 49 TP_STRUCT__entry( 50 __field(int, bus_num) 50 __field(int, bus_num) 51 __field(int, chip_select) 51 __field(int, chip_select) 52 __field(unsigned long, mode) 52 __field(unsigned long, mode) 53 __field(unsigned int, bits_per 53 __field(unsigned int, bits_per_word) 54 __field(unsigned int, max_spee 54 __field(unsigned int, max_speed_hz) 55 __field(int, status) 55 __field(int, status) 56 ), 56 ), 57 57 58 TP_fast_assign( 58 TP_fast_assign( 59 __entry->bus_num = spi->contro 59 __entry->bus_num = spi->controller->bus_num; 60 __entry->chip_select = spi_ge 60 __entry->chip_select = spi_get_chipselect(spi, 0); 61 __entry->mode = spi->mode; 61 __entry->mode = spi->mode; 62 __entry->bits_per_word = spi-> 62 __entry->bits_per_word = spi->bits_per_word; 63 __entry->max_speed_hz = spi->m 63 __entry->max_speed_hz = spi->max_speed_hz; 64 __entry->status = status; 64 __entry->status = status; 65 ), 65 ), 66 66 67 TP_printk("spi%d.%d setup mode %lu, %s 67 TP_printk("spi%d.%d setup mode %lu, %s%s%s%s%u bits/w, %u Hz max --> %d", 68 __entry->bus_num, __entry->c 68 __entry->bus_num, __entry->chip_select, 69 (__entry->mode & SPI_MODE_X_ 69 (__entry->mode & SPI_MODE_X_MASK), 70 (__entry->mode & SPI_CS_HIGH 70 (__entry->mode & SPI_CS_HIGH) ? "cs_high, " : "", 71 (__entry->mode & SPI_LSB_FIR 71 (__entry->mode & SPI_LSB_FIRST) ? "lsb, " : "", 72 (__entry->mode & SPI_3WIRE) 72 (__entry->mode & SPI_3WIRE) ? "3wire, " : "", 73 (__entry->mode & SPI_LOOP) ? 73 (__entry->mode & SPI_LOOP) ? "loopback, " : "", 74 __entry->bits_per_word, __en 74 __entry->bits_per_word, __entry->max_speed_hz, 75 __entry->status) 75 __entry->status) 76 ); 76 ); 77 77 78 TRACE_EVENT(spi_set_cs, 78 TRACE_EVENT(spi_set_cs, 79 TP_PROTO(struct spi_device *spi, bool 79 TP_PROTO(struct spi_device *spi, bool enable), 80 TP_ARGS(spi, enable), 80 TP_ARGS(spi, enable), 81 81 82 TP_STRUCT__entry( 82 TP_STRUCT__entry( 83 __field(int, bus_num) 83 __field(int, bus_num) 84 __field(int, chip_select) 84 __field(int, chip_select) 85 __field(unsigned long, mode) 85 __field(unsigned long, mode) 86 __field(bool, enable) 86 __field(bool, enable) 87 ), 87 ), 88 88 89 TP_fast_assign( 89 TP_fast_assign( 90 __entry->bus_num = spi->contro 90 __entry->bus_num = spi->controller->bus_num; 91 __entry->chip_select = spi_get 91 __entry->chip_select = spi_get_chipselect(spi, 0); 92 __entry->mode = spi->mode; 92 __entry->mode = spi->mode; 93 __entry->enable = enable; 93 __entry->enable = enable; 94 ), 94 ), 95 95 96 TP_printk("spi%d.%d %s%s", 96 TP_printk("spi%d.%d %s%s", 97 __entry->bus_num, __entry->c 97 __entry->bus_num, __entry->chip_select, 98 __entry->enable ? "activate" 98 __entry->enable ? "activate" : "deactivate", 99 (__entry->mode & SPI_CS_HIGH 99 (__entry->mode & SPI_CS_HIGH) ? ", cs_high" : "") 100 ); 100 ); 101 101 102 DECLARE_EVENT_CLASS(spi_message, 102 DECLARE_EVENT_CLASS(spi_message, 103 103 104 TP_PROTO(struct spi_message *msg), 104 TP_PROTO(struct spi_message *msg), 105 105 106 TP_ARGS(msg), 106 TP_ARGS(msg), 107 107 108 TP_STRUCT__entry( 108 TP_STRUCT__entry( 109 __field( int, 109 __field( int, bus_num ) 110 __field( int, 110 __field( int, chip_select ) 111 __field( struct spi_mes 111 __field( struct spi_message *, msg ) 112 ), 112 ), 113 113 114 TP_fast_assign( 114 TP_fast_assign( 115 __entry->bus_num = msg->spi->c 115 __entry->bus_num = msg->spi->controller->bus_num; 116 __entry->chip_select = spi_get 116 __entry->chip_select = spi_get_chipselect(msg->spi, 0); 117 __entry->msg = msg; 117 __entry->msg = msg; 118 ), 118 ), 119 119 120 TP_printk("spi%d.%d %p", (int)__entry- 120 TP_printk("spi%d.%d %p", (int)__entry->bus_num, 121 (int)__entry->chip_select, 121 (int)__entry->chip_select, 122 (struct spi_message *)__entr 122 (struct spi_message *)__entry->msg) 123 ); 123 ); 124 124 125 DEFINE_EVENT(spi_message, spi_message_submit, 125 DEFINE_EVENT(spi_message, spi_message_submit, 126 126 127 TP_PROTO(struct spi_message *msg), 127 TP_PROTO(struct spi_message *msg), 128 128 129 TP_ARGS(msg) 129 TP_ARGS(msg) 130 130 131 ); 131 ); 132 132 133 DEFINE_EVENT(spi_message, spi_message_start, 133 DEFINE_EVENT(spi_message, spi_message_start, 134 134 135 TP_PROTO(struct spi_message *msg), 135 TP_PROTO(struct spi_message *msg), 136 136 137 TP_ARGS(msg) 137 TP_ARGS(msg) 138 138 139 ); 139 ); 140 140 141 TRACE_EVENT(spi_message_done, 141 TRACE_EVENT(spi_message_done, 142 142 143 TP_PROTO(struct spi_message *msg), 143 TP_PROTO(struct spi_message *msg), 144 144 145 TP_ARGS(msg), 145 TP_ARGS(msg), 146 146 147 TP_STRUCT__entry( 147 TP_STRUCT__entry( 148 __field( int, 148 __field( int, bus_num ) 149 __field( int, 149 __field( int, chip_select ) 150 __field( struct spi_mes 150 __field( struct spi_message *, msg ) 151 __field( unsigned, 151 __field( unsigned, frame ) 152 __field( unsigned, 152 __field( unsigned, actual ) 153 ), 153 ), 154 154 155 TP_fast_assign( 155 TP_fast_assign( 156 __entry->bus_num = msg->spi->c 156 __entry->bus_num = msg->spi->controller->bus_num; 157 __entry->chip_select = spi_get 157 __entry->chip_select = spi_get_chipselect(msg->spi, 0); 158 __entry->msg = msg; 158 __entry->msg = msg; 159 __entry->frame = msg->frame_le 159 __entry->frame = msg->frame_length; 160 __entry->actual = msg->actual_ 160 __entry->actual = msg->actual_length; 161 ), 161 ), 162 162 163 TP_printk("spi%d.%d %p len=%u/%u", (in 163 TP_printk("spi%d.%d %p len=%u/%u", (int)__entry->bus_num, 164 (int)__entry->chip_select, 164 (int)__entry->chip_select, 165 (struct spi_message *)__entr 165 (struct spi_message *)__entry->msg, 166 (unsigned)__entry->actual, ( 166 (unsigned)__entry->actual, (unsigned)__entry->frame) 167 ); 167 ); 168 168 169 /* 169 /* 170 * Consider a buffer valid if non-NULL and if !! 170 * consider a buffer valid if non-NULL and if it doesn't match the dummy buffer 171 * that only exist to work with controllers th 171 * that only exist to work with controllers that have SPI_CONTROLLER_MUST_TX or 172 * SPI_CONTROLLER_MUST_RX. 172 * SPI_CONTROLLER_MUST_RX. 173 */ 173 */ 174 #define spi_valid_txbuf(msg, xfer) \ 174 #define spi_valid_txbuf(msg, xfer) \ 175 (xfer->tx_buf && xfer->tx_buf != msg-> 175 (xfer->tx_buf && xfer->tx_buf != msg->spi->controller->dummy_tx) 176 #define spi_valid_rxbuf(msg, xfer) \ 176 #define spi_valid_rxbuf(msg, xfer) \ 177 (xfer->rx_buf && xfer->rx_buf != msg-> 177 (xfer->rx_buf && xfer->rx_buf != msg->spi->controller->dummy_rx) 178 178 179 DECLARE_EVENT_CLASS(spi_transfer, 179 DECLARE_EVENT_CLASS(spi_transfer, 180 180 181 TP_PROTO(struct spi_message *msg, stru 181 TP_PROTO(struct spi_message *msg, struct spi_transfer *xfer), 182 182 183 TP_ARGS(msg, xfer), 183 TP_ARGS(msg, xfer), 184 184 185 TP_STRUCT__entry( 185 TP_STRUCT__entry( 186 __field( int, 186 __field( int, bus_num ) 187 __field( int, 187 __field( int, chip_select ) 188 __field( struct spi_tra 188 __field( struct spi_transfer *, xfer ) 189 __field( int, 189 __field( int, len ) 190 __dynamic_array(u8, rx_buf, 190 __dynamic_array(u8, rx_buf, 191 spi_valid_rxbu 191 spi_valid_rxbuf(msg, xfer) ? 192 (xfer- 192 (xfer->len < 64 ? xfer->len : 64) : 0) 193 __dynamic_array(u8, tx_buf, 193 __dynamic_array(u8, tx_buf, 194 spi_valid_txbu 194 spi_valid_txbuf(msg, xfer) ? 195 (xfer- 195 (xfer->len < 64 ? xfer->len : 64) : 0) 196 ), 196 ), 197 197 198 TP_fast_assign( 198 TP_fast_assign( 199 __entry->bus_num = msg->spi->c 199 __entry->bus_num = msg->spi->controller->bus_num; 200 __entry->chip_select = spi_get 200 __entry->chip_select = spi_get_chipselect(msg->spi, 0); 201 __entry->xfer = xfer; 201 __entry->xfer = xfer; 202 __entry->len = xfer->len; 202 __entry->len = xfer->len; 203 203 204 if (spi_valid_txbuf(msg, xfer) 204 if (spi_valid_txbuf(msg, xfer)) 205 memcpy(__get_dynamic_a 205 memcpy(__get_dynamic_array(tx_buf), 206 xfer->tx_buf, _ 206 xfer->tx_buf, __get_dynamic_array_len(tx_buf)); 207 207 208 if (spi_valid_rxbuf(msg, xfer) 208 if (spi_valid_rxbuf(msg, xfer)) 209 memcpy(__get_dynamic_a 209 memcpy(__get_dynamic_array(rx_buf), 210 xfer->rx_buf, _ 210 xfer->rx_buf, __get_dynamic_array_len(rx_buf)); 211 ), 211 ), 212 212 213 TP_printk("spi%d.%d %p len=%d tx=[%*ph 213 TP_printk("spi%d.%d %p len=%d tx=[%*phD] rx=[%*phD]", 214 __entry->bus_num, __entry->c 214 __entry->bus_num, __entry->chip_select, 215 __entry->xfer, __entry->len, 215 __entry->xfer, __entry->len, 216 __get_dynamic_array_len(tx_b 216 __get_dynamic_array_len(tx_buf), __get_dynamic_array(tx_buf), 217 __get_dynamic_array_len(rx_b 217 __get_dynamic_array_len(rx_buf), __get_dynamic_array(rx_buf)) 218 ); 218 ); 219 219 220 DEFINE_EVENT(spi_transfer, spi_transfer_start, 220 DEFINE_EVENT(spi_transfer, spi_transfer_start, 221 221 222 TP_PROTO(struct spi_message *msg, stru 222 TP_PROTO(struct spi_message *msg, struct spi_transfer *xfer), 223 223 224 TP_ARGS(msg, xfer) 224 TP_ARGS(msg, xfer) 225 225 226 ); 226 ); 227 227 228 DEFINE_EVENT(spi_transfer, spi_transfer_stop, 228 DEFINE_EVENT(spi_transfer, spi_transfer_stop, 229 229 230 TP_PROTO(struct spi_message *msg, stru 230 TP_PROTO(struct spi_message *msg, struct spi_transfer *xfer), 231 231 232 TP_ARGS(msg, xfer) 232 TP_ARGS(msg, xfer) 233 233 234 ); 234 ); 235 235 236 #endif /* _TRACE_POWER_H */ 236 #endif /* _TRACE_POWER_H */ 237 237 238 /* This part must be outside protection */ 238 /* This part must be outside protection */ 239 #include <trace/define_trace.h> 239 #include <trace/define_trace.h> 240 240
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.