qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] hw/arm: Remove printf() calls
@ 2025-02-27 17:01 Peter Maydell
  2025-02-27 17:01 ` [PATCH 1/5] hw/arm/omap1: Convert raw printfs to qemu_log_mask() Peter Maydell
                   ` (6 more replies)
  0 siblings, 7 replies; 12+ messages in thread
From: Peter Maydell @ 2025-02-27 17:01 UTC (permalink / raw)
  To: qemu-arm, qemu-devel

I noticed while looking at the sx1 functional tests that
the omap1 device emulation code prints to stdout
"omap_clkm_write: clocking scheme set to synchronous scalable"
which the test dutifully captures to its default.log.

Printing this kind of debug or information message to stdout
is definitely not something we do any more; so seeing it
prompted me to clean this up for hw/arm:
 * printf()s for guest errors or unimplemented functionality
   should be qemu_log_mask()
 * printf()s for minor informational things should be
   tracepoints
 * printf() for debug that have been ifdeffed out forever
   could in theory be tracepoints, but I didn't feel it
   worth the effort of conversion in this case: I doubt that
   anybody will be trying to debug this code or that the
   specific handful of debug ifdefs would be what they'll want
   anyway. If anybody ever does need to do debug here, they can
   add the tracepoints that are actually useful to them.

thanks
-- PMM

Peter Maydell (5):
  hw/arm/omap1: Convert raw printfs to qemu_log_mask()
  hw/arm/omap1: Drop ALMDEBUG ifdeffed out code
  hw/arm/omap1: Convert information printfs to tracepoints
  hw/arm/omap_sx1.c: Remove ifdeffed out debug printf
  hw/arm/versatilepb: Convert printfs to LOG_GUEST_ERROR

 hw/arm/omap1.c       | 126 ++++++++++++++++---------------------------
 hw/arm/omap_sx1.c    |   4 --
 hw/arm/versatilepb.c |   7 ++-
 hw/arm/trace-events  |   7 +++
 4 files changed, 57 insertions(+), 87 deletions(-)

-- 
2.43.0



^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/5] hw/arm/omap1: Convert raw printfs to qemu_log_mask()
  2025-02-27 17:01 [PATCH 0/5] hw/arm: Remove printf() calls Peter Maydell
