Skip to contentSkip to conversation

Trivial ARM changes

PATCH Applied Bernhard Beschow 4 participants 8 messages Nov 3, 2024 – Nov 4, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover Trivial ARM changes

This series improves the tracing experience in three devices used in ARM context. It also removes a duplicate statement in an IMX watchdog.

v2:
* Fix format strings in trace events for imx_gpt (Phil)
* Add patch for tmp105 which improves tracing

Bernhard Beschow (4):
hw/rtc/ds1338: Trace send and receive operations hw/timer/imx_gpt: Convert DPRINTF to trace events hw/watchdog/wdt_imx2: Remove redundant assignment hw/sensor/tmp105: Convert printf() to trace event, add tracing for
read/write access

 meson.build            |  1 +
 hw/sensor/trace.h      |  1 +
 hw/rtc/ds1338.c        |  6 ++++++
 hw/sensor/tmp105.c     |  7 ++++++-
 hw/timer/imx_gpt.c     | 18 +++++-------------
 hw/watchdog/wdt_imx2.c |  1 -
 hw/rtc/trace-events    |  4 ++++
 hw/sensor/trace-events |  6 ++++++
 hw/timer/trace-events  |  6 ++++++
 9 files changed, 35 insertions(+), 15 deletions(-)
 create mode 100644 hw/sensor/trace.h
 create mode 100644 hw/sensor/trace-events
Signature · 1 line
2.47.0
#1 lore raw

PATCH v2 1/4 hw/rtc/ds1338: Trace send and receive operations

---
 hw/rtc/ds1338.c     | 6 ++++++
 hw/rtc/trace-events | 4 ++++
 2 files changed, 10 insertions(+)
hw/rtc/ds1338.c +6 -0
index a5fe221418..929a92f7bd 100644
@@ -17,6 +17,7 @@
 #include "qemu/module.h"
 #include "qom/object.h"
 #include "sysemu/rtc.h"
