All of lore.kernel.org
 help / color / mirror / Atom feed
From: Damien Hedde <damien.hedde@greensocs.com>
To: qemu-devel@nongnu.org
Cc: Damien Hedde <damien.hedde@greensocs.com>,
	peter.maydell@linaro.org,
	"Edgar E . Iglesias" <edgar.iglesias@xilinx.com>,
	berrange@redhat.com, ehabkost@redhat.com, pbonzini@redhat.com,
	alistair@alistair23.me, mark.burton@greensocs.com,
	qemu-arm@nongnu.org, Alistair Francis <alistair.francis@wdc.com>,
	marcandre.lureau@redhat.com, edgar.iglesias@gmail.com,
	philmd@redhat.com
Subject: [PATCH v9 9/9] qdev-monitor: print the device's clock with info qtree
Date: Mon,  6 Apr 2020 15:52:51 +0200	[thread overview]
Message-ID: <20200406135251.157596-10-damien.hedde@greensocs.com> (raw)
In-Reply-To: <20200406135251.157596-1-damien.hedde@greensocs.com>

This prints the clocks attached to a DeviceState when using
"info qtree" monitor command. For every clock, it displays the
direction, the name and if the clock is forwarded. For input clock,
it displays also the frequency.

This is based on the original work of Frederic Konrad.

Here follows a sample of `info qtree` output on xilinx_zynq machine
after linux boot with only one uart clocked:
> bus: main-system-bus
>  type System
>  [...]
>  dev: cadence_uart, id ""
>    gpio-out "sysbus-irq" 1
>    clock-in "refclk" freq_hz=0.000000e+00
>    chardev = ""
>    mmio 00000000e0001000/0000000000001000
>  dev: cadence_uart, id ""
>    gpio-out "sysbus-irq" 1
>    clock-in "refclk" freq_hz=1.375661e+07
>    chardev = "serial0"
>    mmio 00000000e0000000/0000000000001000
>  [...]
>  dev: xilinx,zynq_slcr, id ""
>    clock-out "uart1_ref_clk" freq_hz=0.000000e+00
>    clock-out "uart0_ref_clk" freq_hz=1.375661e+07
>    clock-in "ps_clk" freq_hz=3.333333e+07
>    mmio 00000000f8000000/0000000000001000

Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
---

v7:
 + print output clocks frequencies too
 + add sample of qtree message above
 + display frequencies in floating-point
---
 qdev-monitor.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/qdev-monitor.c b/qdev-monitor.c
index 9833b33549..56cee1483f 100644
--- a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -38,6 +38,7 @@
 #include "migration/misc.h"
 #include "migration/migration.h"
 #include "qemu/cutils.h"
+#include "hw/clock.h"
 
 /*
  * Aliases were a bad idea from the start.  Let's keep them
@@ -737,6 +738,7 @@ static void qdev_print(Monitor *mon, DeviceState *dev, int indent)
     ObjectClass *class;
     BusState *child;
     NamedGPIOList *ngl;
+    NamedClockList *ncl;
 
     qdev_printf("dev: %s, id \"%s\"\n", object_get_typename(OBJECT(dev)),
                 dev->id ? dev->id : "");
@@ -751,6 +753,13 @@ static void qdev_print(Monitor *mon, DeviceState *dev, int indent)
                         ngl->num_out);
         }
     }
+    QLIST_FOREACH(ncl, &dev->clocks, node) {
+        qdev_printf("clock-%s%s \"%s\" freq_hz=%e\n",
+                    ncl->output ? "out" : "in",
+                    ncl->alias ? " (alias)" : "",
+                    ncl->name,
+                    CLOCK_PERIOD_TO_HZ(1.0 * clock_get(ncl->clock)));
+    }
     class = object_get_class(OBJECT(dev));
     do {
         qdev_print_props(mon, dev, DEVICE_CLASS(class)->props_, indent);
-- 
2.26.0



  parent reply	other threads:[~2020-04-06 14:01 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-06 13:52 [PATCH v9 0/9] Clock framework API Damien Hedde
2020-04-06 13:52 ` [PATCH v9 1/9] hw/core/clock: introduce clock object Damien Hedde
2020-04-17 14:39   ` Peter Maydell
2020-04-06 13:52 ` [PATCH v9 2/9] hw/core/clock-vmstate: define a vmstate entry for clock state Damien Hedde
2020-04-06 13:52 ` [PATCH v9 3/9] qdev: add clock input&output support to devices Damien Hedde
2020-04-06 13:52 ` [PATCH v9 4/9] qdev-clock: introduce an init array to ease the device construction Damien Hedde
2020-04-06 13:52 ` [PATCH v9 5/9] docs/clocks: add device's clock documentation Damien Hedde
2020-04-07  5:07   ` Markus Armbruster
2020-04-08 10:06     ` Damien Hedde
2020-04-14  7:15       ` Markus Armbruster
2020-04-17 15:52   ` Peter Maydell
2020-04-17 16:52     ` Damien Hedde
2020-04-06 13:52 ` [PATCH v9 6/9] hw/misc/zynq_slcr: add clock generation for uarts Damien Hedde
2020-04-06 13:52 ` [PATCH v9 7/9] hw/char/cadence_uart: add clock support Damien Hedde
2020-04-06 13:52 ` [PATCH v9 8/9] hw/arm/xilinx_zynq: connect uart clocks to slcr Damien Hedde
2020-04-06 13:52 ` Damien Hedde [this message]
2020-04-17 17:45 ` [PATCH v9 0/9] Clock framework API Peter Maydell

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=20200406135251.157596-10-damien.hedde@greensocs.com \
    --to=damien.hedde@greensocs.com \
    --cc=alistair.francis@wdc.com \
    --cc=alistair@alistair23.me \
    --cc=berrange@redhat.com \
    --cc=edgar.iglesias@gmail.com \
    --cc=edgar.iglesias@xilinx.com \
    --cc=ehabkost@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=mark.burton@greensocs.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@redhat.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.