hw/misc: Replace DPRINTF with trace events in i.MX CCM family
cover hw/misc: Replace DPRINTF with trace events in i.MX CCM family
This series modernizes the three i.MX CCM device models by removing the old DEBUG_IMX*_CCM / DPRINTF macros and emitting QEMU trace events instead, following the same pattern already merged for hw/timer/imx_epit (commit 5005b00d41).
Patches are split per file so each commit changes one device, keeps git bisect clean, and stays in scope for the trivial-patches team.
No behavior change is intended: the previous DEBUG_IMX_CCM switches defaulted to 0, so DPRINTF output was off by default. After this series the same information is available via -trace 'imx*ccm'.
jack wang (3):
hw/misc/imx_ccm: Replace DPRINTF with trace events hw/misc/imx25_ccm: Replace DPRINTF with trace events hw/misc/imx31_ccm: Replace DPRINTF with trace events
hw/misc/imx25_ccm.c | 34 ++++++++++------------------------ hw/misc/imx31_ccm.c | 33 ++++++++++----------------------- hw/misc/imx_ccm.c | 18 +++--------------- hw/misc/trace-events | 23 +++++++++++++++++++++++ 4 files changed, 46 insertions(+), 62 deletions(-)
Signature · 1 line
2.53.0
PATCH 3/3 hw/misc/imx31_ccm: Replace DPRINTF with trace events
--- hw/misc/imx31_ccm.c | 33 ++++++++++----------------------- hw/misc/trace-events | 10 ++++++++++ 2 files changed, 20 insertions(+), 23 deletions(-)
hw/misc/imx31_ccm.c +10 -23
@@ -16,21 +16,10 @@#include "migration/vmstate.h" #include "qemu/log.h" #include "qemu/module.h" +#include "hw/misc/trace.h" #define CKIH_FREQ 26000000/* 26MHz crystal input */ -#ifndef DEBUG_IMX31_CCM -#define DEBUG_IMX31_CCM 0 -#endif - -#define DPRINTF(fmt, args...) \ - do { \ - if (DEBUG_IMX31_CCM) { \ - fprintf(stderr, "[%s]%s: " fmt , TYPE_IMX31_CCM, \ - __func__, ##args); \ - } \ - } while (0) -static const char *imx31_ccm_reg_name (uint32_t reg) {static char unknown[20 ];
@@ -120,7 +109,7 @@ static uint32_t imx31_ccm_get_pll_ref_clk(IMXCCMState *dev) freq =CKIH_FREQ ; } -DPRINTF ("freq = %u\n" , freq); +trace_imx31_ccm_get_pll_ref_clk (freq);return freq; }
@@ -133,7 +122,7 @@ static uint32_t imx31_ccm_get_mpll_clk(IMXCCMState *dev) freq =imx_ccm_calc_pll (s->reg[IMX31_CCM_MPCTL_REG ],imx31_ccm_get_pll_ref_clk (dev)); -DPRINTF ("freq = %u\n" , freq); +trace_imx31_ccm_get_mpll_clk (freq);return freq; }
@@ -150,7 +139,7 @@ static uint32_t imx31_ccm_get_mcu_main_clk(IMXCCMState *dev) freq =imx31_ccm_get_mpll_clk (dev); } -DPRINTF ("freq = %u\n" , freq); +trace_imx31_ccm_get_mcu_main_clk (freq);return freq; }
@@ -163,7 +152,7 @@ static uint32_t imx31_ccm_get_hclk_clk(IMXCCMState *dev) freq =imx31_ccm_get_mcu_main_clk (dev) / (1 +EXTRACT (s->reg[IMX31_CCM_PDR0_REG ],MAX )); -DPRINTF ("freq = %u\n" , freq); +trace_imx31_ccm_get_hclk_clk (freq);return freq; }
@@ -176,7 +165,7 @@ static uint32_t imx31_ccm_get_ipg_clk(IMXCCMState *dev) freq =imx31_ccm_get_hclk_clk (dev) / (1 +EXTRACT (s->reg[IMX31_CCM_PDR0_REG ],IPG )); -DPRINTF ("freq = %u\n" , freq); +trace_imx31_ccm_get_ipg_clk (freq);return freq; }
@@ -201,7 +190,7 @@ static uint32_t imx31_ccm_get_clock_frequency(IMXCCMState *dev, IMXClk clock)break ; } -DPRINTF ("Clock = %d) = %u\n" , clock, freq); +trace_imx31_ccm_get_clock_frequency (clock, freq);return freq; }
@@ -210,7 +199,7 @@ static void imx31_ccm_reset(DeviceState *dev) {IMX31CCMState *s =IMX31_CCM (dev); -DPRINTF ("()\n" ); +memset (s->reg,0 ,sizeof (uint32_t ) *IMX31_CCM_MAX_REG );
@@ -244,8 +233,7 @@ static uint64_t imx31_ccm_read(void *opaque, hwaddr offset, unsigned size) HWADDR_PRIx "\n", TYPE_IMX31_CCM, __func__, offset); } -DPRINTF ("reg[%s] => 0x%" PRIx32"\n" ,imx31_ccm_reg_name (offset >>2 ), - value); +trace_imx31_ccm_read (imx31_ccm_reg_name (offset >>2 ), value);return (uint64_t )value; }
@@ -255,8 +243,7 @@ static void imx31_ccm_write(void *opaque, hwaddr offset, uint64_t value, {IMX31CCMState *s = (IMX31CCMState *)opaque; -DPRINTF ("reg[%s] <= 0x%" PRIx32"\n" ,imx31_ccm_reg_name (offset >>2 ), - (uint32_t )value); +trace_imx31_ccm_write (imx31_ccm_reg_name (offset >>2 ), value);switch (offset >>2 ) {case IMX31_CCM_CCMR_REG :
hw/misc/trace-events +10 -0
@@ -282,6 +282,16 @@ imx25_ccm_get_clock_frequency(unsigned clock, uint32_t freq) "(clock = %d) = %u" imx25_ccm_read(const char *reg, uint32_t value) "reg[%s] => 0x%" PRIx32 imx25_ccm_write(const char *reg, uint32_t value) "reg[%s] <= 0x%" PRIx32 +# imx31_ccm.c +imx31_ccm_get_mpll_clk(uint32_t freq) "freq = %u" +imx31_ccm_get_pll_ref_clk(uint32_t freq) "freq = %u" +imx31_ccm_get_mcu_main_clk(uint32_t freq) "freq = %u" +imx31_ccm_get_hclk_clk(uint32_t freq) "freq = %u" +imx31_ccm_get_ipg_clk(uint32_t freq) "freq = %u" +imx31_ccm_get_clock_frequency(unsigned clock, uint32_t freq) "(clock = %u) = %u" +imx31_ccm_read(const char *reg, uint32_t value) "reg[%s] => 0x%" PRIx32 +imx31_ccm_write(const char *reg, uint32_t value) "reg[%s] <= 0x%" PRIx32 + # iotkit-sysinfo.c iotkit_sysinfo_read(uint64_t offset, uint64_t data, unsigned size) "IoTKit SysInfo read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" iotkit_sysinfo_write(uint64_t offset, uint64_t data, unsigned size) "IoTKit SysInfo write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
Signature · 1 line
2.53.0
PATCH 1/3 hw/misc/imx_ccm: Replace DPRINTF with trace events
In reply to jack wang--- hw/misc/imx_ccm.c | 18 +++--------------- hw/misc/trace-events | 4 ++++ 2 files changed, 7 insertions(+), 15 deletions(-)
hw/misc/imx_ccm.c +3 -15
@@ -14,18 +14,7 @@#include "qemu/osdep.h" #include "hw/misc/imx_ccm.h" #include "qemu/module.h" - -#ifndef DEBUG_IMX_CCM -#define DEBUG_IMX_CCM 0 -#endif - -#define DPRINTF(fmt, args...) \ - do { \ - if (DEBUG_IMX_CCM) { \ - fprintf(stderr, "[%s]%s: " fmt , TYPE_IMX_CCM, \ - __func__, ##args); \ - } \ - } while (0) +#include "hw/misc/trace.h" uint32_t imx_ccm_get_clock_frequency (IMXCCMState *dev,IMXClk clock)
@@ -37,7 +26,7 @@ uint32_t imx_ccm_get_clock_frequency(IMXCCMState *dev, IMXClk clock) freq = klass->get_clock_frequency (dev, clock); } -DPRINTF ("(clock = %d) = %u\n" , clock, freq); +trace_imx_ccm_get_clock_frequency (clock,freq);return freq; }
@@ -64,8 +53,7 @@ uint32_t imx_ccm_calc_pll(uint32_t pllreg, uint32_t base_freq) freq = ((2 * (base_freq >>10 ) * (mfi * mfd + mfn)) / (mfd * pd)) <<10 ; -DPRINTF ("(pllreg = 0x%08x, base_freq = %u) = %d\n" , pllreg, base_freq, - freq); +trace_imx_ccm_calc_pll (pllreg, base_freq, freq);return freq; }
hw/misc/trace-events +4 -0
@@ -237,6 +237,10 @@ iotkit_secctl_s_write(uint32_t offset, uint64_t data, unsigned size) "IoTKit Sec iotkit_secctl_ns_read(uint32_t offset, uint64_t data, unsigned size) "IoTKit SecCtl NS regs read: offset 0x%x data 0x%" PRIx64 " size %u" iotkit_secctl_ns_write(uint32_t offset, uint64_t data, unsigned size) "IoTKit SecCtl NS regs write: offset 0x%x data 0x%" PRIx64 " size %u" +# imx_ccm.c +imx_ccm_get_clock_frequency(uint32_t clock, uint32_t freq) "(clock = %u) = %u" +imx_ccm_calc_pll(uint32_t pllreq, uint32_t base_freq, uint32_t freq) "(pllreg = 0x%08x, base_freq = %u) = %u" + # imx6_ccm.c imx6_analog_get_periph_clk(uint32_t freq) "freq = %u Hz" imx6_analog_get_pll2_clk(uint32_t freq) "freq = %u Hz"
Signature · 1 line
2.53.0
PATCH 2/3 hw/misc/imx25_ccm: Replace DPRINTF with trace events
In reply to jack wang--- hw/misc/imx25_ccm.c | 34 ++++++++++------------------------ hw/misc/trace-events | 9 +++++++++ 2 files changed, 19 insertions(+), 24 deletions(-)
hw/misc/imx25_ccm.c +10 -24
@@ -16,18 +16,8 @@#include "migration/vmstate.h" #include "qemu/log.h" #include "qemu/module.h" +#include "hw/misc/trace.h" -#ifndef DEBUG_IMX25_CCM -#define DEBUG_IMX25_CCM 0 -#endif - -#define DPRINTF(fmt, args...) \ - do { \ - if (DEBUG_IMX25_CCM) { \ - fprintf(stderr, "[%s]%s: " fmt , TYPE_IMX25_CCM, \ - __func__, ##args); \ - } \ - } while (0)static const char *imx25_ccm_reg_name (uint32_t reg) {
@@ -118,12 +108,12 @@ static uint32_t imx25_ccm_get_mpll_clk(IMXCCMState *dev) freq =imx_ccm_calc_pll (s->reg[IMX25_CCM_MPCTL_REG ],CKIH_FREQ ); } -DPRINTF ("freq = %u\n" , freq); +trace_imx25_ccm_get_mpll_clk (freq);return freq; } -static uint32_t imx25_ccm_get_mcu_clk (IMXCCMState *dev) +static uint32_t imx25_ccm_get_mcu_clk (IMX25CCMState *dev) {uint32_t freq;IMX25CCMState *s =IMX25_CCM (dev);
@@ -136,7 +126,7 @@ static uint32_t imx25_ccm_get_mcu_clk(IMXCCMState *dev) freq = freq / (1 +EXTRACT (s->reg[IMX25_CCM_CCTL_REG ],ARM_CLK_DIV )); -DPRINTF ("freq = %u\n" , freq); +trace_imx25_ccm_get_mcu_clk (freq);return freq; }
@@ -149,7 +139,7 @@ static uint32_t imx25_ccm_get_ahb_clk(IMXCCMState *dev) freq =imx25_ccm_get_mcu_clk (dev) / (1 +EXTRACT (s->reg[IMX25_CCM_CCTL_REG ],AHB_CLK_DIV )); -DPRINTF ("freq = %u\n" , freq); +trace_imx25_ccm_get_ahb_clk (freq);return freq; }
@@ -160,7 +150,7 @@ static uint32_t imx25_ccm_get_ipg_clk(IMXCCMState *dev) freq =imx25_ccm_get_ahb_clk (dev) /2 ; -DPRINTF ("freq = %u\n" , freq); +trace_imx25_ccm_get_ipg_clk (freq);return freq; }
@@ -168,7 +158,7 @@ static uint32_t imx25_ccm_get_ipg_clk(IMXCCMState *dev)static uint32_t imx25_ccm_get_clock_frequency (IMXCCMState *dev,IMXClk clock) {uint32_t freq =0 ; -DPRINTF ("Clock = %d)\n" , clock); +trace_imx25_ccm_get_clock_frequency (clock, freq);switch (clock) {case CLK_NONE :
@@ -186,7 +176,7 @@ static uint32_t imx25_ccm_get_clock_frequency(IMXCCMState *dev, IMXClk clock)break ; } -DPRINTF ("Clock = %d) = %u\n" , clock, freq); +trace_imx25_ccm_get_clock_frequency (clock, freq);return freq; }
@@ -195,8 +185,6 @@ static void imx25_ccm_reset(DeviceState *dev) {IMX25CCMState *s =IMX25_CCM (dev); -DPRINTF ("\n" ); -memset (s->reg,0 ,IMX25_CCM_MAX_REG *sizeof (uint32_t )); s->reg[IMX25_CCM_MPCTL_REG ] =0x800b2c01 ; s->reg[IMX25_CCM_UPCTL_REG ] =0x84042800 ;
@@ -238,8 +226,7 @@ static uint64_t imx25_ccm_read(void *opaque, hwaddr offset, unsigned size) HWADDR_PRIx "\n", TYPE_IMX25_CCM, __func__, offset); } -DPRINTF ("reg[%s] => 0x%" PRIx32"\n" ,imx25_ccm_reg_name (offset >>2 ), - value); +trace_imx25_ccm_read (imx25_ccm_reg_name (offset >>2 ), value);return value; }
@@ -249,8 +236,7 @@ static void imx25_ccm_write(void *opaque, hwaddr offset, uint64_t value, {IMX25CCMState *s = (IMX25CCMState *)opaque; -DPRINTF ("reg[%s] <= 0x%" PRIx32"\n" ,imx25_ccm_reg_name (offset >>2 ), - (uint32_t )value); +trace_imx25_ccm_write (imx25_ccm_reg_name (offset >>2 ), (uint32_t )value);if (offset <0x70 ) {/*
hw/misc/trace-events +9 -0
@@ -273,6 +273,15 @@ imx6_src_reset(void) "" imx7_src_read(const char *reg_name, uint32_t value) "reg[%s] => 0x%" PRIx32 imx7_src_write(const char *reg_name, uint32_t value) "reg[%s] <= 0x%" PRIx32 +# imx25_ccm.c +imx25_ccm_get_mpll_clk(uint32_t freq) "freq = %u" +imx25_ccm_get_mcu_clk(uint32_t freq) "freq = %u" +imx25_ccm_get_ahb_clk(uint32_t freq) "freq = %u" +imx25_ccm_get_ipg_clk(uint32_t freq) "freq = %u" +imx25_ccm_get_clock_frequency(unsigned clock, uint32_t freq) "(clock = %d) = %u" +imx25_ccm_read(const char *reg, uint32_t value) "reg[%s] => 0x%" PRIx32 +imx25_ccm_write(const char *reg, uint32_t value) "reg[%s] <= 0x%" PRIx32 + # iotkit-sysinfo.c iotkit_sysinfo_read(uint64_t offset, uint64_t data, unsigned size) "IoTKit SysInfo read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" iotkit_sysinfo_write(uint64_t offset, uint64_t data, unsigned size) "IoTKit SysInfo write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
Signature · 1 line
2.53.0
Re: [PATCH 1/3] hw/misc/imx_ccm: Replace DPRINTF with trace events
In reply to jack wanghw/misc/imx_ccm.c uint32_t imx_ccm_get_clock_frequency(IMXCCMState *dev, IMXClk clock) · line 29
Quoted 13 lines · jack wang
--- hw/misc/imx_ccm.c | 18 +++--------------- hw/misc/trace-events | 4 ++++ 2 files changed, 7 insertions(+), 15 deletions(-)
uint32_timx_ccm_get_clock_frequency(IMXCCMState *dev, IMXClk clock)hw/misc/imx_ccm.c +1
-1@@ -37,7 +26,7 @@ uint32_t imx_ccm_get_clock_frequency(IMXCCMState *dev, IMXClk clock) freq = klass->get_clock_frequency (dev, clock); } -DPRINTF ("(clock = %d) = %u\n" , clock, freq); +trace_imx_ccm_get_clock_frequency (clock,freq);
Our coding style wants a space after this comma. (Running your patches through scripts/checkpatch.pl can catch this kind of style nit, though it sometimes has false positives.)
Otherwise
thanks
-- PMM
Re: [PATCH 2/3] hw/misc/imx25_ccm: Replace DPRINTF with trace events
In reply to jack wangQuoted 5 lines · jack wang
--- hw/misc/imx25_ccm.c | 34 ++++++++++------------------------ hw/misc/trace-events | 9 +++++++++ 2 files changed, 19 insertions(+), 24 deletions(-)
This patch and patch 3 are missing your Signed-off-by:
line; we can't take them without it.
hw/misc/imx25_ccm.c static void imx25_ccm_write(void *opaque, hwaddr offset, uint64_t value, · line 239
Quoted 3 lines
hw/misc/imx25_ccm.c +1
-2-DPRINTF ("reg[%s] <= 0x%" PRIx32"\n" ,imx25_ccm_reg_name (offset >>2 ), - (uint32_t )value); +trace_imx25_ccm_write (imx25_ccm_reg_name (offset >>2 ), (uint32_t )value);
You can drop the uint32_t cast here. We needed it with DPRINTF because that's a variadic function. But the trace version is a normal function and because the argument's type there is uint32_t C will do the conversion for us automatically.
Otherwise
thanks
-- PMM
Re: [PATCH 3/3] hw/misc/imx31_ccm: Replace DPRINTF with trace events
In reply to jack wangQuoted 5 lines · jack wang
--- hw/misc/imx31_ccm.c | 33 ++++++++++----------------------- hw/misc/trace-events | 10 ++++++++++ 2 files changed, 20 insertions(+), 23 deletions(-)
Other than the missing signed-off-by line,
thanks
-- PMM