Skip to contentSkip to conversation

Trivial ARM changes

PATCH Superseded Bernhard Beschow 3 participants 9 messages May 13, 2024 Arm i.MX and Layerscape

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Trivial ARM changes

This series improves the tracing experience in two devices used in ARM context. It also removes a duplicate statement in an IMX watchdog which may indicate a bug (see comment underneath commit message).

Best regards,
Bernhard

Bernhard Beschow (3):
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/rtc/ds1338.c        |  6 ++++++
 hw/timer/imx_gpt.c     | 18 +++++-------------
 hw/watchdog/wdt_imx2.c |  1 -
 hw/rtc/trace-events    |  4 ++++
 hw/timer/trace-events  |  6 ++++++
 5 files changed, 21 insertions(+), 14 deletions(-)
Signature · 1 line
2.45.0
#1 lore raw

PATCH 1/3 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 e479661c39..ec1b6c40b1 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.45.0
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] hw/rtc/ds1338: Trace send and receive operations

Quoted 17 lines · Bernhard Beschow
---
  hw/rtc/ds1338.c     | 6 ++++++
  hw/rtc/trace-events | 4 ++++
  2 files changed, 10 insertions(+)
hw/rtc/ds1338.c +1 -0
@@ -134,6 +138,8 @@ static int ds1338_send(I2CSlave *i2c, uint8_t data)
  {
      DS1338State *s = DS1338(i2c);
 
+    trace_ds1338_send(s->ptr, data);
 
 

hw/rtc/trace-events pl031_set_alarm(uint32_t ticks) "alarm set for %u ticks" · line 27

Quoted 6 lines
hw/rtc/trace-events +3 -0
@@ -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

DS1338State::ptr is signed, although being an offset, odd. Using unsigned in traces seems better anyway,

#3 lore raw

PATCH 2/3 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 a8edaec867..3c3b044622 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 de769f4b71..c9bcc85455 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 %d to %d Hz"
+imx_gpt_read(const char *name, uint32_t value) "%s -> 0x%08x"
+imx_gpt_write(const char *name, uint32_t value) "%s <- 0x%08x"
+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.45.0
Reviewed-by on v1 2/3
#4 lore raw

Re: [PATCH 2/3] hw/timer/imx_gpt: Convert DPRINTF to trace events

Quoted 26 lines · 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 +2 -3
@@ -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);
 
 

hw/timer/imx_gpt.c cmsdk_apb_dualtimer_read(uint64_t offset, uint64_t data, unsigned size) "CMSDK A · line 53

Quoted 5 lines
hw/timer/imx_gpt.c +2 -0
@@ -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 %d to %d Hz"

'%d' is signed, for unsigned you want '%u'.

hw/timer/trace-events cmsdk_apb_dualtimer_read(uint64_t offset, uint64_t data, unsigned size) "CMSDK A · line 55

Quoted 2 lines
hw/timer/trace-events +2 -0
+imx_gpt_read(const char *name, uint32_t value) "%s -> 0x%08x"
+imx_gpt_write(const char *name, uint32_t value) "%s <- 0x%08x"

I'd avoid the cast and use uint64_t/PRIx64 here to KISS, regardless:

Quoted 2 lines
hw/timer/trace-events +2 -0
+imx_gpt_timeout(void) ""
+
#5 lore raw

Re: [PATCH 2/3] hw/timer/imx_gpt: Convert DPRINTF to trace events

Am 13. Mai 2024 11:30:04 UTC schrieb "Philippe Mathieu-Daudé" <[email protected]>:

Quoted 23 lines · Bernhard Beschow
Quoted 20 lines
---
  hw/timer/imx_gpt.c    | 18 +++++-------------
  hw/timer/trace-events |  6 ++++++
  2 files changed, 11 insertions(+), 13 deletions(-)
hw/timer/imx_gpt.c +2 -1
@@ -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);
Quoted 7 lines

hw/timer/trace-events cmsdk_apb_dualtimer_read(uint64_t offset, uint64_t data, unsigned size) "CMSDK A · line 52

Quoted 5 lines
hw/timer/trace-events +1 -0
@@ -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 %d to %d Hz"

'%d' is signed, for unsigned you want '%u'.

I'll respin.

Thanks,
Bernhard

Quoted 10 lines

hw/timer/trace-events cmsdk_apb_dualtimer_read(uint64_t offset, uint64_t data, unsigned size) "CMSDK A · line 55

Quoted 3 lines
hw/timer/trace-events +2 -0
+imx_gpt_read(const char *name, uint32_t value) "%s -> 0x%08x"
+imx_gpt_write(const char *name, uint32_t value) "%s <- 0x%08x"

I'd avoid the cast and use uint64_t/PRIx64 here to KISS, regardless:

Quoted 2 lines
hw/timer/trace-events +2 -0
+imx_gpt_timeout(void) ""
+
#6 lore raw

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

In reply to Bernhard Beschow

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

---

The duplicate line may indicate a bug. I'm not familiar with the code, so this patch may go into the wrong direction. Please check!

---
 hw/watchdog/wdt_imx2.c | 1 -
 1 file changed, 1 deletion(-)
hw/watchdog/wdt_imx2.c +0 -1
index 6452fc4721..f9a7ea287f 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.45.0
#7 lore raw

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

Quoted 9 lines · Bernhard Beschow

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

---

The duplicate line may indicate a bug. I'm not familiar with the code, so this patch may go into the wrong direction. Please check!

The bug might be in imx2_wdt_write() where the WRSR register is overwritten, shouldn't we OR the SFTW bit, keeping other (such TOUT) set?

    if (!(value & IMX2_WDT_WCR_SRS)) {
        s->wrsr = IMX2_WDT_WRSR_SFTW;
    }
Quoted 16 lines
---
  hw/watchdog/wdt_imx2.c | 1 -
  1 file changed, 1 deletion(-)
hw/watchdog/wdt_imx2.c +0 -1
index 6452fc4721..f9a7ea287f 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();
      }
  }
Reviewed-by on v1 3/3
#8 lore raw

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

In reply to Bernhard Beschow
Quoted 9 lines · Bernhard Beschow

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

---

The duplicate line may indicate a bug. I'm not familiar with the code, so this patch may go into the wrong direction. Please check!

Should be ok. Technically the function should not be called to start with if the watchdog isn't running. If it is, it might be useful to trace the content of wcr and try to determine why the timer isn't stopped if / when the watchdog is disabled.

Thanks,
Guenter

Quoted 16 lines
---
  hw/watchdog/wdt_imx2.c | 1 -
  1 file changed, 1 deletion(-)
hw/watchdog/wdt_imx2.c +0 -1
index 6452fc4721..f9a7ea287f 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();
      }
  }