hw/misc/imx_ccm: Replace DPRINTF with trace events
PATCH v3 1/3 hw/misc/imx_ccm: Replace DPRINTF with trace events
--- 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 v3 1/1 hw/timer/imx_epit: Replace DPRINTF with trace events
Clean up the codebase by removing the outdated DEBUG_IMX_EPIT and DPRINTF macros, replacing them with modern QEMU trace events.
This also removes an empty and meaningless DPRINTF("\n") in the imx_epit_realize function.
--- hw/timer/imx_epit.c | 25 +++++-------------------- hw/timer/trace-events | 8 ++++++++ 2 files changed, 13 insertions(+), 20 deletions(-)
hw/timer/imx_epit.c +5 -20
@@ -20,18 +20,7 @@#include "hw/misc/imx_ccm.h" #include "qemu/module.h" #include "qemu/log.h" - -#ifndef DEBUG_IMX_EPIT -#define DEBUG_IMX_EPIT 0 -#endif - -#define DPRINTF(fmt, args...) \ - do { \ - if (DEBUG_IMX_EPIT) { \ - fprintf(stderr, "[%s]%s: " fmt , TYPE_IMX_EPIT, \ - __func__, ##args); \ - } \ - } while (0) +#include "trace.h" static const char *imx_epit_reg_name (uint32_t reg) {
@@ -80,7 +69,7 @@ static uint32_t imx_epit_get_freq(IMXEPITState *s)uint32_t prescaler =1 +extract32 (s->cr,CR_PRESCALE_SHIFT ,CR_PRESCALE_BITS );uint32_t f_in =imx_ccm_get_clock_frequency (s->ccm, imx_epit_clocks[clksrc]);uint32_t freq = f_in / prescaler; -DPRINTF ("ptimer frequency is %u\n" , freq); +trace_imx_epit_get_freq (freq);return freq; }
@@ -146,8 +135,7 @@ static uint64_t imx_epit_read(void *opaque, hwaddr offset, unsigned size) HWADDR_PRIx "\n", TYPE_IMX_EPIT, __func__, offset);break ; } - -DPRINTF ("(%s) = 0x%08x\n" ,imx_epit_reg_name (offset >>2 ), reg_value); +trace_imx_epit_read (imx_epit_reg_name (offset >>2 ), reg_value);return reg_value; }
@@ -328,8 +316,7 @@ static void imx_epit_write(void *opaque, hwaddr offset, uint64_t value, {IMXEPITState *s =IMX_EPIT (opaque); -DPRINTF ("(%s, value = 0x%08x)\n" ,imx_epit_reg_name (offset >>2 ), - (uint32_t )value); +trace_imx_epit_write (imx_epit_reg_name (offset >>2 ), value);switch (offset >>2 ) {case 0 :/* CR */
@@ -362,7 +349,7 @@ static void imx_epit_cmp(void *opaque)/* The cmp ptimer can't be running when the peripheral is disabled */ assert (s->cr &CR_EN ); -DPRINTF ("sr was %d\n" , s->sr); +trace_imx_epit_cmp (s->sr);/* Set interrupt status bit SR.OCIF and update the interrupt state */ s->sr |=SR_OCIF ;imx_epit_update_int (s);
@@ -399,8 +386,6 @@ static void imx_epit_realize(DeviceState *dev, Error **errp)IMXEPITState *s =IMX_EPIT (dev);SysBusDevice *sbd =SYS_BUS_DEVICE (dev); -DPRINTF ("\n" ); -sysbus_init_irq (sbd, &s->irq);memory_region_init_io (&s->iomem,OBJECT (s), &imx_epit_ops, s,TYPE_IMX_EPIT ,0x00001000 );
hw/timer/trace-events +8 -0
@@ -122,3 +122,11 @@ hpet_ram_write_tn_cmp(uint8_t reg_off) "hpet_ram_writel HPET_TN_CMP + %" PRIu8 hpet_ram_write_invalid_tn_cmp(void) "invalid HPET_TN_CMP + 4 write" hpet_ram_write_invalid(void) "invalid hpet_ram_writel" hpet_ram_write_counter_write_while_enabled(void) "Writing counter while HPET enabled!" + +# imx_epit.c +imx_epit_get_freq(uint32_t freq) "ptimer frequency is %u" +imx_epit_read(const char *name, uint32_t value) "(%s) = 0x%08x" +imx_epit_write(const char *name, uint64_t value) "(%s, value = 0x%08" PRIx64 ")" +imx_epit_cmp(uint32_t sr) "sr was %d" + +
Signature · 1 line
2.53.0
PATCH v3 3/3 hw/misc/imx31_ccm: Replace DPRINTF with trace events
In reply to jack wang--- 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 v3 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 ), 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 v3 2/3] hw/misc/imx25_ccm: Replace DPRINTF with trace events
Quoted 13 lines · jack wang
Signed-off-by jack wang <[email protected]>Reviewed-by Peter Maydell <[email protected]>--- hw/misc/imx25_ccm.c | 34 ++++++++++------------------------ hw/misc/trace-events | 9 +++++++++ 2 files changed, 19 insertions(+), 24 deletions(-)hw/misc/imx25_ccm.c +0
-0
hw/misc/imx25_ccm.c line 19
Quoted 4 lines
hw/misc/imx25_ccm.c +1
-0@@ -16,18 +16,8 @@#include "migration/vmstate.h" #include "qemu/log.h" #include "qemu/module.h" +#include "hw/misc/trace.h"
For trace headers, we recommend just "trace.h".
Quoted 17 lines
hw/misc/imx25_ccm.c +0
-11-#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 );
hw/misc/imx25_ccm.c static uint32_t imx25_ccm_get_mpll_clk(IMXCCMState *dev) · line 116
Quoted 10 lines
hw/misc/imx25_ccm.c +2
-2} -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)
This is an unrelated change, and it causes the file to not compile.
Patches should change one thing at a time, and you should always test them before sending, please.
thanks
-- PMM
Quoted 8 lines · jack wang
Signed-off-by jack wang <[email protected]>Reviewed-by Peter Maydell <[email protected]>--- hw/misc/imx_ccm.c | 18 +++--------------- hw/misc/trace-events | 4 ++++ 2 files changed, 7 insertions(+), 15 deletions(-)
It looks like you didn't send a cover letter for this v3 version, which makes the series harder to deal with. Anyway, I have applied it to target-arm.next and fixed up the compile errors. Thanks for your contribution, but please be more careful with testing for future patches.
-- PMM