hw/misc: i2c-echo: add tracing
PATCH 1/1 hw/misc: i2c-echo: add tracing
This has been useful when debugging when unsure if the guest is generating i2c traffic.
--- hw/misc/i2c-echo.c | 13 +++++++++++++ hw/misc/trace-events | 5 +++++ 2 files changed, 18 insertions(+)
hw/misc/i2c-echo.c +13 -0
@@ -13,6 +13,7 @@#include "qemu/main-loop.h" #include "block/aio.h" #include "hw/i2c/i2c.h" +#include "trace.h" #define TYPE_I2C_ECHO "i2c-echo"OBJECT_DECLARE_SIMPLE_TYPE (I2CEchoState,I2C_ECHO )
@@ -80,11 +81,19 @@ static int i2c_echo_event(I2CSlave *s, enum i2c_event event)case I2C_START_RECV : state->pos =0 ; +trace_i2c_echo_event (DEVICE (s)->canonical_path,"I2C_START_RECV" );break ;case I2C_START_SEND : state->pos =0 ; +trace_i2c_echo_event (DEVICE (s)->canonical_path,"I2C_START_SEND" ); +break ; + +case I2C_START_SEND_ASYNC : + state->pos =0 ; + +trace_i2c_echo_event (DEVICE (s)->canonical_path,"I2C_START_SEND_ASYNC" );break ;case I2C_FINISH :
@@ -92,9 +101,11 @@ static int i2c_echo_event(I2CSlave *s, enum i2c_event event) state->state =I2C_ECHO_STATE_START_SEND ;i2c_bus_master (state->bus, state->bh); +trace_i2c_echo_event (DEVICE (s)->canonical_path,"I2C_FINISH" );break ;case I2C_NACK : +trace_i2c_echo_event (DEVICE (s)->canonical_path,"I2C_NACK" );break ;default :
@@ -112,6 +123,7 @@ static uint8_t i2c_echo_recv(I2CSlave *s)return 0xff ; } +trace_i2c_echo_recv (DEVICE (s)->canonical_path, state->data[state->pos]);return state->data[state->pos++]; }
@@ -119,6 +131,7 @@ static int i2c_echo_send(I2CSlave *s, uint8_t data) {I2CEchoState *state =I2C_ECHO (s); +trace_i2c_echo_send (DEVICE (s)->canonical_path, data);if (state->pos >2 ) {return -1 ; }
hw/misc/trace-events +5 -0
@@ -390,3 +390,8 @@ ivshmem_flat_read_write_mmr_invalid(uint64_t addr_offset) "No ivshmem register m ivshmem_flat_interrupt_invalid_peer(uint16_t peer_id) "Can't interrupt non-existing peer %u" ivshmem_flat_write_mmr(uint64_t addr_offset) "Write access at offset %"PRIu64 ivshmem_flat_interrupt_peer(uint16_t peer_id, uint16_t vector_id) "Interrupting peer ID %u, vector %u..." + +#i2c-echo.c +i2c_echo_event(const char *id, const char *event) "%s: %s" +i2c_echo_recv(const char *id, uint8_t data) "%s: recv 0x%" PRIx8 +i2c_echo_send(const char *id, uint8_t data) "%s: send 0x%" PRIx8
Signature · 1 line
2.48.0.rc2.279.g1de40edade-goog
Hi Titus,
Quoted 28 lines · Titus Rwantare
This has been useful when debugging when unsure if the guest is generating i2c traffic.
Signed-off-by Titus Rwantare <[email protected]>--- hw/misc/i2c-echo.c | 13 +++++++++++++ hw/misc/trace-events | 5 +++++ 2 files changed, 18 insertions(+)hw/misc/i2c-echo.c +2
-0@@ -13,6 +13,7 @@#include "qemu/main-loop.h" #include "block/aio.h" #include "hw/i2c/i2c.h" +#include "trace.h" #define TYPE_I2C_ECHO "i2c-echo"OBJECT_DECLARE_SIMPLE_TYPE (I2CEchoState,I2C_ECHO )@@ -80,11 +81,19 @@ static int i2c_echo_event(I2CSlave *s, enum i2c_event event)case I2C_START_RECV : state->pos =0 ; +trace_i2c_echo_event (DEVICE (s)->canonical_path,"I2C_START_RECV" );break ;
hw/misc/i2c-echo.c static int i2c_echo_event(I2CSlave *s, enum i2c_event event) · line 96
Quoted 10 lines
hw/misc/i2c-echo.c +7
-0case I2C_START_SEND : state->pos =0 ; +trace_i2c_echo_event (DEVICE (s)->canonical_path,"I2C_START_SEND" ); +break ; + +case I2C_START_SEND_ASYNC : + state->pos =0 ; + +trace_i2c_echo_event (DEVICE (s)->canonical_path,"I2C_START_SEND_ASYNC" );
This patch is doing a bit more that what it describes, since now START_SEND_ASYNC returns 0x00 instead of 0xff (besides updating pos).
Please split as one patch per logical change.
Thanks!
Phil.
Quoted 3 lines
hw/misc/i2c-echo.c +0
-0break ;case I2C_FINISH :
Quoted 46 lines · Philippe Mathieu-Daudé
Hi Titus,
Quoted 28 lines · Titus Rwantare
This has been useful when debugging when unsure if the guest is generating i2c traffic.
Signed-off-by Titus Rwantare <[email protected]>--- hw/misc/i2c-echo.c | 13 +++++++++++++ hw/misc/trace-events | 5 +++++ 2 files changed, 18 insertions(+)hw/misc/i2c-echo.c +2
-0@@ -13,6 +13,7 @@#include "qemu/main-loop.h" #include "block/aio.h" #include "hw/i2c/i2c.h" +#include "trace.h" #define TYPE_I2C_ECHO "i2c-echo"OBJECT_DECLARE_SIMPLE_TYPE (I2CEchoState,I2C_ECHO )@@ -80,11 +81,19 @@ static int i2c_echo_event(I2CSlave *s, enum i2c_event event)case I2C_START_RECV : state->pos =0 ; +trace_i2c_echo_event (DEVICE (s)->canonical_path,"I2C_START_RECV" );break ;hw/misc/i2c-echo.c static int i2c_echo_event(I2CSlave *s, enum i2c_event event) · line 96
Quoted 10 lines
hw/misc/i2c-echo.c +7
-0case I2C_START_SEND : state->pos =0 ; +trace_i2c_echo_event (DEVICE (s)->canonical_path,"I2C_START_SEND" ); +break ; + +case I2C_START_SEND_ASYNC : + state->pos =0 ; + +trace_i2c_echo_event (DEVICE (s)->canonical_path,"I2C_START_SEND_ASYNC" );This patch is doing a bit more that what it describes, since now
START_SEND_ASYNCreturns0x00instead of0xff(besides updating pos).
Quoted 6 lines
Please split as one patch per logical change.
Thanks!
Phil.
I've removed the async case from the patch as it's not something that has come up.
- Titus