+#include "trace.h"
 
 /* Size of NVRAM including both the user-accessible area and the
  * secondary register area.
@@ -126,6 +127,9 @@ static uint8_t ds1338_recv(I2CSlave *i2c)
     uint8_t res;
 
     res  = s->nvram[s->ptr];
+
+    trace_ds1338_recv(s->ptr, res);
+
     inc_regptr(s);
     return res;
 }
@@ -134,6 +138,8 @@ static int ds1338_send(I2CSlave *i2c, uint8_t data)
 {
     DS1338State *s = DS1338(i2c);
 
+    trace_ds1338_send(s->ptr, data);
+
     if (s->addr_byte) {
         s->ptr = data & (NVRAM_SIZE - 1);
         s->addr_byte = false;
hw/rtc/trace-events +4 -0
index ebb311a5b0..8012afe102 100644
@@ -22,6 +22,10 @@ pl031_set_alarm(uint32_t ticks) "alarm set for %u ticks"
 aspeed_rtc_read(uint64_t addr, uint64_t value) "addr 0x%02" PRIx64 " value 0x%08" PRIx64
 aspeed_rtc_write(uint64_t addr, uint64_t value) "addr 0x%02" PRIx64 " value 0x%08" PRIx64
 
+# ds1338.c
+ds1338_recv(uint32_t addr, uint8_t value) "[0x%" PRIx32 "] -> 0x%02" PRIx8
+ds1338_send(uint32_t addr, uint8_t value) "[0x%" PRIx32 "] <- 0x%02" PRIx8
+
 # m48t59.c
 m48txx_nvram_io_read(uint64_t addr, uint64_t value) "io read addr:0x%04" PRIx64 " value:0x%02" PRIx64
 m48txx_nvram_io_write(uint64_t addr, uint64_t value) "io write addr:0x%04" PRIx64 " value:0x%02" PRIx64
Signature · 1 line
2.47.0
#2 lore raw

PATCH v2 2/4 hw/timer/imx_gpt: Convert DPRINTF to trace events

In reply to Bernhard Beschow
---
 hw/timer/imx_gpt.c    | 18 +++++-------------
 hw/timer/trace-events |  6 ++++++
 2 files changed, 11 insertions(+), 13 deletions(-)
hw/timer/imx_gpt.c +5 -13
index 23b3d79bdb..2663a9d9ef 100644
@@ -18,19 +18,12 @@
 #include "migration/vmstate.h"
 #include "qemu/module.h"
 #include "qemu/log.h"
+#include "trace.h"
 
 #ifndef DEBUG_IMX_GPT
 #define DEBUG_IMX_GPT 0
 #endif
 
-#define DPRINTF(fmt, args...) \
-    do { \
-        if (DEBUG_IMX_GPT) { \
-            fprintf(stderr, "[%s]%s: " fmt , TYPE_IMX_GPT, \
-                                             __func__, ##args); \
-        } \
-    } while (0)
-
 static const char *imx_gpt_reg_name(uint32_t reg)
 {
     switch (reg) {
@@ -145,7 +138,7 @@ static void imx_gpt_set_freq(IMXGPTState *s)
     s->freq = imx_ccm_get_clock_frequency(s->ccm,
                                           s->clocks[clksrc]) / (1 + s->pr);
 
-    DPRINTF("Setting clksrc %d to frequency %d\n", clksrc, s->freq);
+    trace_imx_gpt_set_freq(clksrc, s->freq);
 
     if (s->freq) {
         ptimer_set_freq(s->timer, s->freq);
@@ -317,7 +310,7 @@ static uint64_t imx_gpt_read(void *opaque, hwaddr offset, unsigned size)
         break;
     }
 
-    DPRINTF("(%s) = 0x%08x\n", imx_gpt_reg_name(offset >> 2), reg_value);
+    trace_imx_gpt_read(imx_gpt_reg_name(offset >> 2), reg_value);
 
     return reg_value;
 }
@@ -384,8 +377,7 @@ static void imx_gpt_write(void *opaque, hwaddr offset, uint64_t value,
     IMXGPTState *s = IMX_GPT(opaque);
     uint32_t oldreg;
 
-    DPRINTF("(%s, value = 0x%08x)\n", imx_gpt_reg_name(offset >> 2),
-            (uint32_t)value);
+    trace_imx_gpt_write(imx_gpt_reg_name(offset >> 2), (uint32_t)value);
 
     switch (offset >> 2) {
     case 0:
@@ -485,7 +477,7 @@ static void imx_gpt_timeout(void *opaque)
 {
     IMXGPTState *s = IMX_GPT(opaque);
 
-    DPRINTF("\n");
+    trace_imx_gpt_timeout();
 
     s->sr |= s->next_int;
     s->next_int = 0;
hw/timer/trace-events +6 -0
index f48a712801..5cfc369fba 100644
@@ -49,6 +49,12 @@ cmsdk_apb_dualtimer_read(uint64_t offset, uint64_t data, unsigned size) "CMSDK A
 cmsdk_apb_dualtimer_write(uint64_t offset, uint64_t data, unsigned size) "CMSDK APB dualtimer write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
 cmsdk_apb_dualtimer_reset(void) "CMSDK APB dualtimer: reset"
 
+# imx_gpt.c
+imx_gpt_set_freq(uint32_t clksrc, uint32_t freq) "Setting clksrc %u to %u Hz"
+imx_gpt_read(const char *name, uint64_t value) "%s -> 0x%08" PRIx64
+imx_gpt_write(const char *name, uint64_t value) "%s <- 0x%08" PRIx64
+imx_gpt_timeout(void) ""
+
 # npcm7xx_timer.c
 npcm7xx_timer_read(const char *id, uint64_t offset, uint64_t value) " %s offset: 0x%04" PRIx64 " value 0x%08" PRIx64
 npcm7xx_timer_write(const char *id, uint64_t offset, uint64_t value) "%s offset: 0x%04" PRIx64 " value 0x%08" PRIx64
Signature · 1 line
2.47.0
#3 lore raw

PATCH v2 3/4 hw/watchdog/wdt_imx2: Remove redundant assignment

In reply to Bernhard Beschow

The same statement is executed unconditionally right before the if statement.

---
 hw/watchdog/wdt_imx2.c | 1 -
 1 file changed, 1 deletion(-)
hw/watchdog/wdt_imx2.c +0 -1
index be63d421da..8162d58afa 100644
@@ -39,7 +39,6 @@ static void imx2_wdt_expired(void *opaque)
 
     /* Perform watchdog action if watchdog is enabled */
     if (s->wcr & IMX2_WDT_WCR_WDE) {
-        s->wrsr = IMX2_WDT_WRSR_TOUT;
         watchdog_perform_action();
     }
 }
Signature · 1 line
2.47.0
Reviewed-by on v2 3/4
#4 lore raw

Re: [PATCH v2 3/4] hw/watchdog/wdt_imx2: Remove redundant assignment

Quoted 8 lines · Bernhard Beschow

The same statement is executed unconditionally right before the if statement.

---
  hw/watchdog/wdt_imx2.c | 1 -
  1 file changed, 1 deletion(-)

r~

#5 lore raw

PATCH v2 4/4 hw/sensor/tmp105: Convert printf() to trace event, add tracing for read/write access

In reply to Bernhard Beschow

