diff mbox series

spi/trace: Cap buffer contents at 64 bytes

Message ID 20190413204855.7819-1-noralf@tronnes.org (mailing list archive)
State Accepted
Commit ed86bf8ef3b5ea49230d7d7050a360b74df98ce2
Headers show
Series spi/trace: Cap buffer contents at 64 bytes | expand

Commit Message

Noralf Trønnes April 13, 2019, 8:48 p.m. UTC
Large transfers (64kB) doesn't show up in the trace. Not sure why, but
since printk can only display buffers up to 64 bytes in length, we only
need to store the first 64 bytes.

Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
---
 include/trace/events/spi.h | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Noralf Trønnes April 14, 2019, 9:41 a.m. UTC | #1
Den 13.04.2019 22.48, skrev Noralf Trønnes:
> Large transfers (64kB) doesn't show up in the trace. Not sure why, but
> since printk can only display buffers up to 64 bytes in length, we only
> need to store the first 64 bytes.
> 

I forgot this:

Fixes: 8d245475c3f6 ("spi/trace: include buffer contents in traces")

> Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
> ---
>  include/trace/events/spi.h | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/include/trace/events/spi.h b/include/trace/events/spi.h
> index aef6869f563d..0dd9171d2ad8 100644
> --- a/include/trace/events/spi.h
> +++ b/include/trace/events/spi.h
> @@ -131,9 +131,11 @@ DECLARE_EVENT_CLASS(spi_transfer,
>  		__field(        struct spi_transfer *,   xfer   )
>  		__field(        int,            len             )
>  		__dynamic_array(u8, rx_buf,
> -				spi_valid_rxbuf(msg, xfer) ? xfer->len : 0)
> +				spi_valid_rxbuf(msg, xfer) ?
> +					(xfer->len < 64 ? xfer->len : 64) : 0)
>  		__dynamic_array(u8, tx_buf,
> -				spi_valid_txbuf(msg, xfer) ? xfer->len : 0)
> +				spi_valid_txbuf(msg, xfer) ?
> +					(xfer->len < 64 ? xfer->len : 64) : 0)
>  	),
>  
>  	TP_fast_assign(
> @@ -144,11 +146,11 @@ DECLARE_EVENT_CLASS(spi_transfer,
>  
>  		if (spi_valid_txbuf(msg, xfer))
>  			memcpy(__get_dynamic_array(tx_buf),
> -			       xfer->tx_buf, xfer->len);
> +			       xfer->tx_buf, __get_dynamic_array_len(tx_buf));
>  
>  		if (spi_valid_rxbuf(msg, xfer))
>  			memcpy(__get_dynamic_array(rx_buf),
> -			       xfer->rx_buf, xfer->len);
> +			       xfer->rx_buf, __get_dynamic_array_len(rx_buf));
>  	),
>  
>  	TP_printk("spi%d.%d %p len=%d tx=[%*phD] rx=[%*phD]",
>
diff mbox series

Patch

diff --git a/include/trace/events/spi.h b/include/trace/events/spi.h
index aef6869f563d..0dd9171d2ad8 100644
--- a/include/trace/events/spi.h
+++ b/include/trace/events/spi.h
@@ -131,9 +131,11 @@  DECLARE_EVENT_CLASS(spi_transfer,
 		__field(        struct spi_transfer *,   xfer   )
 		__field(        int,            len             )
 		__dynamic_array(u8, rx_buf,
-				spi_valid_rxbuf(msg, xfer) ? xfer->len : 0)
+				spi_valid_rxbuf(msg, xfer) ?
+					(xfer->len < 64 ? xfer->len : 64) : 0)
 		__dynamic_array(u8, tx_buf,
-				spi_valid_txbuf(msg, xfer) ? xfer->len : 0)
+				spi_valid_txbuf(msg, xfer) ?
+					(xfer->len < 64 ? xfer->len : 64) : 0)
 	),
 
 	TP_fast_assign(
@@ -144,11 +146,11 @@  DECLARE_EVENT_CLASS(spi_transfer,
 
 		if (spi_valid_txbuf(msg, xfer))
 			memcpy(__get_dynamic_array(tx_buf),
-			       xfer->tx_buf, xfer->len);
+			       xfer->tx_buf, __get_dynamic_array_len(tx_buf));
 
 		if (spi_valid_rxbuf(msg, xfer))
 			memcpy(__get_dynamic_array(rx_buf),
-			       xfer->rx_buf, xfer->len);
+			       xfer->rx_buf, __get_dynamic_array_len(rx_buf));
 	),
 
 	TP_printk("spi%d.%d %p len=%d tx=[%*phD] rx=[%*phD]",