@ 2025-02-27 17:01 ` Peter Maydell
  2025-02-27 22:15   ` Philippe Mathieu-Daudé
  2025-02-27 17:01 ` [PATCH 2/5] hw/arm/omap1: Drop ALMDEBUG ifdeffed out code Peter Maydell
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 12+ messages in thread
From: Peter Maydell @ 2025-02-27 17:01 UTC (permalink / raw)
  To: qemu-arm, qemu-devel

omap1.c is very old code, and it contains numerous calls direct to
printf() for various error and information cases.

In this commit, convert the printf() calls that are for either guest
error or unimplemented functionality to qemu_log_mask() calls.

This leaves the printf() calls that are informative or which are
ifdeffed-out debug statements untouched.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/arm/omap1.c | 48 +++++++++++++++++++++++++++++++-----------------
 1 file changed, 31 insertions(+), 17 deletions(-)

diff --git a/hw/arm/omap1.c b/hw/arm/omap1.c
index ca2eb0d1576..3c0ce5e0979 100644
--- a/hw/arm/omap1.c
+++ b/hw/arm/omap1.c
@@ -2559,8 +2559,9 @@ static void omap_rtc_interrupts_update(struct omap_rtc_s *s)
 static void omap_rtc_alarm_update(struct omap_rtc_s *s)
 {
     s->alarm_ti = mktimegm(&s->alarm_tm);
-    if (s->alarm_ti == -1)
-        printf("%s: conversion failed\n", __func__);
+    if (s->alarm_ti == -1) {
+        qemu_log_mask(LOG_GUEST_ERROR, "%s: conversion failed\n", __func__);
+    }
 }
 
 static uint64_t omap_rtc_read(void *opaque, hwaddr addr, unsigned size)
@@ -3024,8 +3025,9 @@ static void omap_mcbsp_source_tick(void *opaque)
 
     if (!s->rx_rate)
         return;
-    if (s->rx_req)
-        printf("%s: Rx FIFO overrun\n", __func__);
+    if (s->rx_req) {
+        qemu_log_mask(LOG_GUEST_ERROR, "%s: Rx FIFO overrun\n", __func__);
+    }
 
     s->rx_req = s->rx_rate << bps[(s->rcr[0] >> 5) & 7];
 
@@ -3070,8 +3072,9 @@ static void omap_mcbsp_sink_tick(void *opaque)
 
     if (!s->tx_rate)
         return;
-    if (s->tx_req)
-        printf("%s: Tx FIFO underrun\n", __func__);
+    if (s->tx_req) {
+        qemu_log_mask(LOG_GUEST_ERROR, "%s: Tx FIFO underrun\n", __func__);
+    }
 
     s->tx_req = s->tx_rate << bps[(s->xcr[0] >> 5) & 7];
 
@@ -3173,7 +3176,7 @@ static uint64_t omap_mcbsp_read(void *opaque, hwaddr addr,
         /* Fall through.  */
     case 0x02:	/* DRR1 */
         if (s->rx_req < 2) {
-            printf("%s: Rx FIFO underrun\n", __func__);
+            qemu_log_mask(LOG_GUEST_ERROR, "%s: Rx FIFO underrun\n", __func__);
             omap_mcbsp_rx_done(s);
         } else {
             s->tx_req -= 2;
@@ -3278,8 +3281,9 @@ static void omap_mcbsp_writeh(void *opaque, hwaddr addr,
             }
             if (s->tx_req < 2)
                 omap_mcbsp_tx_done(s);
-        } else
-            printf("%s: Tx FIFO overrun\n", __func__);
+        } else {
+            qemu_log_mask(LOG_GUEST_ERROR, "%s: Tx FIFO overrun\n", __func__);
+        }
         return;
 
     case 0x08:	/* SPCR2 */
@@ -3293,8 +3297,11 @@ static void omap_mcbsp_writeh(void *opaque, hwaddr addr,
     case 0x0a:	/* SPCR1 */
         s->spcr[0] &= 0x0006;
         s->spcr[0] |= 0xf8f9 & value;
-        if (value & (1 << 15))				/* DLB */
-            printf("%s: Digital Loopback mode enable attempt\n", __func__);
+        if (value & (1 << 15)) {                        /* DLB */
+            qemu_log_mask(LOG_UNIMP,
+                          "%s: Digital Loopback mode enable attempt\n",
+                          __func__);
+        }
         if (~value & 1) {				/* RRST */
             s->spcr[0] &= ~6;
             s->rx_req = 0;
@@ -3325,13 +3332,19 @@ static void omap_mcbsp_writeh(void *opaque, hwaddr addr,
         return;
     case 0x18:	/* MCR2 */
         s->mcr[1] = value & 0x03e3;
-        if (value & 3)					/* XMCM */
-            printf("%s: Tx channel selection mode enable attempt\n", __func__);
+        if (value & 3) {                                /* XMCM */
+            qemu_log_mask(LOG_UNIMP,
+                          "%s: Tx channel selection mode enable attempt\n",
+                          __func__);
+        }
         return;
     case 0x1a:	/* MCR1 */
         s->mcr[0] = value & 0x03e1;
-        if (value & 1)					/* RMCM */
-            printf("%s: Rx channel selection mode enable attempt\n", __func__);
+        if (value & 1) {                                /* RMCM */
+            qemu_log_mask(LOG_UNIMP,
+                          "%s: Rx channel selection mode enable attempt\n",
+                          __func__);
+        }
         return;
     case 0x1c:	/* RCERA */
         s->rcer[0] = value & 0xffff;
@@ -3412,8 +3425,9 @@ static void omap_mcbsp_writew(void *opaque, hwaddr addr,
             }
             if (s->tx_req < 4)
                 omap_mcbsp_tx_done(s);
-        } else
-            printf("%s: Tx FIFO overrun\n", __func__);
+        } else {
+            qemu_log_mask(LOG_GUEST_ERROR, "%s: Tx FIFO overrun\n", __func__);
+        }
         return;
     }
 
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/5] hw/arm/omap1: Drop ALMDEBUG ifdeffed out code
  2025-02-27 17:01 [PATCH 0/5] hw/arm: Remove printf() calls Peter Maydell
  2025-02-27 17:01 ` [PATCH 1/5] hw/arm/omap1: Convert raw printfs to qemu_log_mask() Peter Maydell