printf() unconditionally prints to the console which disturbs -serial stdio. Fix that by converting into a trace event. While at it, add some tracing for read and write access.

Fixes 7e7c5e4c1ba5 "Nokia N800 machine support (ARM)."
---
 meson.build            | 1 +
 hw/sensor/trace.h      | 1 +
 hw/sensor/tmp105.c     | 7 ++++++-
 hw/sensor/trace-events | 6 ++++++
 4 files changed, 14 insertions(+), 1 deletion(-)
 create mode 100644 hw/sensor/trace.h
 create mode 100644 hw/sensor/trace-events
meson.build +1 -0
index 2c9086a3fe..19df8d7125 100644
@@ -3476,6 +3476,7 @@ if have_system
     'hw/s390x',
     'hw/scsi',
     'hw/sd',
+    'hw/sensor',
     'hw/sh4',
     'hw/sparc',
     'hw/sparc64',
hw/sensor/trace.h new file +1 -0
new file mode 100644
index 0000000000..e4721560b0
@@ -0,0 +1 @@
+#include "trace/trace-hw_sensor.h"
hw/sensor/tmp105.c +6 -1
index 9d7b911f59..ef2824f3e1 100644
@@ -27,6 +27,7 @@
 #include "qapi/visitor.h"
 #include "qemu/module.h"
 #include "hw/registerfields.h"
+#include "trace.h"
 
 FIELD(CONFIG, SHUTDOWN_MODE,        0, 1)
 FIELD(CONFIG, THERMOSTAT_MODE,      1, 1)
@@ -150,17 +151,21 @@ static void tmp105_read(TMP105State *s)
         s->buf[s->len++] = ((uint16_t) s->limit[1]) >> 0;
         break;
     }
+
+    trace_tmp105_read(s->i2c.address, s->pointer);
 }
 
 static void tmp105_write(TMP105State *s)
 {
+    trace_tmp105_write(s->i2c.address, s->pointer);
+
     switch (s->pointer & 3) {
     case TMP105_REG_TEMPERATURE:
         break;
 
     case TMP105_REG_CONFIG:
         if (FIELD_EX8(s->buf[0] & ~s->config, CONFIG, SHUTDOWN_MODE)) {
-            printf("%s: TMP105 shutdown\n", __func__);
+            trace_tmp105_write_shutdown(s->i2c.address);
         }
         s->config = FIELD_DP8(s->buf[0], CONFIG, ONE_SHOT, 0);
         s->faults = tmp105_faultq[FIELD_EX8(s->config, CONFIG, FAULT_QUEUE)];
hw/sensor/trace-events new file +6 -0
new file mode 100644
index 0000000000..a3fe54fa6d
@@ -0,0 +1,6 @@
+# See docs/devel/tracing.rst for syntax documentation.
+
+# tmp105.c
+tmp105_read(uint8_t dev, uint8_t addr) "device: 0x%02x, addr: 0x%02x"
+tmp105_write(uint8_t dev, uint8_t addr) "device: 0x%02x, addr 0x%02x"
+tmp105_write_shutdown(uint8_t dev) "device: 0x%02x"
Signature · 1 line
2.47.0
Reviewed-by on v2 4/4
#6 lore raw

Re: [PATCH v2 4/4] hw/sensor/tmp105: Convert printf() to trace event, add tracing for read/write access

Quoted 6 lines · Bernhard Beschow

printf() unconditionally prints to the console which disturbs -serial stdio. Fix that by converting into a trace event. While at it, add some tracing for read and write access.

Fixes 7e7c5e4c1ba5 "Nokia N800 machine support (ARM)."
Quoted 8 lines
---
  meson.build            | 1 +
  hw/sensor/trace.h      | 1 +
  hw/sensor/tmp105.c     | 7 ++++++-
  hw/sensor/trace-events | 6 ++++++
  4 files changed, 14 insertions(+), 1 deletion(-)

create mode 100644 hw/sensor/trace.h
create mode 100644 hw/sensor/trace-events

#7 lore raw
In reply to Bernhard Beschow
Quoted 8 lines · Bernhard Beschow

This series improves the tracing experience in three devices used in ARM context. It also removes a duplicate statement in an IMX watchdog.

v2:
* Fix format strings in trace events for imx_gpt (Phil)
* Add patch for tmp105 which improves tracing

Quoted 6 lines

Bernhard Beschow (4):
hw/rtc/ds1338: Trace send and receive operations hw/timer/imx_gpt: Convert DPRINTF to trace events hw/watchdog/wdt_imx2: Remove redundant assignment hw/sensor/tmp105: Convert printf() to trace event, add tracing for
read/write access

Applied to target-arm.next, thanks.

-- PMM