* [PATCH v2] hw/misc: i2c-echo: add tracing
@ 2025-01-21 10:59 Titus Rwantare
2025-01-22 6:38 ` Hao Wu
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Titus Rwantare @ 2025-01-21 10:59 UTC (permalink / raw)
To: philmd, minyard, its; +Cc: qemu-arm, qemu-devel, clg, Titus Rwantare
This has been useful when debugging and unsure if the guest is
generating i2c traffic.
Signed-off-by: Titus Rwantare <titusr@google.com>
---
hw/misc/i2c-echo.c | 8 ++++++++
hw/misc/trace-events | 5 +++++
2 files changed, 13 insertions(+)
diff --git a/hw/misc/i2c-echo.c b/hw/misc/i2c-echo.c
index 5ae3d0817e..65d10029dc 100644
--- a/hw/misc/i2c-echo.c
+++ b/hw/misc/i2c-echo.c
@@ -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,13 @@ 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_FINISH:
@@ -92,12 +95,15 @@ 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:
+ trace_i2c_echo_event(DEVICE(s)->canonical_path, "UNHANDLED");
return -1;
}
@@ -112,6 +118,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 +126,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;
}
diff --git a/hw/misc/trace-events b/hw/misc/trace-events
index cf1abe6928..d58dca2389 100644
--- a/hw/misc/trace-events
+++ b/hw/misc/trace-events
@@ -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
--
2.48.0.rc2.279.g1de40edade-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] hw/misc: i2c-echo: add tracing
2025-01-21 10:59 [PATCH v2] hw/misc: i2c-echo: add tracing Titus Rwantare
@ 2025-01-22 6:38 ` Hao Wu
2025-01-22 7:00 ` Philippe Mathieu-Daudé
2025-01-22 12:46 ` Corey Minyard
2 siblings, 0 replies; 4+ messages in thread
From: Hao Wu @ 2025-01-22 6:38 UTC (permalink / raw)
To: Titus Rwantare; +Cc: philmd, minyard, its, qemu-arm, qemu-devel, clg
[-- Attachment #1: Type: text/plain, Size: 3071 bytes --]
On Tue, Jan 21, 2025 at 7:00 PM Titus Rwantare <titusr@google.com> wrote:
> This has been useful when debugging and unsure if the guest is
> generating i2c traffic.
>
> Signed-off-by: Titus Rwantare <titusr@google.com>
>
Reviewed-by: Hao Wu <wuhaotsh@google.com>
> ---
> hw/misc/i2c-echo.c | 8 ++++++++
> hw/misc/trace-events | 5 +++++
> 2 files changed, 13 insertions(+)
>
> diff --git a/hw/misc/i2c-echo.c b/hw/misc/i2c-echo.c
> index 5ae3d0817e..65d10029dc 100644
> --- a/hw/misc/i2c-echo.c
> +++ b/hw/misc/i2c-echo.c
> @@ -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,13 @@ 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_FINISH:
> @@ -92,12 +95,15 @@ 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:
> + trace_i2c_echo_event(DEVICE(s)->canonical_path, "UNHANDLED");
> return -1;
> }
>
> @@ -112,6 +118,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 +126,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;
> }
> diff --git a/hw/misc/trace-events b/hw/misc/trace-events
> index cf1abe6928..d58dca2389 100644
> --- a/hw/misc/trace-events
> +++ b/hw/misc/trace-events
> @@ -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
> --
> 2.48.0.rc2.279.g1de40edade-goog
>
>
>
[-- Attachment #2: Type: text/html, Size: 4154 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] hw/misc: i2c-echo: add tracing
2025-01-21 10:59 [PATCH v2] hw/misc: i2c-echo: add tracing Titus Rwantare
2025-01-22 6:38 ` Hao Wu
@ 2025-01-22 7:00 ` Philippe Mathieu-Daudé
2025-01-22 12:46 ` Corey Minyard
2 siblings, 0 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-22 7:00 UTC (permalink / raw)
To: Titus Rwantare, minyard, its; +Cc: qemu-arm, qemu-devel, clg
On 21/1/25 11:59, Titus Rwantare wrote:
> This has been useful when debugging and unsure if the guest is
> generating i2c traffic.
>
> Signed-off-by: Titus Rwantare <titusr@google.com>
> ---
> hw/misc/i2c-echo.c | 8 ++++++++
> hw/misc/trace-events | 5 +++++
> 2 files changed, 13 insertions(+)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> +#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
and queued using 0x02% format, thanks!
Phil.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] hw/misc: i2c-echo: add tracing
2025-01-21 10:59 [PATCH v2] hw/misc: i2c-echo: add tracing Titus Rwantare
2025-01-22 6:38 ` Hao Wu
2025-01-22 7:00 ` Philippe Mathieu-Daudé
@ 2025-01-22 12:46 ` Corey Minyard
2 siblings, 0 replies; 4+ messages in thread
From: Corey Minyard @ 2025-01-22 12:46 UTC (permalink / raw)
To: Titus Rwantare; +Cc: philmd, minyard, its, qemu-arm, qemu-devel, clg
On Tue, Jan 21, 2025 at 10:59:34AM +0000, Titus Rwantare wrote:
> This has been useful when debugging and unsure if the guest is
> generating i2c traffic.
Acked-by: Corey Minyard <cminyard@mvista.com>
>
> Signed-off-by: Titus Rwantare <titusr@google.com>
> ---
> hw/misc/i2c-echo.c | 8 ++++++++
> hw/misc/trace-events | 5 +++++
> 2 files changed, 13 insertions(+)
>
> diff --git a/hw/misc/i2c-echo.c b/hw/misc/i2c-echo.c
> index 5ae3d0817e..65d10029dc 100644
> --- a/hw/misc/i2c-echo.c
> +++ b/hw/misc/i2c-echo.c
> @@ -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,13 @@ 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_FINISH:
> @@ -92,12 +95,15 @@ 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:
> + trace_i2c_echo_event(DEVICE(s)->canonical_path, "UNHANDLED");
> return -1;
> }
>
> @@ -112,6 +118,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 +126,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;
> }
> diff --git a/hw/misc/trace-events b/hw/misc/trace-events
> index cf1abe6928..d58dca2389 100644
> --- a/hw/misc/trace-events
> +++ b/hw/misc/trace-events
> @@ -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
> --
> 2.48.0.rc2.279.g1de40edade-goog
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-01-22 12:46 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-21 10:59 [PATCH v2] hw/misc: i2c-echo: add tracing Titus Rwantare
2025-01-22 6:38 ` Hao Wu
2025-01-22 7:00 ` Philippe Mathieu-Daudé
2025-01-22 12:46 ` Corey Minyard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).