@ 2025-02-27 17:01 ` Peter Maydell
  2025-02-27 22:15   ` Philippe Mathieu-Daudé
  2025-02-27 17:01 ` [PATCH 3/5] hw/arm/omap1: Convert information printfs to tracepoints Peter Maydell
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 12+ messages in thread
From: Peter Maydell @ 2025-02-27 17:01 UTC (permalink / raw)
  To: qemu-arm, qemu-devel

In omap1.c, there are some debug printfs in the omap_rtc_write()
function that are guardad by ifdef ALMDEBUG. ALMDEBUG is never
set, so this is all dead code.

It's not worth the effort of converting all of these to tracepoints;
a modern tracepoint approach would probably have a single tracepoint
covering all the register writes anyway. Just delete the printf()s.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/arm/omap1.c | 51 --------------------------------------------------
 1 file changed, 51 deletions(-)

diff --git a/hw/arm/omap1.c b/hw/arm/omap1.c
index 3c0ce5e0979..8f5bb81c96a 100644
--- a/hw/arm/omap1.c
+++ b/hw/arm/omap1.c
@@ -2660,25 +2660,16 @@ static void omap_rtc_write(void *opaque, hwaddr addr,
 
     switch (offset) {
     case 0x00:	/* SECONDS_REG */
-#ifdef ALMDEBUG
-        printf("RTC SEC_REG <-- %02x\n", value);
-#endif
         s->ti -= s->current_tm.tm_sec;
         s->ti += from_bcd(value);
         return;
 
     case 0x04:	/* MINUTES_REG */
-#ifdef ALMDEBUG
-        printf("RTC MIN_REG <-- %02x\n", value);
-#endif
         s->ti -= s->current_tm.tm_min * 60;
         s->ti += from_bcd(value) * 60;
         return;
 
     case 0x08:	/* HOURS_REG */
-#ifdef ALMDEBUG
-        printf("RTC HRS_REG <-- %02x\n", value);
-#endif
         s->ti -= s->current_tm.tm_hour * 3600;
         if (s->pm_am) {
             s->ti += (from_bcd(value & 0x3f) & 12) * 3600;
@@ -2688,17 +2679,11 @@ static void omap_rtc_write(void *opaque, hwaddr addr,
         return;
 
     case 0x0c:	/* DAYS_REG */
-#ifdef ALMDEBUG
-        printf("RTC DAY_REG <-- %02x\n", value);
-#endif
         s->ti -= s->current_tm.tm_mday * 86400;
         s->ti += from_bcd(value) * 86400;
         return;
 
     case 0x10:	/* MONTHS_REG */
-#ifdef ALMDEBUG
-        printf("RTC MTH_REG <-- %02x\n", value);
-#endif
         memcpy(&new_tm, &s->current_tm, sizeof(new_tm));
         new_tm.tm_mon = from_bcd(value);
         ti[0] = mktimegm(&s->current_tm);
@@ -2715,9 +2700,6 @@ static void omap_rtc_write(void *opaque, hwaddr addr,
         return;
 
     case 0x14:	/* YEARS_REG */
-#ifdef ALMDEBUG
-        printf("RTC YRS_REG <-- %02x\n", value);
-#endif
         memcpy(&new_tm, &s->current_tm, sizeof(new_tm));
         new_tm.tm_year += from_bcd(value) - (new_tm.tm_year % 100);
         ti[0] = mktimegm(&s->current_tm);
@@ -2737,25 +2719,16 @@ static void omap_rtc_write(void *opaque, hwaddr addr,
         return;	/* Ignored */
 
     case 0x20:	/* ALARM_SECONDS_REG */
-#ifdef ALMDEBUG
-        printf("ALM SEC_REG <-- %02x\n", value);
-#endif
         s->alarm_tm.tm_sec = from_bcd(value);
         omap_rtc_alarm_update(s);
         return;
 
     case 0x24:	/* ALARM_MINUTES_REG */
-#ifdef ALMDEBUG
-        printf("ALM MIN_REG <-- %02x\n", value);
-#endif
         s->alarm_tm.tm_min = from_bcd(value);
         omap_rtc_alarm_update(s);
         return;
 
     case 0x28:	/* ALARM_HOURS_REG */
-#ifdef ALMDEBUG
-        printf("ALM HRS_REG <-- %02x\n", value);
-#endif
         if (s->pm_am)
             s->alarm_tm.tm_hour =
                     ((from_bcd(value & 0x3f)) % 12) +
@@ -2766,33 +2739,21 @@ static void omap_rtc_write(void *opaque, hwaddr addr,
         return;
 
     case 0x2c:	/* ALARM_DAYS_REG */
-#ifdef ALMDEBUG
-        printf("ALM DAY_REG <-- %02x\n", value);
-#endif
         s->alarm_tm.tm_mday = from_bcd(value);
         omap_rtc_alarm_update(s);
         return;
 
     case 0x30:	/* ALARM_MONTHS_REG */
-#ifdef ALMDEBUG
-        printf("ALM MON_REG <-- %02x\n", value);
-#endif
         s->alarm_tm.tm_mon = from_bcd(value);
         omap_rtc_alarm_update(s);
         return;
 
     case 0x34:	/* ALARM_YEARS_REG */
-#ifdef ALMDEBUG
-        printf("ALM YRS_REG <-- %02x\n", value);
-#endif
         s->alarm_tm.tm_year = from_bcd(value);
         omap_rtc_alarm_update(s);
         return;
 
     case 0x40:	/* RTC_CTRL_REG */
-#ifdef ALMDEBUG
-        printf("RTC CONTROL <-- %02x\n", value);
-#endif
         s->pm_am = (value >> 3) & 1;
         s->auto_comp = (value >> 2) & 1;
         s->round = (value >> 1) & 1;
@@ -2802,32 +2763,20 @@ static void omap_rtc_write(void *opaque, hwaddr addr,
         return;
 
     case 0x44:	/* RTC_STATUS_REG */
-#ifdef ALMDEBUG
-        printf("RTC STATUSL <-- %02x\n", value);
-#endif
         s->status &= ~((value & 0xc0) ^ 0x80);
         omap_rtc_interrupts_update(s);
         return;
 
     case 0x48:	/* RTC_INTERRUPTS_REG */
-#ifdef ALMDEBUG
-        printf("RTC INTRS <-- %02x\n", value);
-#endif
         s->interrupts = value;
         return;
 
     case 0x4c:	/* RTC_COMP_LSB_REG */
-#ifdef ALMDEBUG
-        printf("RTC COMPLSB <-- %02x\n", value);
-#endif
         s->comp_reg &= 0xff00;
         s->comp_reg |= 0x00ff & value;
         return;
 
     case 0x50:	/* RTC_COMP_MSB_REG */
-#ifdef ALMDEBUG
-        printf("RTC COMPMSB <-- %02x\n", value);
-#endif
         s->comp_reg &= 0x00ff;
         s->comp_reg |= 0xff00 & (value << 8);
         return;
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/5] hw/arm/omap1: Convert information printfs to tracepoints
  2025-02-27 17:01 [PATCH 0/5] hw/arm: Remove printf() calls Peter Maydell
  2025-02-27 17:01 ` [PATCH 1/5] hw/arm/omap1: Convert raw printfs to qemu_log_mask() Peter Maydell
  2025-02-27 17:01 ` [PATCH 2/5] hw/arm/omap1: Drop ALMDEBUG ifdeffed out code Peter Maydell
@ 2025-02-27 17:01 ` Peter Maydell
  2025-02-27 22:17   ` Philippe Mathieu-Daudé
  2025-02-27 17:01 ` [PATCH 4/5] hw/arm/omap_sx1.c: Remove ifdeffed out debug printf Peter Maydell
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 12+ messages in thread
From: Peter Maydell @ 2025-02-27 17:01 UTC (permalink / raw)
  To: qemu-arm, qemu-devel

