From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>,
qemu-arm@nongnu.org, qemu-devel@nongnu.org
Cc: patches@linaro.org
Subject: Re: [Qemu-devel] [PATCH 04/14] hw/timer/pl031: Convert to using trace events
Date: Mon, 18 Feb 2019 22:58:43 +0100 [thread overview]
Message-ID: <e0cac3ef-d2b9-5b2c-cb24-599a63695663@redhat.com> (raw)
In-Reply-To: <20190214125107.22178-5-peter.maydell@linaro.org>
On 2/14/19 1:50 PM, Peter Maydell wrote:
> Convert the debug printing in the PL031 device to use trace events,
> and augment it to cover the interesting parts of device operation.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> hw/timer/pl031.c | 55 +++++++++++++++++++++++--------------------
> hw/timer/trace-events | 6 +++++
> 2 files changed, 36 insertions(+), 25 deletions(-)
>
> diff --git a/hw/timer/pl031.c b/hw/timer/pl031.c
> index f774dcd5223..274ad47a33a 100644
> --- a/hw/timer/pl031.c
> +++ b/hw/timer/pl031.c
> @@ -18,15 +18,7 @@
> #include "sysemu/sysemu.h"
> #include "qemu/cutils.h"
> #include "qemu/log.h"
> -
> -//#define DEBUG_PL031
> -
> -#ifdef DEBUG_PL031
> -#define DPRINTF(fmt, ...) \
> -do { printf("pl031: " fmt , ## __VA_ARGS__); } while (0)
> -#else
> -#define DPRINTF(fmt, ...) do {} while(0)
> -#endif
> +#include "trace.h"
>
> #define RTC_DR 0x00 /* Data read register */
> #define RTC_MR 0x04 /* Match register */
> @@ -44,7 +36,10 @@ static const unsigned char pl031_id[] = {
>
> static void pl031_update(PL031State *s)
> {
> - qemu_set_irq(s->irq, s->is & s->im);
> + uint32_t flags = s->is & s->im;
> +
> + trace_pl031_irq_state(flags);
> + qemu_set_irq(s->irq, flags);
> }
>
> static void pl031_interrupt(void * opaque)
> @@ -52,7 +47,7 @@ static void pl031_interrupt(void * opaque)
> PL031State *s = (PL031State *)opaque;
>
> s->is = 1;
> - DPRINTF("Alarm raised\n");
> + trace_pl031_alarm_raised();
> pl031_update(s);
> }
>
> @@ -69,7 +64,7 @@ static void pl031_set_alarm(PL031State *s)
> /* The timer wraps around. This subtraction also wraps in the same way,
> and gives correct results when alarm < now_ticks. */
> ticks = s->mr - pl031_get_count(s);
> - DPRINTF("Alarm set in %ud ticks\n", ticks);
> + trace_pl031_set_alarm(ticks);
> if (ticks == 0) {
> timer_del(s->timer);
> pl031_interrupt(s);
> @@ -83,38 +78,49 @@ static uint64_t pl031_read(void *opaque, hwaddr offset,
> unsigned size)
> {
> PL031State *s = (PL031State *)opaque;
> -
> - if (offset >= 0xfe0 && offset < 0x1000)
> - return pl031_id[(offset - 0xfe0) >> 2];
> + uint64_t r;
>
> switch (offset) {
> case RTC_DR:
> - return pl031_get_count(s);
> + r = pl031_get_count(s);
> + break;
> case RTC_MR:
> - return s->mr;
> + r = s->mr;
> + break;
> case RTC_IMSC:
> - return s->im;
> + r = s->im;
> + break;
> case RTC_RIS:
> - return s->is;
> + r = s->is;
> + break;
> case RTC_LR:
> - return s->lr;
> + r = s->lr;
> + break;
> case RTC_CR:
> /* RTC is permanently enabled. */
> - return 1;
> + r = 1;
> + break;
> case RTC_MIS:
> - return s->is & s->im;
> + r = s->is & s->im;
> + break;
> + case 0xfe0 ... 0xfff:
> + r = pl031_id[(offset - 0xfe0) >> 2];
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> + break;
> case RTC_ICR:
> qemu_log_mask(LOG_GUEST_ERROR,
> "pl031: read of write-only register at offset 0x%x\n",
> (int)offset);
> + r = 0;
> break;
> default:
> qemu_log_mask(LOG_GUEST_ERROR,
> "pl031_read: Bad offset 0x%x\n", (int)offset);
> + r = 0;
> break;
> }
>
> - return 0;
> + trace_pl031_read(offset, r);
> + return r;
> }
>
> static void pl031_write(void * opaque, hwaddr offset,
> @@ -122,6 +128,7 @@ static void pl031_write(void * opaque, hwaddr offset,
> {
> PL031State *s = (PL031State *)opaque;
>
> + trace_pl031_write(offset, value);
>
> switch (offset) {
> case RTC_LR:
> @@ -134,7 +141,6 @@ static void pl031_write(void * opaque, hwaddr offset,
> break;
> case RTC_IMSC:
> s->im = value & 1;
> - DPRINTF("Interrupt mask %d\n", s->im);
> pl031_update(s);
> break;
> case RTC_ICR:
> @@ -142,7 +148,6 @@ static void pl031_write(void * opaque, hwaddr offset,
> cleared when bit 0 of the written value is set. However the
> arm926e documentation (DDI0287B) states that the interrupt is
> cleared when any value is written. */
> - DPRINTF("Interrupt cleared");
> s->is = 0;
> pl031_update(s);
> break;
> diff --git a/hw/timer/trace-events b/hw/timer/trace-events
> index 0144a68951c..12eb505fee7 100644
> --- a/hw/timer/trace-events
> +++ b/hw/timer/trace-events
> @@ -77,3 +77,9 @@ xlnx_zynqmp_rtc_gettime(int year, int month, int day, int hour, int min, int sec
> nrf51_timer_read(uint64_t addr, uint32_t value, unsigned size) "read addr 0x%" PRIx64 " data 0x%" PRIx32 " size %u"
> nrf51_timer_write(uint64_t addr, uint32_t value, unsigned size) "write addr 0x%" PRIx64 " data 0x%" PRIx32 " size %u"
>
> +# hw/timer/pl031.c
> +pl031_irq_state(int level) "irq state %d"
> +pl031_read(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x"
> +pl031_write(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x"
> +pl031_alarm_raised(void) "alarm raised"
> +pl031_set_alarm(uint32_t ticks) "alarm set for %u ticks"
>
next prev parent reply other threads:[~2019-02-18 22:14 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-14 12:50 [Qemu-devel] [PATCH 00/14] Add model of the Arm Musca devboards Peter Maydell
2019-02-14 12:50 ` [Qemu-devel] [PATCH 01/14] hw/arm/armsse: Fix miswiring of expansion IRQs Peter Maydell
2019-02-17 17:49 ` Richard Henderson
2019-02-14 12:50 ` [Qemu-devel] [PATCH 02/14] hw/misc/tz-ppc: Support having unused ports in the middle of the range Peter Maydell
2019-02-17 17:51 ` Richard Henderson
2019-02-14 12:50 ` [Qemu-devel] [PATCH 03/14] hw/timer/pl031: Allow use as an embedded-struct device Peter Maydell
2019-02-17 17:55 ` Richard Henderson
2019-02-18 21:54 ` Philippe Mathieu-Daudé
2019-02-14 12:50 ` [Qemu-devel] [PATCH 04/14] hw/timer/pl031: Convert to using trace events Peter Maydell
2019-02-17 17:56 ` Richard Henderson
2019-02-18 21:58 ` Philippe Mathieu-Daudé [this message]
2019-02-14 12:50 ` [Qemu-devel] [PATCH 05/14] hw/char/pl011: Allow use as an embedded-struct device Peter Maydell
2019-02-17 17:57 ` Richard Henderson
2019-02-18 21:59 ` Philippe Mathieu-Daudé
2019-02-14 12:50 ` [Qemu-devel] [PATCH 06/14] hw/char/pl011: Support all interrupt lines Peter Maydell
2019-02-17 18:00 ` Richard Henderson
2019-02-14 12:51 ` [Qemu-devel] [PATCH 07/14] hw/char/pl011: Use '0x' prefix when logging hex numbers Peter Maydell
2019-02-17 18:00 ` Richard Henderson
2019-02-18 22:00 ` Philippe Mathieu-Daudé
2019-02-14 12:51 ` [Qemu-devel] [PATCH 08/14] hw/arm/armsse: Document SRAM_ADDR_WIDTH property in header comment Peter Maydell
2019-02-17 18:01 ` Richard Henderson
2019-02-14 12:51 ` [Qemu-devel] [PATCH 09/14] hw/arm/armsse: Allow boards to specify init-svtor Peter Maydell
2019-02-17 18:03 ` Richard Henderson
2019-02-18 22:01 ` Philippe Mathieu-Daudé
2019-02-14 12:51 ` [Qemu-devel] [PATCH 10/14] hw/arm/musca.c: Implement models of the Musca-A and -B1 boards Peter Maydell
2019-02-17 18:09 ` Richard Henderson
2019-02-14 12:51 ` [Qemu-devel] [PATCH 11/14] hw/arm/musca: Add PPCs Peter Maydell
2019-02-17 18:14 ` Richard Henderson
2019-02-17 18:19 ` Richard Henderson
2019-02-14 12:51 ` [Qemu-devel] [PATCH 12/14] hw/arm/musca: Add MPCs Peter Maydell
2019-02-17 18:17 ` Richard Henderson
2019-02-19 12:29 ` Peter Maydell
2019-02-14 12:51 ` [Qemu-devel] [PATCH 13/14] hw/arm/musca: Wire up PL031 RTC Peter Maydell
2019-02-17 18:20 ` Richard Henderson
2019-02-14 12:51 ` [Qemu-devel] [PATCH 14/14] hw/arm/musca: Wire up PL011 UARTs Peter Maydell
2019-02-17 18:20 ` Richard Henderson
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=e0cac3ef-d2b9-5b2c-cb24-599a63695663@redhat.com \
--to=philmd@redhat.com \
--cc=patches@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--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).