qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>
Cc: Sarah Harris <S.E.Harris@kent.ac.uk>,
	qemu-devel@nongnu.org,
	Aleksandar Markovic <aleksandar.markovic@rt-rk.com>,
	Michael Rolnik <mrolnik@gmail.com>,
	Aleksandar Markovic <amarkovic@wavecomp.com>,
	Aleksandar Markovic <aleksandar.m.mail@gmail.com>
Subject: Re: [PATCH 2/2] !fixup "hw/timer: Add limited support for AVR 16-bit timer peripheral"
Date: Fri, 31 Jan 2020 11:31:24 +0000	[thread overview]
Message-ID: <87pnez981f.fsf@linaro.org> (raw)
In-Reply-To: <20200131010941.10636-3-philmd@redhat.com>


Philippe Mathieu-Daudé <philmd@redhat.com> writes:

> Convert DB_PRINT() to trace events.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  hw/timer/avr_timer16.c | 25 +++++++++++++++----------
>  hw/timer/trace-events  | 12 ++++++++++++
>  2 files changed, 27 insertions(+), 10 deletions(-)
>
> diff --git a/hw/timer/avr_timer16.c b/hw/timer/avr_timer16.c
> index 4e16afc61c..073f36aa76 100644
> --- a/hw/timer/avr_timer16.c
> +++ b/hw/timer/avr_timer16.c
> @@ -36,6 +36,7 @@
>  #include "qemu/log.h"
>  #include "hw/irq.h"
>  #include "hw/qdev-properties.h"
> +#include "trace.h"
>  
>  /* Register offsets */
>  #define T16_CRA     0x0
> @@ -104,7 +105,6 @@
>  /* Helper macros */
>  #define VAL16(l, h) ((h << 8) | l)
>  #define DB_PRINT(fmt, args...) /* Nothing */
> -/*#define DB_PRINT(fmt, args...) printf("%s: " fmt "\n", __func__, ## args)*/
>  
>  static inline int64_t avr_timer16_ns_to_ticks(AVRTimer16State *t16, int64_t t)
>  {
> @@ -168,8 +168,8 @@ static void avr_timer16_clksrc_update(AVRTimer16State *t16)
>      if (divider) {
>          t16->freq_hz = t16->cpu_freq_hz / divider;
>          t16->period_ns = NANOSECONDS_PER_SECOND / t16->freq_hz;
> -        DB_PRINT("Timer frequency %" PRIu64 " hz, period %" PRIu64 " ns (%f s)",
> -                 t16->freq_hz, t16->period_ns, 1 / (double)t16->freq_hz);
> +        trace_avr_timer16_clksrc_update(t16->freq_hz, t16->period_ns,
> +                                        (uint64_t)(1e6 /
>  t16->freq_hz));

Is it worth including a computed value here?

>      }
>  }
>  
> @@ -235,8 +235,7 @@ static void avr_timer16_set_alarm(AVRTimer16State *t16)
>          t16->reset_time_ns + ((CNT(t16) + alarm_offset) * t16->period_ns);
>      timer_mod(t16->timer, alarm_ns);
>  
> -    DB_PRINT("next alarm %" PRIu64 " ns from now",
> -        alarm_offset * t16->period_ns);
> +    trace_avr_timer16_next_alarm(alarm_offset * t16->period_ns);
>  }
>  
>  static void avr_timer16_interrupt(void *opaque)
> @@ -253,11 +252,11 @@ static void avr_timer16_interrupt(void *opaque)
>          return;
>      }
>  
> -    DB_PRINT("interrupt, cnt = %d", CNT(t16));
> +    trace_avr_timer16_interrupt_count(CNT(t16));
>  
>      /* Counter overflow */
>      if (t16->next_interrupt == OVERFLOW) {
> -        DB_PRINT("0xffff overflow");
> +        trace_avr_timer16_interrupt_overflow("counter 0xffff");
>          avr_timer16_clock_reset(t16);
>          if (t16->imsk & T16_INT_TOV) {
>              t16->ifr |= T16_INT_TOV;
> @@ -266,12 +265,12 @@ static void avr_timer16_interrupt(void *opaque)
>      }
>      /* Check for ocra overflow in CTC mode */
>      if (mode == T16_MODE_CTC_OCRA && t16->next_interrupt == COMPA) {
> -        DB_PRINT("CTC OCRA overflow");
> +        trace_avr_timer16_interrupt_overflow("CTC OCRA");
>          avr_timer16_clock_reset(t16);
>      }
>      /* Check for icr overflow in CTC mode */
>      if (mode == T16_MODE_CTC_ICR && t16->next_interrupt == CAPT) {
> -        DB_PRINT("CTC ICR overflow");
> +        trace_avr_timer16_interrupt_overflow("CTC ICR");

Rather than spamming strings to the trace log I'd suggest expanding
trace_avr_timer16_interrupt_count to include the mode and next_interrupt
state as hex values.

>          avr_timer16_clock_reset(t16);
>          if (t16->imsk & T16_INT_IC) {
>              t16->ifr |= T16_INT_IC;
> @@ -367,6 +366,8 @@ static uint64_t avr_timer16_read(void *opaque, hwaddr offset, unsigned size)
>      default:
>          break;
>      }
> +    trace_avr_timer16_read(offset, retval);
> +
>      return (uint64_t)retval;
>  }
>  
> @@ -378,7 +379,7 @@ static void avr_timer16_write(void *opaque, hwaddr offset,
>      uint8_t val8 = (uint8_t)val64;
>      uint8_t prev_clk_src = CLKSRC(t16);
>  
> -    DB_PRINT("write %d to offset %d", val8, (uint8_t)offset);
> +    trace_avr_timer16_write(offset, val8);
>  
>      switch (offset) {
>      case T16_CRA:
> @@ -475,6 +476,7 @@ static uint64_t avr_timer16_imsk_read(void *opaque,
>  {
>      assert(size == 1);
>      AVRTimer16State *t16 = opaque;
> +    trace_avr_timer16_read_imsk(offset ? 0 : t16->imsk);
>      if (offset != 0) {
>          return 0;
>      }
> @@ -486,6 +488,7 @@ static void avr_timer16_imsk_write(void *opaque, hwaddr offset,
>  {
>      assert(size == 1);
>      AVRTimer16State *t16 = opaque;
> +    trace_avr_timer16_write_imsk(val64);
>      if (offset != 0) {
>          return;
>      }
> @@ -498,6 +501,7 @@ static uint64_t avr_timer16_ifr_read(void *opaque,
>  {
>      assert(size == 1);
>      AVRTimer16State *t16 = opaque;
> +    trace_avr_timer16_read_ifr(offset ? 0 : t16->ifr);
>      if (offset != 0) {
>          return 0;
>      }
> @@ -509,6 +513,7 @@ static void avr_timer16_ifr_write(void *opaque, hwaddr offset,
>  {
>      assert(size == 1);
>      AVRTimer16State *t16 = opaque;
> +    trace_avr_timer16_write_imsk(val64);
>      if (offset != 0) {
>          return;
>      }
> diff --git a/hw/timer/trace-events b/hw/timer/trace-events
> index 29fda7870e..5d9f4c93fb 100644
> --- a/hw/timer/trace-events
> +++ b/hw/timer/trace-events
> @@ -74,3 +74,15 @@ nrf51_timer_write(uint64_t addr, uint32_t value, unsigned size) "write addr 0x%"
>  bcm2835_systmr_irq(bool enable) "timer irq state %u"
>  bcm2835_systmr_read(uint64_t offset, uint64_t data) "timer read: offset 0x%" PRIx64 " data 0x%" PRIx64
>  bcm2835_systmr_write(uint64_t offset, uint64_t data) "timer write: offset 0x%" PRIx64 " data 0x%" PRIx64
> +
> +# avr_timer16.c
> +avr_timer16_read(uint8_t addr, uint8_t value) "timer16 read addr:%u value:%u"
> +avr_timer16_read_ifr(uint8_t value) "timer16 read addr:ifr value:%u"
> +avr_timer16_read_imsk(uint8_t value) "timer16 read addr:imsk value:%u"
> +avr_timer16_write(uint8_t addr, uint8_t value) "timer16 write addr:%u value:%u"
> +avr_timer16_write_ifr(uint8_t value) "timer16 write addr:ifr value:%u"
> +avr_timer16_write_imsk(uint8_t value) "timer16 write addr:imsk value:%u"
> +avr_timer16_interrupt_count(uint8_t cnt) "count: %u"
> +avr_timer16_interrupt_overflow(const char *reason) "overflow: %s"
> +avr_timer16_next_alarm(uint64_t delay_ns) "next alarm: %" PRIu64 " ns from now"
> +avr_timer16_clksrc_update(uint64_t freq_hz, uint64_t period_ns, uint64_t delay_s) "timer frequency: %" PRIu64 " Hz, period: %" PRIu64 " ns (%" PRId64 " us)"


-- 
Alex Bennée


  reply	other threads:[~2020-01-31 11:33 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-31  0:02 [PATCH rc4 00/29] target/avr merger Aleksandar Markovic
2020-01-31  0:02 ` [PATCH rc4 01/29] target/avr: Add basic parameters for new AVR platform Aleksandar Markovic
2020-01-31 18:47   ` Aleksandar Markovic
2020-01-31 19:23   ` Aleksandar Markovic
2020-01-31 20:07   ` Aleksandar Markovic
2020-01-31  0:02 ` [PATCH rc4 02/29] target/avr: Introduce AVR CPU class object Aleksandar Markovic
2020-01-31  0:02 ` [PATCH rc4 03/29] target/avr: Add migration support Aleksandar Markovic
2020-01-31  0:02 ` [PATCH rc4 04/29] target/avr: Add GDB support Aleksandar Markovic
2020-01-31  0:02 ` [PATCH rc4 05/29] target/avr: Introduce enumeration AVRFeature Aleksandar Markovic
2020-01-31  0:02 ` [PATCH rc4 06/29] target/avr: Add defintions of AVR core types Aleksandar Markovic
2020-02-02 15:40   ` Joaquin de Andres
2020-02-08  7:35     ` Aleksandar Markovic
2020-02-10  7:39       ` Michael Rolnik
2020-02-21 11:03         ` Michael Rolnik
2020-02-21 15:31           ` Aleksandar Markovic
2020-02-27  8:38             ` Michael Rolnik
2020-03-06 13:34               ` Michael Rolnik
2020-06-16  8:56                 ` Philippe Mathieu-Daudé
2020-06-29  9:51                 ` Philippe Mathieu-Daudé
2020-01-31  0:02 ` [PATCH rc4 07/29] target/avr: Add instruction helpers Aleksandar Markovic
2020-02-01 12:27   ` Aleksandar Markovic
2020-01-31  0:02 ` [PATCH rc4 08/29] target/avr: Add instruction translation - Register definitions Aleksandar Markovic
2020-01-31  0:02 ` [PATCH rc4 09/29] target/avr: Add instruction translation - Arithmetic and Logic Instructions Aleksandar Markovic
2020-01-31  0:02 ` [PATCH rc4 10/29] target/avr: Add instruction translation - Branch Instructions Aleksandar Markovic
2020-01-31  0:02 ` [PATCH rc4 11/29] target/avr: Add instruction translation - Data Transfer Instructions Aleksandar Markovic
2020-01-31  0:02 ` [PATCH rc4 12/29] target/avr: Add instruction translation - Bit and Bit-test Instructions Aleksandar Markovic
2020-01-31  0:02 ` [PATCH rc4 13/29] target/avr: Add instruction translation - MCU Control Instructions Aleksandar Markovic
2020-01-31  0:02 ` [PATCH rc4 14/29] target/avr: Add instruction translation - CPU main translation function Aleksandar Markovic
2020-01-31  0:02 ` [PATCH rc4 15/29] target/avr: Add instruction disassembly function Aleksandar Markovic
2020-01-31  0:03 ` [PATCH rc4 16/29] hw/char: Add limited support for AVR USART peripheral Aleksandar Markovic
2020-01-31  0:03 ` [PATCH rc4 17/29] hw/timer: Add limited support for AVR 16-bit timer peripheral Aleksandar Markovic
2020-01-31  0:03 ` [PATCH rc4 18/29] hw/misc: Add limited support for AVR power device Aleksandar Markovic
2020-01-31  0:03 ` [PATCH rc4 19/29] target/avr: Add section about AVR into QEMU documentation Aleksandar Markovic
2020-02-01 13:19   ` Aleksandar Markovic
2020-01-31  0:03 ` [PATCH rc4 20/29] target/avr: Register AVR support with the rest of QEMU Aleksandar Markovic
2020-01-31  0:23   ` Philippe Mathieu-Daudé
2020-01-31  0:27     ` Aleksandar Markovic
2020-01-31  0:03 ` [PATCH rc4 21/29] target/avr: Add machine none test Aleksandar Markovic
2020-01-31  0:03 ` [PATCH rc4 22/29] target/avr: Update MAINTAINERS file Aleksandar Markovic
2020-01-31  0:03 ` [PATCH rc4 23/29] hw/avr: Add helper to load raw/ELF firmware binaries Aleksandar Markovic
2020-01-31  0:20   ` Philippe Mathieu-Daudé
2020-01-31  0:26     ` Aleksandar Markovic
2020-01-31  0:28       ` Philippe Mathieu-Daudé
2020-01-31  0:30         ` Aleksandar Markovic
2020-01-31  0:03 ` [PATCH rc4 24/29] hw/avr: Add some ATmega microcontrollers Aleksandar Markovic
2020-01-31  1:56   ` Aleksandar Markovic
2020-01-31  3:09     ` Philippe Mathieu-Daudé
2020-01-31  3:45       ` Aleksandar Markovic
2020-01-31  4:11         ` Aleksandar Markovic
2020-01-31  9:35           ` Thomas Huth
2020-01-31  9:40             ` Aleksandar Markovic
2020-01-31 10:45               ` Philippe Mathieu-Daudé
2020-01-31 11:07                 ` Aleksandar Markovic
2020-01-31  0:03 ` [PATCH rc4 25/29] hw/avr: Add some Arduino boards Aleksandar Markovic
2020-01-31  0:03 ` [PATCH rc4 26/29] target/avr: Update build system Aleksandar Markovic
2020-02-04 22:58   ` Aleksandar Markovic
2020-01-31  0:03 ` [PATCH rc4 27/29] tests/boot-serial-test: Test some Arduino boards (AVR based) Aleksandar Markovic
2020-01-31  0:03 ` [PATCH rc4 28/29] tests/acceptance: Test the Arduino MEGA2560 board Aleksandar Markovic
2020-01-31  0:03 ` [PATCH rc4 29/29] .travis.yml: Run the AVR acceptance tests Aleksandar Markovic
2020-01-31  0:12 ` [PATCH rc4 00/29] target/avr merger Aleksandar Markovic
2020-01-31  1:23   ` Philippe Mathieu-Daudé
2020-01-31 14:43     ` Michael Rolnik
2020-01-31  1:09 ` [PATCH 0/2] !fixup target/avr merger-rc4 Philippe Mathieu-Daudé
2020-01-31  1:09   ` [PATCH 1/2] !fixup "hw/misc: Add limited support for AVR power device" Philippe Mathieu-Daudé
2020-01-31 11:27     ` Alex Bennée
2020-01-31 12:39       ` Philippe Mathieu-Daudé
2020-01-31 14:52         ` Alex Bennée
2020-01-31  1:09   ` [PATCH 2/2] !fixup "hw/timer: Add limited support for AVR 16-bit timer peripheral" Philippe Mathieu-Daudé
2020-01-31 11:31     ` Alex Bennée [this message]
2020-01-31  1:12   ` [PATCH 0/2] !fixup target/avr merger-rc4 Aleksandar Markovic

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pnez981f.fsf@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=S.E.Harris@kent.ac.uk \
    --cc=aleksandar.m.mail@gmail.com \
    --cc=aleksandar.markovic@rt-rk.com \
    --cc=amarkovic@wavecomp.com \
    --cc=mrolnik@gmail.com \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).