The omap1 code uses raw printf() statements to print information
about some events; convert these to tracepoints.

In particular, this will stop the functional test for the sx1
from printing the not-very-helpful note
 "omap_clkm_write: clocking scheme set to synchronous scalable"
to the test's default.log.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/arm/omap1.c      | 27 ++++++++++++++-------------
 hw/arm/trace-events |  7 +++++++
 2 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/hw/arm/omap1.c b/hw/arm/omap1.c
index 8f5bb81c96a..605e733459c 100644
--- a/hw/arm/omap1.c
+++ b/hw/arm/omap1.c
@@ -42,6 +42,7 @@
 #include "qemu/cutils.h"
 #include "qemu/bcd.h"
 #include "target/arm/cpu-qom.h"
+#include "trace.h"
 
 static inline void omap_log_badwidth(const char *funcname, hwaddr addr, int sz)
 {
@@ -1731,8 +1732,7 @@ static void omap_clkm_write(void *opaque, hwaddr addr,
     case 0x18:	/* ARM_SYSST */
         if ((s->clkm.clocking_scheme ^ (value >> 11)) & 7) {
             s->clkm.clocking_scheme = (value >> 11) & 7;
-            printf("%s: clocking scheme set to %s\n", __func__,
-                   clkschemename[s->clkm.clocking_scheme]);
+            trace_omap1_clocking_scheme(clkschemename[s->clkm.clocking_scheme]);
         }
         s->clkm.cold_start &= value & 0x3f;
         return;
@@ -2335,7 +2335,7 @@ static void omap_pwl_update(struct omap_pwl_s *s)
 
     if (output != s->output) {
         s->output = output;
-        printf("%s: Backlight now at %i/256\n", __func__, output);
+        trace_omap1_backlight(output);
     }
 }
 
@@ -2470,8 +2470,8 @@ static void omap_pwt_write(void *opaque, hwaddr addr,
         break;
     case 0x04:	/* VRC */
         if ((value ^ s->vrc) & 1) {
-            if (value & 1)
-                printf("%s: %iHz buzz on\n", __func__, (int)
+            if (value & 1) {
+                trace_omap1_buzz(
                                 /* 1.5 MHz from a 12-MHz or 13-MHz PWT_CLK */
                                 ((omap_clk_getrate(s->clk) >> 3) /
                                  /* Pre-multiplexer divider */
@@ -2487,8 +2487,9 @@ static void omap_pwt_write(void *opaque, hwaddr addr,
                                  /*  80/127 divider */
                                  ((value & (1 << 5)) ?  80 : 127) /
                                  (107 * 55 * 63 * 127)));
-            else
-                printf("%s: silence!\n", __func__);
+            } else {
+                trace_omap1_silence();
+            }
         }
         s->vrc = value & 0x7f;
         break;
@@ -3494,7 +3495,7 @@ static void omap_lpg_tick(void *opaque)
         timer_mod(s->tm, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + s->on);
 
     s->cycle = !s->cycle;
-    printf("%s: LED is %s\n", __func__, s->cycle ? "on" : "off");
+    trace_omap1_led(s->cycle ? "on" : "off");
 }
 
 static void omap_lpg_update(struct omap_lpg_s *s)
@@ -3514,11 +3515,11 @@ static void omap_lpg_update(struct omap_lpg_s *s)
     }
 
     timer_del(s->tm);
-    if (on == period && s->on < s->period)
-        printf("%s: LED is on\n", __func__);
-    else if (on == 0 && s->on)
-        printf("%s: LED is off\n", __func__);
-    else if (on && (on != s->on || period != s->period)) {
+    if (on == period && s->on < s->period) {
+        trace_omap1_led("on");
+    } else if (on == 0 && s->on) {
+        trace_omap1_led("off");
+    } else if (on && (on != s->on || period != s->period)) {
         s->cycle = 0;
         s->on = on;
         s->period = period;
diff --git a/hw/arm/trace-events b/hw/arm/trace-events
index 7790db780e0..70b137a6cfd 100644
--- a/hw/arm/trace-events
+++ b/hw/arm/trace-events
@@ -1,5 +1,12 @@
 # See docs/devel/tracing.rst for syntax documentation.
 
+# omap1.c
+omap1_clocking_scheme(const char *scheme) "omap1 CLKM: clocking scheme set to %s"
+omap1_backlight(int output) "omap1 PWL: backlight now at %d/256"
+omap1_buzz(int freq) "omap1 PWT: %dHz buzz on"
+omap1_silence(void) "omap1 PWT: buzzer silenced"
+omap1_led(const char *onoff) "omap1 LPG: LED is %s"
+
 # virt-acpi-build.c
 virt_acpi_setup(void) "No fw cfg or ACPI disabled. Bailing out."
 
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 4/5] hw/arm/omap_sx1.c: Remove ifdeffed out debug printf
  2025-02-27 17:01 [PATCH 0/5] hw/arm: Remove printf() calls Peter Maydell
                   ` (2 preceding siblings ...)
  2025-02-27 17:01 ` [PATCH 3/5] hw/arm/omap1: Convert information printfs to tracepoints Peter Maydell
@ 2025-02-27 17:01 ` Peter Maydell
  2025-02-27 17:01 ` [PATCH 5/5] hw/arm/versatilepb: Convert printfs to LOG_GUEST_ERROR Peter Maydell
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Peter Maydell @ 2025-02-27 17:01 UTC (permalink / raw)
  To: qemu-arm, qemu-devel

Remove an ifdeffed out debug printf from the static_write() function in
omap_sx1.c. In theory we could turn this into a tracepoint, but for
code this old it doesn't seem worthwhile. We can add tracepoints if
and when we have a reason to debug something.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/arm/omap_sx1.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/hw/arm/omap_sx1.c b/hw/arm/omap_sx1.c
index c6b0bed0796..24b40431832 100644
--- a/hw/arm/omap_sx1.c
+++ b/hw/arm/omap_sx1.c
@@ -76,10 +76,6 @@ static uint64_t static_read(void *opaque, hwaddr offset,
 static void static_write(void *opaque, hwaddr offset,
                          uint64_t value, unsigned size)
 {
-#ifdef SPY
-    printf("%s: value %" PRIx64 " %u bytes written at 0x%x\n",
-                    __func__, value, size, (int)offset);
-#endif
 }
 
 static const MemoryRegionOps static_ops = {
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 5/5] hw/arm/versatilepb: Convert printfs to LOG_GUEST_ERROR
  2025-02-27 17:01 [PATCH 0/5] hw/arm: Remove printf() calls Peter Maydell
                   ` (3 preceding siblings ...)
  2025-02-27 17:01 ` [PATCH 4/5] hw/arm/omap_sx1.c: Remove ifdeffed out debug printf Peter Maydell
@ 2025-02-27 17:01 ` Peter Maydell
  2025-02-27 22:18   ` Philippe Mathieu-Daudé
  2025-02-27 17:49 ` [PATCH 0/5] hw/arm: Remove printf() calls Richard Henderson
  2025-03-03 13:05 ` Philippe Mathieu-Daudé
  6 siblings, 1 reply; 12+ messages in thread
From: Peter Maydell @ 2025-02-27 17:01 UTC (permalink / raw)
  To: qemu-arm, qemu-devel

Convert some printf() calls for attempts to access nonexistent
registers into LOG_GUEST_ERROR logging.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/arm/versatilepb.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c
index 941616cd25b..35766445fa4 100644
--- a/hw/arm/versatilepb.c
+++ b/hw/arm/versatilepb.c
@@ -27,6 +27,7 @@
 #include "qom/object.h"
 #include "audio/audio.h"
 #include "target/arm/cpu-qom.h"
+#include "qemu/log.h"
 
 #define VERSATILE_FLASH_ADDR 0x34000000
 #define VERSATILE_FLASH_SIZE (64 * 1024 * 1024)
@@ -110,7 +111,8 @@ static uint64_t vpb_sic_read(void *opaque, hwaddr offset,
     case 8: /* PICENABLE */
         return s->pic_enable;
     default:
-        printf ("vpb_sic_read: Bad register offset 0x%x\n", (int)offset);
+        qemu_log_mask(LOG_GUEST_ERROR,
+                      "vpb_sic_read: Bad register offset 0x%x\n", (int)offset);
         return 0;
     }
 }
@@ -144,7 +146,8 @@ static void vpb_sic_write(void *opaque, hwaddr offset,
         vpb_sic_update_pic(s);
         break;
     default:
-        printf ("vpb_sic_write: Bad register offset 0x%x\n", (int)offset);
+        qemu_log_mask(LOG_GUEST_ERROR,
+                      "vpb_sic_write: Bad register offset 0x%x\n", (int)offset);
         return;
     }
     vpb_sic_update(s);
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/5] hw/arm: Remove printf() calls
  2025-02-27 17:01 [PATCH 0/5] hw/arm: Remove printf() calls Peter Maydell
                   ` (4 preceding siblings ...)
  2025-02-27 17:01 ` [PATCH 5/5] hw/arm/versatilepb: Convert printfs to LOG_GUEST_ERROR Peter Maydell
@ 2025-02-27 17:49 ` Richard Henderson
  2025-03-03 13:05 ` Philippe Mathieu-Daudé
  6 siblings, 0 replies; 12+ messages in thread
From: Richard Henderson @ 2025-02-27 17:49 UTC (permalink / raw)
  To: qemu-devel

On 2/27/25 09:01, Peter Maydell wrote:
> Peter Maydell (5):
>    hw/arm/omap1: Convert raw printfs to qemu_log_mask()
>    hw/arm/omap1: Drop ALMDEBUG ifdeffed out code
>    hw/arm/omap1: Convert information printfs to tracepoints
>    hw/arm/omap_sx1.c: Remove ifdeffed out debug printf
>    hw/arm/versatilepb: Convert printfs to LOG_GUEST_ERROR

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/5] hw/arm/omap1: Convert raw printfs to qemu_log_mask()
  2025-02-27 17:01 ` [PATCH 1/5] hw/arm/omap1: Convert raw printfs to qemu_log_mask() Peter Maydell
@ 2025-02-27 22:15   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 12+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-02-27 22:15 UTC (permalink / raw)
  To: Peter Maydell, qemu-arm, qemu-devel

On 27/2/25 18:01, Peter Maydell wrote:
> omap1.c is very old code, and it contains numerous calls direct to
> printf() for various error and information cases.
> 
> In this commit, convert the printf() calls that are for either guest
> error or unimplemented functionality to qemu_log_mask() calls.
> 
> This leaves the printf() calls that are informative or which are
> ifdeffed-out debug statements untouched.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   hw/arm/omap1.c | 48 +++++++++++++++++++++++++++++++-----------------
>   1 file changed, 31 insertions(+), 17 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/5] hw/arm/omap1: Drop ALMDEBUG ifdeffed out code
  2025-02-27 17:01 ` [PATCH 2/5] hw/arm/omap1: Drop ALMDEBUG ifdeffed out code Peter Maydell
@ 2025-02-27 22:15   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 12+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-02-27 22:15 UTC (permalink / raw)
  To: Peter Maydell, qemu-arm, qemu-devel

On 27/2/25 18:01, Peter Maydell wrote:
> In omap1.c, there are some debug printfs in the omap_rtc_write()
> function that are guardad by ifdef ALMDEBUG. ALMDEBUG is never
> set, so this is all dead code.
> 
> It's not worth the effort of converting all of these to tracepoints;
> a modern tracepoint approach would probably have a single tracepoint
> covering all the register writes anyway. Just delete the printf()s.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   hw/arm/omap1.c | 51 --------------------------------------------------
>   1 file changed, 51 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/5] hw/arm/omap1: Convert information printfs to tracepoints
  2025-02-27 17:01 ` [PATCH 3/5] hw/arm/omap1: Convert information printfs to tracepoints Peter Maydell
@ 2025-02-27 22:17   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 12+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-02-27 22:17 UTC (permalink / raw)
  To: Peter Maydell, qemu-arm, qemu-devel

On 27/2/25 18:01, Peter Maydell wrote:
> The omap1 code uses raw printf() statements to print information
> about some events; convert these to tracepoints.
> 
> In particular, this will stop the functional test for the sx1
> from printing the not-very-helpful note
>   "omap_clkm_write: clocking scheme set to synchronous scalable"
> to the test's default.log.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   hw/arm/omap1.c      | 27 ++++++++++++++-------------
>   hw/arm/trace-events |  7 +++++++
>   2 files changed, 21 insertions(+), 13 deletions(-)


> diff --git a/hw/arm/trace-events b/hw/arm/trace-events
> index 7790db780e0..70b137a6cfd 100644
> --- a/hw/arm/trace-events
> +++ b/hw/arm/trace-events
> @@ -1,5 +1,12 @@
>   # See docs/devel/tracing.rst for syntax documentation.
>   
> +# omap1.c
> +omap1_clocking_scheme(const char *scheme) "omap1 CLKM: clocking scheme set to %s"
> +omap1_backlight(int output) "omap1 PWL: backlight now at %d/256"

omap1_pwl_...

> +omap1_buzz(int freq) "omap1 PWT: %dHz buzz on"
> +omap1_silence(void) "omap1 PWT: buzzer silenced"

omap1_pwt_...

> +omap1_led(const char *onoff) "omap1 LPG: LED is %s"

omap1_lpg_led

Regardless:
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 5/5] hw/arm/versatilepb: Convert printfs to LOG_GUEST_ERROR
  2025-02-27 17:01 ` [PATCH 5/5] hw/arm/versatilepb: Convert printfs to LOG_GUEST_ERROR Peter Maydell
