^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #undef TRACE_SYSTEM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define TRACE_SYSTEM spi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #if !defined(_TRACE_SPI_H) || defined(TRACE_HEADER_MULTI_READ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #define _TRACE_SPI_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/ktime.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/tracepoint.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) DECLARE_EVENT_CLASS(spi_controller,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) TP_PROTO(struct spi_controller *controller),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) TP_ARGS(controller),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) TP_STRUCT__entry(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) __field( int, bus_num )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) ),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) TP_fast_assign(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) __entry->bus_num = controller->bus_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) ),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) TP_printk("spi%d", (int)__entry->bus_num)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) DEFINE_EVENT(spi_controller, spi_controller_idle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) TP_PROTO(struct spi_controller *controller),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) TP_ARGS(controller)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) DEFINE_EVENT(spi_controller, spi_controller_busy,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) TP_PROTO(struct spi_controller *controller),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) TP_ARGS(controller)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) DECLARE_EVENT_CLASS(spi_message,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) TP_PROTO(struct spi_message *msg),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) TP_ARGS(msg),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) TP_STRUCT__entry(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) __field( int, bus_num )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) __field( int, chip_select )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) __field( struct spi_message *, msg )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) ),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) TP_fast_assign(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) __entry->bus_num = msg->spi->controller->bus_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) __entry->chip_select = msg->spi->chip_select;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) __entry->msg = msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) ),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) TP_printk("spi%d.%d %p", (int)__entry->bus_num,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) (int)__entry->chip_select,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) (struct spi_message *)__entry->msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) DEFINE_EVENT(spi_message, spi_message_submit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) TP_PROTO(struct spi_message *msg),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) TP_ARGS(msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) DEFINE_EVENT(spi_message, spi_message_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) TP_PROTO(struct spi_message *msg),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) TP_ARGS(msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) TRACE_EVENT(spi_message_done,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) TP_PROTO(struct spi_message *msg),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) TP_ARGS(msg),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) TP_STRUCT__entry(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) __field( int, bus_num )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) __field( int, chip_select )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) __field( struct spi_message *, msg )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) __field( unsigned, frame )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) __field( unsigned, actual )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) ),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) TP_fast_assign(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) __entry->bus_num = msg->spi->controller->bus_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) __entry->chip_select = msg->spi->chip_select;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) __entry->msg = msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) __entry->frame = msg->frame_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) __entry->actual = msg->actual_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) ),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) TP_printk("spi%d.%d %p len=%u/%u", (int)__entry->bus_num,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) (int)__entry->chip_select,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) (struct spi_message *)__entry->msg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) (unsigned)__entry->actual, (unsigned)__entry->frame)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) * consider a buffer valid if non-NULL and if it doesn't match the dummy buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) * that only exist to work with controllers that have SPI_CONTROLLER_MUST_TX or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) * SPI_CONTROLLER_MUST_RX.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) #define spi_valid_txbuf(msg, xfer) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) (xfer->tx_buf && xfer->tx_buf != msg->spi->controller->dummy_tx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) #define spi_valid_rxbuf(msg, xfer) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) (xfer->rx_buf && xfer->rx_buf != msg->spi->controller->dummy_rx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) DECLARE_EVENT_CLASS(spi_transfer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) TP_PROTO(struct spi_message *msg, struct spi_transfer *xfer),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) TP_ARGS(msg, xfer),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) TP_STRUCT__entry(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) __field( int, bus_num )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) __field( int, chip_select )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) __field( struct spi_transfer *, xfer )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) __field( int, len )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) __dynamic_array(u8, rx_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) spi_valid_rxbuf(msg, xfer) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) (xfer->len < 64 ? xfer->len : 64) : 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) __dynamic_array(u8, tx_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) spi_valid_txbuf(msg, xfer) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) (xfer->len < 64 ? xfer->len : 64) : 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) ),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) TP_fast_assign(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) __entry->bus_num = msg->spi->controller->bus_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) __entry->chip_select = msg->spi->chip_select;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) __entry->xfer = xfer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) __entry->len = xfer->len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) if (spi_valid_txbuf(msg, xfer))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) memcpy(__get_dynamic_array(tx_buf),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) xfer->tx_buf, __get_dynamic_array_len(tx_buf));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) if (spi_valid_rxbuf(msg, xfer))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) memcpy(__get_dynamic_array(rx_buf),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) xfer->rx_buf, __get_dynamic_array_len(rx_buf));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) ),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) TP_printk("spi%d.%d %p len=%d tx=[%*phD] rx=[%*phD]",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) __entry->bus_num, __entry->chip_select,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) __entry->xfer, __entry->len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) __get_dynamic_array_len(tx_buf), __get_dynamic_array(tx_buf),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) __get_dynamic_array_len(rx_buf), __get_dynamic_array(rx_buf))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) DEFINE_EVENT(spi_transfer, spi_transfer_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) TP_PROTO(struct spi_message *msg, struct spi_transfer *xfer),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) TP_ARGS(msg, xfer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) DEFINE_EVENT(spi_transfer, spi_transfer_stop,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) TP_PROTO(struct spi_message *msg, struct spi_transfer *xfer),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) TP_ARGS(msg, xfer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) #endif /* _TRACE_POWER_H */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) /* This part must be outside protection */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) #include <trace/define_trace.h>