From patchwork Mon Apr 6 13:52:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Damien Hedde X-Patchwork-Id: 1266889 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=greensocs.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=greensocs.com header.i=@greensocs.com header.a=rsa-sha256 header.s=mail header.b=DpAvFuYy; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48wsbW1Srlz9sQx for ; Mon, 6 Apr 2020 23:59:18 +1000 (AEST) Received: from localhost ([::1]:60538 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLSHU-0008Hh-O9 for incoming@patchwork.ozlabs.org; Mon, 06 Apr 2020 09:59:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54172) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLSBm-00042P-KT for qemu-devel@nongnu.org; Mon, 06 Apr 2020 09:53:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLSBl-0002Ch-Gv for qemu-devel@nongnu.org; Mon, 06 Apr 2020 09:53:22 -0400 Received: from beetle.greensocs.com ([5.135.226.135]:57150) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLSBi-00027G-Qq; Mon, 06 Apr 2020 09:53:19 -0400 Received: from crumble.bar.greensocs.com (unknown [172.17.10.14]) by beetle.greensocs.com (Postfix) with ESMTPS id 4F68896F58; Mon, 6 Apr 2020 13:53:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=greensocs.com; s=mail; t=1586181197; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LSG/QpD1xqo/C6MQOGaRFTgH86+yW5uNIUzQ2andGQk=; b=DpAvFuYyp6/Zj8DXDaj0LWWey/wKffnlF15Do7BcjiHjnRPrPPkyCX9rSnFcrlC6tLLI1e a72PY47RxCRhMk72o+Nx//DWAdmQNa+dwQiVJ1LKD7xx7Ix21nQHglJKQSRM5od4s1c8KZ WaDbTQliYZhb4imHLe7AzW+6ND1VLOU= From: Damien Hedde To: qemu-devel@nongnu.org Subject: [PATCH v9 9/9] qdev-monitor: print the device's clock with info qtree Date: Mon, 6 Apr 2020 15:52:51 +0200 Message-Id: <20200406135251.157596-10-damien.hedde@greensocs.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200406135251.157596-1-damien.hedde@greensocs.com> References: <20200406135251.157596-1-damien.hedde@greensocs.com> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=greensocs.com; s=mail; t=1586181197; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LSG/QpD1xqo/C6MQOGaRFTgH86+yW5uNIUzQ2andGQk=; b=TNiQbGa8DyiWfoxtZ+Y7ALFB2zUkwmiuEgiBH/9nRIH3u014NTlJST9/2yt06DRfSUcCP6 K7hGbMcwMEHCTskNq3W+3r1B6hvLBv5ruFubFi1wadJlUh0jZKamKv2Re0N312RtPhnJf5 xvh98UcFLi4wcJTJ2EqyPHPCaFF+9L4= ARC-Seal: i=1; s=mail; d=greensocs.com; t=1586181197; a=rsa-sha256; cv=none; b=rsoI97DSIWFUXxIgIO+apK3O1wMsvmJXjMh/wK62zdHy7JQc8371cFaCBjoBNjv16M/3T3 k7JY/U5+SXKpfXtgAljTdvLZC7S8LxXjqj2rCobsPh2HyFOToAMcs+ujyU3i+foxnIT219 L30zOxWP/rPwhE3Yn5n4NgZHkV774sI= ARC-Authentication-Results: i=1; beetle.greensocs.com; none X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 5.135.226.135 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , peter.maydell@linaro.org, "Edgar E . Iglesias" , berrange@redhat.com, ehabkost@redhat.com, pbonzini@redhat.com, alistair@alistair23.me, mark.burton@greensocs.com, qemu-arm@nongnu.org, Alistair Francis , marcandre.lureau@redhat.com, edgar.iglesias@gmail.com, philmd@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell Reviewed-by: Alistair Francis Reviewed-by: Edgar E. Iglesias --- 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);