@ 2025-02-27 22:18   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 12+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-02-27 22:18 UTC (permalink / raw)
  To: Peter Maydell, qemu-arm, qemu-devel

On 27/2/25 18:01, Peter Maydell wrote:
> Convert some printf() calls for attempts to access nonexistent
> registers into LOG_GUEST_ERROR logging.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   hw/arm/versatilepb.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/5] hw/arm: Remove printf() calls
  2025-02-27 17:01 [PATCH 0/5] hw/arm: Remove printf() calls Peter Maydell
                   ` (5 preceding siblings ...)
  2025-02-27 17:49 ` [PATCH 0/5] hw/arm: Remove printf() calls Richard Henderson
@ 2025-03-03 13:05 ` Philippe Mathieu-Daudé
  6 siblings, 0 replies; 12+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-03 13:05 UTC (permalink / raw)
  To: Peter Maydell, qemu-arm, qemu-devel

On 27/2/25 18:01, Peter Maydell wrote:

> Peter Maydell (5):
>    hw/arm/omap1: Convert raw printfs to qemu_log_mask()
>    hw/arm/omap1: Drop ALMDEBUG ifdeffed out code
>    hw/arm/omap1: Convert information printfs to tracepoints
>    hw/arm/omap_sx1.c: Remove ifdeffed out debug printf
>    hw/arm/versatilepb: Convert printfs to LOG_GUEST_ERROR

Thanks, series queued to hw-misc (with the suggested trace event
name changes in patch 3).

Regards,

Phil.



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2025-03-03 13:07 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-27 17:01 [PATCH 0/5] hw/arm: Remove printf() calls Peter Maydell
2025-02-27 17:01 ` [PATCH 1/5] hw/arm/omap1: Convert raw printfs to qemu_log_mask() Peter Maydell
2025-02-27 22:15   ` Philippe Mathieu-Daudé
2025-02-27 17:01 ` [PATCH 2/5] hw/arm/omap1: Drop ALMDEBUG ifdeffed out code Peter Maydell
2025-02-27 22:15   ` Philippe Mathieu-Daudé
2025-02-27 17:01 ` [PATCH 3/5] hw/arm/omap1: Convert information printfs to tracepoints Peter Maydell
2025-02-27 22:17   ` Philippe Mathieu-Daudé
2025-02-27 17:01 ` [PATCH 4/5] hw/arm/omap_sx1.c: Remove ifdeffed out debug printf Peter Maydell
2025-02-27 17:01 ` [PATCH 5/5] hw/arm/versatilepb: Convert printfs to LOG_GUEST_ERROR Peter Maydell
2025-02-27 22:18   ` Philippe Mathieu-Daudé
2025-02-27 17:49 ` [PATCH 0/5] hw/arm: Remove printf() calls Richard Henderson
2025-03-03 13:05 ` Philippe Mathieu-Daudé

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).