From nobody Thu May 2 17:58:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.218.43 as permitted sender) client-ip=209.85.218.43; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-f43.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.218.43 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1617949450; cv=none; d=zohomail.com; s=zohoarc; b=W+83+u43mlfzB4vBlu4myLjXFWS0dQvQ6hHU6KI5Ybt65QSfaaRXloBJwROr6Da0OKNPNKxc14KFpw7jm2IrO1OSy+49QS82z059VMbApWX/E0dSgwoxDZ213cU5PTL4miFjnTFOpYs8AHEOS0x+T3+BT3u5fpcY9QfLsvRb1Dg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617949450; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+QFZRjfiDBXxrw9xt50MWOZpl0I5gXE/SA7o167QDWg=; b=XLupuBrm75ttlDFC3ioElnkYREsjvUTJlSBNkG1MV8Zf7mwLFKrcCGvH+cYKmV0THMAjT8flCeBLWlrLTNSb6h1WUsaNzEwISdXXgrmiZ2xSfFfzVCgGtHn6m03u66Fdi86fDu8Fls3h29K81R8qf0s+PxKFZ11OKLCRD1St+kU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.218.43 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) by mx.zohomail.com with SMTPS id 1617949450348134.70719703072348; Thu, 8 Apr 2021 23:24:10 -0700 (PDT) Received: by mail-ej1-f43.google.com with SMTP id n2so6842840ejy.7 for ; Thu, 08 Apr 2021 23:24:09 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (17.red-88-21-201.staticip.rima-tde.net. [88.21.201.17]) by smtp.gmail.com with ESMTPSA id y2sm721771ejf.30.2021.04.08.23.24.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Apr 2021 23:24:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+QFZRjfiDBXxrw9xt50MWOZpl0I5gXE/SA7o167QDWg=; b=KuSpfrH94JzrHSUNpQx8QtXxszv230tbET93dTvso5XdxyyYyDCLZpwDdOA+fnmTow qnEuYIJRi6Llc3zkVn18tdWA44/eXFdHs/gtZIaZ/p4GmV7FUbtSDA0c71iZCpqMDnj8 vg1SZ3DSmfEwBLHktCW95CMBQldQZ1gK6j2P6XlCG0IRY6dDrLyRNCMQmF6M40hWeApz VGfpvy/Vs71w7AdtRLzSbm+BzYUdriVkvVflOdQjiSbJyR6sLb3tFUYGMiHPttcNtmiG sNgTVsgj1aMRU0BsEx6rghWf1JoKiAZOF1cG2pOSE3ncFzVVSLkhnCb376AZovGj/DXo 0vFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=+QFZRjfiDBXxrw9xt50MWOZpl0I5gXE/SA7o167QDWg=; b=tQuM87lGqDeTjREGIVNkq5sVySIWJromWDVPZ6G55EbXv1wWpA0ZpTHiTpGD2DAtdk ctZAKApmgukDHyPE9J1dlDBB1njyDavhEPMoAK/HZ5p06ru3bOV8oI9zwPVEiYE54K2f hs6vGvUvQurMqMY6FgOUF/gkACa3/VKOcbjmN4ELTeyUYcusMbTIYxZW9G037bhpU/JA Op34zAraG/nD0DHvK4BGPYHDrt4Uym/tEMTwt/0RbZxMZiPkKojJMZ+P1o4BZ+MgU/CI GaKxE7Mg33zSR92X0wZ32jzW82+HKOLsWGweNm7GvGIHQk8+T1C+vxJkQlKVhhtjMlv6 Y9gQ== X-Gm-Message-State: AOAM533NYBJ6zyzVJPWWm5UlTCtyJL3nGKRnhSv4QheXi2ti1j83R2VB 0pjDGS8qb7DqCDEPSHb+Gck= X-Google-Smtp-Source: ABdhPJzoLV+Oosakh2S6h+GLl7oCSkXiwvb3bJBI7O38WoHm3OyQT1CFj8S7kpuE6HA6ENaSFIQvyg== X-Received: by 2002:a17:907:984a:: with SMTP id jj10mr14474275ejc.180.1617949448673; Thu, 08 Apr 2021 23:24:08 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Paolo Bonzini , Luc Michel , Peter Maydell , Damien Hedde , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eduardo Habkost Subject: [RFC PATCH-for-6.1 1/9] hw/core/clock: Increase clock propagation trace events verbosity Date: Fri, 9 Apr 2021 08:23:53 +0200 Message-Id: <20210409062401.2350436-2-f4bug@amsat.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210409062401.2350436-1-f4bug@amsat.org> References: <20210409062401.2350436-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) Move the 'clock_propagate' trace event to clock_propagate_period() to display the recursive propagation, and add 'propagate_children' event to closely look at the clock propagation for each children in the clock tree. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/core/clock.c | 8 +++++++- hw/core/trace-events | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/hw/core/clock.c b/hw/core/clock.c index fc5a99683f8..a42dc3c3d29 100644 --- a/hw/core/clock.c +++ b/hw/core/clock.c @@ -79,7 +79,14 @@ static void clock_propagate_period(Clock *clk, bool call= _callbacks) { Clock *child; =20 + trace_clock_propagate(CLOCK_PATH(clk), + CLOCK_PERIOD_TO_HZ(clk->period), + call_callbacks); QLIST_FOREACH(child, &clk->children, sibling) { + trace_clock_propagate_children(CLOCK_PATH(clk), + CLOCK_PERIOD_TO_HZ(clk->period), + CLOCK_PATH(child), + CLOCK_PERIOD_TO_HZ(child->period)); if (child->period !=3D clk->period) { if (call_callbacks) { clock_call_callback(child, ClockPreUpdate); @@ -99,7 +106,6 @@ static void clock_propagate_period(Clock *clk, bool call= _callbacks) void clock_propagate(Clock *clk) { assert(clk->source =3D=3D NULL); - trace_clock_propagate(CLOCK_PATH(clk)); clock_propagate_period(clk, true); } =20 diff --git a/hw/core/trace-events b/hw/core/trace-events index 360ddeb2c87..22df6789918 100644 --- a/hw/core/trace-events +++ b/hw/core/trace-events @@ -32,5 +32,6 @@ resettable_transitional_function(void *obj, const char *o= bjtype) "obj=3D%p(%s)" clock_set_source(const char *clk, const char *src) "'%s', src=3D'%s'" clock_disconnect(const char *clk) "'%s'" clock_set(const char *clk, uint64_t old, uint64_t new) "'%s', %"PRIu64"Hz-= >%"PRIu64"Hz" -clock_propagate(const char *clk) "'%s'" +clock_propagate(const char *src, uint64_t src_hz, int cb) "src=3D'%s' val= =3D%"PRIu64"Hz cb=3D%d" +clock_propagate_children(const char *src, uint64_t src_hz, const char *clk= , uint64_t clk_hz) "src=3D'%s'@%"PRIu64"Hz -> clk=3D'%s'@%"PRIu64"Hz" clock_update(const char *clk, const char *src, uint64_t hz, int cb) "'%s',= src=3D'%s', val=3D%"PRIu64"Hz cb=3D%d" --=20 2.26.3 From nobody Thu May 2 17:58:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.218.42 as permitted sender) client-ip=209.85.218.42; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-f42.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.218.42 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1617949455; cv=none; d=zohomail.com; s=zohoarc; b=iyqirUP/IxKx1qbzNMIv+bghufIV6MAFa/U9H3Ou1SSGd2qKx7wGbk/UVbI6NQEWYlv38NNgLKuH+0IhUmeQMUie85Xldp/5AKSPHQ00+t95+Kx1P+wcRldjri6IIptMKTU9+Sy+Iq61irCpKlfJr+L+MPOb2giXydalcvNWIPc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617949455; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Zv8F1mVV51iuCp3WfDxO+akUI3QLMou50E1/QnZlhLk=; b=Uf2wZ0I+6mmH2dGWDpZgFa9YZtCpTBJMMcBnuD5RHsIDebR45S9LYWq5VdZfn2zixbhEhkPFyB1/tBeXcVIIzHMjVwxmHjkUGMavqODF61twISxQr6KzXYI5Vb/+yhtNzw+XyGVgFiyzlu9WvVCnZGkQcisrnRDjCTLXPMYklPc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.218.42 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) by mx.zohomail.com with SMTPS id 1617949455568695.9535227629239; Thu, 8 Apr 2021 23:24:15 -0700 (PDT) Received: by mail-ej1-f42.google.com with SMTP id r9so6864158ejj.3 for ; Thu, 08 Apr 2021 23:24:15 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (17.red-88-21-201.staticip.rima-tde.net. [88.21.201.17]) by smtp.gmail.com with ESMTPSA id b24sm719251ejq.75.2021.04.08.23.24.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Apr 2021 23:24:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Zv8F1mVV51iuCp3WfDxO+akUI3QLMou50E1/QnZlhLk=; b=qxd+RzbM5kMKgsvTyLiyNQgr71qrrYTmogHq0FfpuhG+Z3388PwJTdpgz0BAA9q3HH gY5ixnpIn3/gAfn/7axlIoG28w9O23qJkEENiko+LHkKz2NUR3A5/kJAaL4GnFr/qaL1 X0RekDtZA88dYcv8cUVPFXCrkPKR4QlGaxjEiBaMLOajIpzf9zyHrvR01HC+Fokp2Zax ULzANGijajblICV5vDONcOpLAFZTkLQ8ZQSqeCqjGT8J+X0qbXDJXwrIpvMH6T4/Jq42 r+R4gD4/9qkJfwVAU3P9dSX5Rr5l6M3UwW9CRaPxW+lT2JsHQ1/SrFswd4VWONxcIS68 +1/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Zv8F1mVV51iuCp3WfDxO+akUI3QLMou50E1/QnZlhLk=; b=k+k6RntZg9iVVWNhbhzHCZVmie+gVesQvAerONDPChiB4x0hjFLu3z2R8kPxTpcYXc eaVQPLkiNP7dUkY3LAN5tcM5a+79VrQFZZRFmLAzEbOfQ4JlpKKlYJQPhZlpG3zAFPdX 76Ij4KrDRGRvxnre79GtwZ+GBEuZrHwRz/feMkTE4Lgs5gGCNHF+RQCEhj2BSTz11fVw vH0Bj8kUfhNX+Nxi2LTU8dNxhvCbLZAeQKob1uKGgWSdYL+nK6JebHKgEtPuHGDB0gwl L7KrHtLZRxwHA9g9DWsU9sgiE6iyZmCNPVtDaaxGOAcf42l3mXr7PjOyQAbgcIUk+D5H +53g== X-Gm-Message-State: AOAM530UAsK41QWIIW1C5hPbP9SDseg5H4pvWySlY2eznc+o5ZiskrXK tkJEtCDCI5QaPVwcKL/678E= X-Google-Smtp-Source: ABdhPJxfff6Eo8NnUprk30XCkBTgoUGGNgk01dY+gvIRfX5cGKSCFsBL+IYvVazeTQ8rOduo7SxKBw== X-Received: by 2002:a17:906:6b8c:: with SMTP id l12mr14409061ejr.511.1617949453870; Thu, 08 Apr 2021 23:24:13 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Paolo Bonzini , Luc Michel , Peter Maydell , Damien Hedde , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eduardo Habkost , Marcel Apfelbaum Subject: [RFC PATCH-for-6.1 2/9] hw/core/machine: Add machine_create_constant_clock() helper Date: Fri, 9 Apr 2021 08:23:54 +0200 Message-Id: <20210409062401.2350436-3-f4bug@amsat.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210409062401.2350436-1-f4bug@amsat.org> References: <20210409062401.2350436-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) Boards usually have crystal oscillators (at fixed frequency) feeding their various clocked components. Add a helper to create such constant clocks in the machine. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/boards.h | 17 +++++++++++++++++ hw/core/machine.c | 11 +++++++++++ 2 files changed, 28 insertions(+) diff --git a/include/hw/boards.h b/include/hw/boards.h index ad6c8fd5376..c8100f7a33a 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -11,6 +11,7 @@ #include "qemu/module.h" #include "qom/object.h" #include "hw/core/cpu.h" +#include "hw/clock.h" =20 #define TYPE_MACHINE_SUFFIX "-machine" =20 @@ -83,6 +84,22 @@ bool device_is_dynamic_sysbus(MachineClass *mc, DeviceSt= ate *dev); MemoryRegion *machine_consume_memdev(MachineState *machine, HostMemoryBackend *backend); =20 +/** + * machine_create_constant_clock: + * @machine: the parent machine + * @name: the clock object name + * @freq_hz: the clock frequency (in Hz) + * + * Helper function to create a new constant clock (fixed frequency + * of @freq_hz) and parent it to @machine. There is no need to call + * clock_setup_canonical_path on the returned clock as it is done + * by this function. + * + * @return the newly created clock + */ +Clock *machine_create_constant_clock(MachineState *machine, + const char *name, unsigned freq_hz); + /** * CPUArchId: * @arch_id - architecture-dependent CPU ID of present or possible CPU diff --git a/hw/core/machine.c b/hw/core/machine.c index 40def78183a..41baf80559d 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -1233,6 +1233,17 @@ void machine_run_board_init(MachineState *machine) phase_advance(PHASE_MACHINE_INITIALIZED); } =20 +Clock *machine_create_constant_clock(MachineState *machine, + const char *name, unsigned freq_hz) +{ + Clock *clk; + + clk =3D clock_new(OBJECT(machine), name); + clock_set_hz(clk, freq_hz); + + return clk; +} + static NotifierList machine_init_done_notifiers =3D NOTIFIER_LIST_INITIALIZER(machine_init_done_notifiers); =20 --=20 2.26.3 From nobody Thu May 2 17:58:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.218.48 as permitted sender) client-ip=209.85.218.48; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-f48.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.218.48 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1617949460; cv=none; d=zohomail.com; s=zohoarc; b=nTaPdHv+WaT+yZSBT28XegvYtKQbJFqZyfDzOuNz6csgeuzOje3CMY9Hh7bs998gQ8jA8QS7rR8kqOnST4HmWO9hbsIWqyCimh5ZFEeJNMiuERYi+YX13gpWAXPIciDaCLk1a436hHUte77eoAXICrquNYfwrKKC9ZfZwQG6Zw4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617949460; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KM2bACU647mjpsDpzpNgymCuMSg/hlg69APP0D5FAlI=; b=RzfVgOAtSW1FSXm/KRsv2BSIfwOE7m9BJKtiSD9ExdPGN5t7x1QSw0ha7fOwGGjjO4zeZrzTvmo3assgiYbWlAkXyPstTnfec9Xanjg7NmQE9qobjpep8CSuN76Nd6WPg9gGu6wyj1LP1bHeJQaNGFuzhWC1w+Jof7//qCFeVaw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.218.48 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) by mx.zohomail.com with SMTPS id 1617949460929221.92205527477563; Thu, 8 Apr 2021 23:24:20 -0700 (PDT) Received: by mail-ej1-f48.google.com with SMTP id g17so4076231ejp.8 for ; Thu, 08 Apr 2021 23:24:20 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (17.red-88-21-201.staticip.rima-tde.net. [88.21.201.17]) by smtp.gmail.com with ESMTPSA id a9sm846600eda.13.2021.04.08.23.24.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Apr 2021 23:24:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KM2bACU647mjpsDpzpNgymCuMSg/hlg69APP0D5FAlI=; b=sFsdBlHqI21NWowVevVCbm58EHUNmABa9M6WocYFi0KlG8UcktrHQ6dA24yFL9Kfut AGiwUyj51uwNwKBMADtr2QtgftcEzFSQEeP4rLDEmGs5KhG6aq1JOB1TKc9217SujshR /DrYAK6bYKUk7fp3PUwZ/ipDa7Kf7qjOIzzZAe3v9Ov4tou288F6U08Hnw1ifN7cxjzm H04m9Ed+rzkoxNM/uo0szEazltGW1TG1mU9IXbJv4dveMd0kzwPHy5bVqLCbQLDyiRgk 5NoRdDFn/rXkTqnVtPDrXSp7o1EjpMWsFIOspacJrtKqFk9CLjLxvhizxOYJJqvDjmkF 7jkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=KM2bACU647mjpsDpzpNgymCuMSg/hlg69APP0D5FAlI=; b=GIIkSNniwQiiO9RiKAXLkHDIUWVBURZ6lwNYowWSEvqyRdYWveUG6gas1seiLEzYb8 E+fuNsJhg5UeuYKDrQ66N7TqF1uS+YQM17bkAmz6of1BysvWUgTlwjJGq3L99hLwhRXA OAIJ/qnCrLjbQkKbq5++3/Ga9gfOpxO4ZAMtSP6t2QigsMznhVysUrdpcVuZOCzobXr9 Sy2E4BPMvZSNDSmlS0LKh0l43wWv01BAe1e2sVTyiLmzi4+pFn0tC7uRM5LbeZXsga5L iYgbmqck+EokzSYNgc4vsakNs5X7HcZ3YRhOQLDmWVu1yzk0YbYeJWA//fIZiea9Ah6b Np6A== X-Gm-Message-State: AOAM53247Wz8FQYyWKjibP2W9mh/jHejULIOGnKacL1vkPsL1qLWaL7M mPjGi+9p7zgxXJqr6PnOxzo= X-Google-Smtp-Source: ABdhPJwiRa54IKzddTIhrI/nF3QxHryStq4E2A8ggC91kqfZ0uZGo4RAzlzbujk3D5oF0Py4M6iagA== X-Received: by 2002:a17:906:eb88:: with SMTP id mh8mr14958512ejb.74.1617949459153; Thu, 08 Apr 2021 23:24:19 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Paolo Bonzini , Luc Michel , Peter Maydell , Damien Hedde , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eduardo Habkost Subject: [RFC PATCH-for-6.1 3/9] hw/arm: Use new machine_create_constant_clock() helper Date: Fri, 9 Apr 2021 08:23:55 +0200 Message-Id: <20210409062401.2350436-4-f4bug@amsat.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210409062401.2350436-1-f4bug@amsat.org> References: <20210409062401.2350436-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) Use the newly added machine_create_constant_clock() helper to create the SYSCLKs. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/arm/mps2-tz.c | 6 ++---- hw/arm/mps2.c | 3 +-- hw/arm/musca.c | 6 ++---- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c index 3fbe3d29f95..86481fbe40d 100644 --- a/hw/arm/mps2-tz.c +++ b/hw/arm/mps2-tz.c @@ -740,10 +740,8 @@ static void mps2tz_common_init(MachineState *machine) } =20 /* These clocks don't need migration because they are fixed-frequency = */ - mms->sysclk =3D clock_new(OBJECT(machine), "SYSCLK"); - clock_set_hz(mms->sysclk, mmc->sysclk_frq); - mms->s32kclk =3D clock_new(OBJECT(machine), "S32KCLK"); - clock_set_hz(mms->s32kclk, S32KCLK_FRQ); + mms->sysclk =3D machine_create_constant_clock(machine, "SYSCLK", mmc->= sysclk_frq); + mms->s32kclk =3D machine_create_constant_clock(machine, "S32KCLK", S32= KCLK_FRQ); =20 object_initialize_child(OBJECT(machine), TYPE_IOTKIT, &mms->iotkit, mmc->armsse_type); diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c index 81413b7133e..5d9250da615 100644 --- a/hw/arm/mps2.c +++ b/hw/arm/mps2.c @@ -143,8 +143,7 @@ static void mps2_common_init(MachineState *machine) } =20 /* This clock doesn't need migration because it is fixed-frequency */ - mms->sysclk =3D clock_new(OBJECT(machine), "SYSCLK"); - clock_set_hz(mms->sysclk, SYSCLK_FRQ); + mms->sysclk =3D machine_create_constant_clock(machine, "SYSCLK", SYSCL= K_FRQ); =20 /* The FPGA images have an odd combination of different RAMs, * because in hardware they are different implementations and diff --git a/hw/arm/musca.c b/hw/arm/musca.c index 7a83f7dda7d..e15149f3a27 100644 --- a/hw/arm/musca.c +++ b/hw/arm/musca.c @@ -372,10 +372,8 @@ static void musca_init(MachineState *machine) exit(1); } =20 - mms->sysclk =3D clock_new(OBJECT(machine), "SYSCLK"); - clock_set_hz(mms->sysclk, SYSCLK_FRQ); - mms->s32kclk =3D clock_new(OBJECT(machine), "S32KCLK"); - clock_set_hz(mms->s32kclk, S32KCLK_FRQ); + mms->sysclk =3D machine_create_constant_clock(machine, "SYSCLK", SYSCL= K_FRQ); + mms->s32kclk =3D machine_create_constant_clock(machine, "S32KCLK", S32= KCLK_FRQ); =20 object_initialize_child(OBJECT(machine), "sse-200", &mms->sse, TYPE_SSE200); --=20 2.26.3 From nobody Thu May 2 17:58:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.208.47 as permitted sender) client-ip=209.85.208.47; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ed1-f47.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.208.47 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1617949466; cv=none; d=zohomail.com; s=zohoarc; b=j8aEWiiBkGTEul9qu2pwHos+0fk4KT4MRy70lRqOpoz80lEYzHh+yYOdMeJhU+GLjMtRjTGMOuD86FyMUgY5ZZZzxVysAruxu9LYNh134Id+dbfn+8nnoYqO3OWZAm3scBYCSekPEa96E76VDMirUumGDA8QSIYTPjHCWkeDxBQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617949466; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zRoQYNlkLYyE9AlFcEvCS75qivi0ECZWMEXZijy0geo=; b=buF61nfi8dOFrRO8AOaHII1IU4wTXiMa0B0DjIJC9abkUZkxXUNuW7XL3PdXMev1MJ5nz3ljHA2N9r/HgJVUe20lqv9dIGnf45zEUPYtgZClrFaoK18Uwn0hErMBTSnmsYfhJg5tAPybiK9DzMoM4RLmZYyp3iNPKCvKwQJT//Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.208.47 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) by mx.zohomail.com with SMTPS id 161794946634887.18931352460822; Thu, 8 Apr 2021 23:24:26 -0700 (PDT) Received: by mail-ed1-f47.google.com with SMTP id s15so5198510edd.4 for ; Thu, 08 Apr 2021 23:24:25 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (17.red-88-21-201.staticip.rima-tde.net. [88.21.201.17]) by smtp.gmail.com with ESMTPSA id 28sm816854edw.82.2021.04.08.23.24.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Apr 2021 23:24:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zRoQYNlkLYyE9AlFcEvCS75qivi0ECZWMEXZijy0geo=; b=jZtsq9FagTXfsvqDf7W34eslAdCA4mGEvi2srm/7/nc6zymz7fBhbd7tT+4090WqQ7 RNVKiEaLFwYUqEOOGDgwwzEVTB/qgNKRNnqHO/UJyiNiiQHOiL9h+El+jVjh75LrEAXg oPaDjM51orhXfYGwrQUnzsINS7hPjwfyaHv+m7Ox2qefMSheSaGUUstZHZXZoKbQPJR+ 6g/elCbzJpocQoUSiady8qamz0sFai1WheOpOjBGb5tYv8p0Td4pe2YZr67HM4VNf45z rYk4nQqsGZPs0uLXF2xuErE75GsuwSEDXrVr8TzLA/ym5ScTillo03rkbMgNO4ExKQwO ilPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=zRoQYNlkLYyE9AlFcEvCS75qivi0ECZWMEXZijy0geo=; b=C9b7snFp0SYnwAvzowtMtI5BjMDy088XE/YOmNvzjQN+43ik2GGwI7r4KGAFJz9ltl ItTwpSHANp/fYon5TJJCrUmEiBjkS7FbBw8gh/1EI2Wl9PRUdb5jm3JBOcrGTg8shPk9 ++3n8bW33eoy8I84cBogNSRCQj4ZvpHlHB7+ECuFcOYpRJgrSAkawiQh5qXygU8unmqy eB0UoLJ7YTHXyJhpIf1AwBIkISClyF0m+CT3uDjiTYLdFYYcn+wli3hYZRgBFQdq6a2w 6aRFFMp1d6w+kXhGUJ6it4lc6jnqt2Zh7yvROQLFx006KXqOADoMB0SFIgrpfrsRZK8+ RNwA== X-Gm-Message-State: AOAM531nuJl61JSdjoFyOiEBKVhWpQtqHl54BZvH4RwTM1otBFaTfMCH EdTZBqpXFa22wJLnPWndgdY= X-Google-Smtp-Source: ABdhPJycFP3DeWWCiB4FHpmElahwDBNZmZFiZYI0x7QKzBFgxbcU9Ri82gmB1RG/SGZ237kKc9X3IQ== X-Received: by 2002:a05:6402:26c9:: with SMTP id x9mr15630569edd.322.1617949464597; Thu, 08 Apr 2021 23:24:24 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Paolo Bonzini , Luc Michel , Peter Maydell , Damien Hedde , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eduardo Habkost , Huacai Chen , Jiaxun Yang , Aurelien Jarno , Aleksandar Rikalo , =?UTF-8?q?Herv=C3=A9=20Poussineau?= Subject: [RFC PATCH-for-6.1 4/9] hw/mips: Use new machine_create_constant_clock() helper Date: Fri, 9 Apr 2021 08:23:56 +0200 Message-Id: <20210409062401.2350436-5-f4bug@amsat.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210409062401.2350436-1-f4bug@amsat.org> References: <20210409062401.2350436-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) Use the newly added machine_create_constant_clock() helper to create the CPU reference clocks. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/mips/fuloong2e.c | 4 ++-- hw/mips/jazz.c | 6 +++--- hw/mips/loongson3_virt.c | 4 ++-- hw/mips/mipssim.c | 7 ++++--- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/hw/mips/fuloong2e.c b/hw/mips/fuloong2e.c index 4f61f2c873b..72dc5702727 100644 --- a/hw/mips/fuloong2e.c +++ b/hw/mips/fuloong2e.c @@ -259,8 +259,8 @@ static void mips_fuloong2e_init(MachineState *machine) CPUMIPSState *env; DeviceState *dev; =20 - cpuclk =3D clock_new(OBJECT(machine), "cpu-refclk"); - clock_set_hz(cpuclk, 533080000); /* ~533 MHz */ + cpuclk =3D machine_create_constant_clock(machine, "cpu-refclk", + 533080000); /* ~533 MHz */ =20 /* init CPUs */ cpu =3D mips_cpu_create_with_clock(machine->cpu_type, cpuclk); diff --git a/hw/mips/jazz.c b/hw/mips/jazz.c index 1a0888a0fd5..3c220b4df6b 100644 --- a/hw/mips/jazz.c +++ b/hw/mips/jazz.c @@ -185,9 +185,9 @@ static void mips_jazz_init(MachineState *machine, exit(EXIT_FAILURE); } =20 - cpuclk =3D clock_new(OBJECT(machine), "cpu-refclk"); - clock_set_hz(cpuclk, ext_clk[jazz_model].freq_hz - * ext_clk[jazz_model].pll_mult); + cpuclk =3D machine_create_constant_clock(machine, "cpu-refclk", + ext_clk[jazz_model].freq_hz + * ext_clk[jazz_model].pll_mult); =20 /* init CPUs */ cpu =3D mips_cpu_create_with_clock(machine->cpu_type, cpuclk); diff --git a/hw/mips/loongson3_virt.c b/hw/mips/loongson3_virt.c index b15071defc6..b9f18ecd911 100644 --- a/hw/mips/loongson3_virt.c +++ b/hw/mips/loongson3_virt.c @@ -530,8 +530,8 @@ static void mips_loongson3_virt_init(MachineState *mach= ine) sysbus_create_simple("goldfish_rtc", virt_memmap[VIRT_RTC].base, qdev_get_gpio_in(liointc, RTC_IRQ)); =20 - cpuclk =3D clock_new(OBJECT(machine), "cpu-refclk"); - clock_set_hz(cpuclk, DEF_LOONGSON3_FREQ); + cpuclk =3D machine_create_constant_clock(machine, "cpu-refclk", + DEF_LOONGSON3_FREQ); =20 for (i =3D 0; i < machine->smp.cpus; i++) { int ip; diff --git a/hw/mips/mipssim.c b/hw/mips/mipssim.c index f5d0da05aa1..af11cf9ac25 100644 --- a/hw/mips/mipssim.c +++ b/hw/mips/mipssim.c @@ -153,11 +153,12 @@ mips_mipssim_init(MachineState *machine) ResetData *reset_info; int bios_size; =20 - cpuclk =3D clock_new(OBJECT(machine), "cpu-refclk"); #ifdef TARGET_MIPS64 - clock_set_hz(cpuclk, 6000000); /* 6 MHz */ + cpuclk =3D machine_create_constant_clock(machine, "cpu-refclk", + 6000000); /* 6 MHz */ #else - clock_set_hz(cpuclk, 12000000); /* 12 MHz */ + cpuclk =3D machine_create_constant_clock(machine, "cpu-refclk", + 12000000); /* 12 MHz */ #endif =20 /* Init CPUs. */ --=20 2.26.3 From nobody Thu May 2 17:58:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.208.52 as permitted sender) client-ip=209.85.208.52; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ed1-f52.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.208.52 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1617949471; cv=none; d=zohomail.com; s=zohoarc; b=bzNopnuWDF1QnhQ3mFOwQwJofj1vL+AOy7DvdPXBEQ0CEQIKnLnA4BN/QkNkICr66ltCFcQvZLWz6JCowxAn+A1Efq3CAgVmwTeTPe1h1IVUgJdNehpKfXhsu5tmYd15ycrPe5q9U+3gd2SSCeir+eOnclqs0U0EQWnaO/OOxrU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617949471; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1QJK5YsqEWkcz1+zXEQOYzQ3PdzprOwAmBARKtOH8jU=; b=Ryvx5rMq4SAxTlqnr/TIegCRxCtD2av29TKO397WoO6XH+MiSsq6ln9l2J/n1ZR9zXBrpISyjQr+aI8bA/zBIwEff17rpPG74Uz0eeVOcyqlBHsfniTiTFYXFro3hMc1lbdjeqdmoXAOwL4pHciRpAbheT8Rvm+KEvaJAIfei+Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.208.52 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) by mx.zohomail.com with SMTPS id 1617949471458521.1470158532369; Thu, 8 Apr 2021 23:24:31 -0700 (PDT) Received: by mail-ed1-f52.google.com with SMTP id g17so4436672edm.6 for ; Thu, 08 Apr 2021 23:24:30 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (17.red-88-21-201.staticip.rima-tde.net. [88.21.201.17]) by smtp.gmail.com with ESMTPSA id t7sm820410edq.42.2021.04.08.23.24.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Apr 2021 23:24:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1QJK5YsqEWkcz1+zXEQOYzQ3PdzprOwAmBARKtOH8jU=; b=SFfzj4vFkxKHFw7I2WM5bwbS612EFrpySvYmokQA6PhgvkhyNBRVwSRzN/yal9TlTh haAU0c18LOjMWa2lHdIcpYxkQ+zDwjf1Nw+UHhLlQqd9VdNzl32rLZLQm+eO8TErD/FA 7OWnuwUQZLo/7eGDwh/SC0ncctEgyqYmS5pNJS+95fZpk+s8P6YFveOur5ad5bSTng4u HarUk8pCRZ0kxu7uY9tv2VXDgnldftzu4OxSJ4aKB19wAo04Cs+8AELq22FwCPK09azB TafJrTsukB66R1l2yVOvzAPXdV8qNPg475aBxle+1uozY/TwBearXLLuInTT89cd8vk1 oV7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=1QJK5YsqEWkcz1+zXEQOYzQ3PdzprOwAmBARKtOH8jU=; b=tvxfjqCi+3QrEQ+b+3zeBwZEDc/jHGkVC6gPtsO6GT6UJ8TNs26YEDSQ52tRR8baa9 ci7TAKon38xlYGR6qKIV1nxAgX+V56Qw/5gKGMJsB2z0SzZ+gF2c6VTI3XqX4XDXFquN +CK9FXQtfvLIEZT+JhwVTx0PjCTW6/WcqeX7UualecituksSWgn/ER/9rllwbZR/EBZr vVofwxKcaluhQWBlAFG/Cxupw9up1qZ1APjwlJAoHcuyVSBYFlP17hiWK9z7IvNH8LYM 5dMMkxDfgoK/7itdPU9BeGntLIWH4omX17fT+1Kq/wxUYlE/sKM3cUtpemvhnLw3baiL Ip4Q== X-Gm-Message-State: AOAM5325lJGl2WLtiJQX1lTgj77N1kikmm/GZoEtgmAgXSPR8Cb1uzcn e6ZxALjO/1B6vrhB5ClXluw= X-Google-Smtp-Source: ABdhPJznfibeaFD5ex6/UkoMzabT/fJR93l2LnzgcBxyv2MHxV51NWXNqFBqnC7pvpoUSASRUfCG/w== X-Received: by 2002:a05:6402:35cd:: with SMTP id z13mr16107830edc.21.1617949469778; Thu, 08 Apr 2021 23:24:29 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Paolo Bonzini , Luc Michel , Peter Maydell , Damien Hedde , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eduardo Habkost , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [RFC PATCH-for-6.1 5/9] hw/core/qdev-clock: Add qdev_ground_clock() helper Date: Fri, 9 Apr 2021 08:23:57 +0200 Message-Id: <20210409062401.2350436-6-f4bug@amsat.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210409062401.2350436-1-f4bug@amsat.org> References: <20210409062401.2350436-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) Clocks are rarely left unconnected, but rather connected to ground plane to avoid noise. When representing the clock tree, we want to see such ground clock. As we might reuse this clock on various boards, introduce the qdev_ground_clock() which return a singleton ground clock. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/qdev-clock.h | 9 +++++++++ hw/core/qdev-clock.c | 11 +++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/hw/qdev-clock.h b/include/hw/qdev-clock.h index ffa0f7ba09e..2f2d2da6cd6 100644 --- a/include/hw/qdev-clock.h +++ b/include/hw/qdev-clock.h @@ -161,4 +161,13 @@ typedef struct ClockPortInitElem ClockPortInitArray[]; */ void qdev_init_clocks(DeviceState *dev, const ClockPortInitArray clocks); =20 +/** + * qdev_ground_clock: + * @returns: a pointer to the ground clock + * + * Get the special 'ground' clock. This clock can be used as input + * (unclocked) or output. + */ +Clock *qdev_ground_clock(void); + #endif /* QDEV_CLOCK_H */ diff --git a/hw/core/qdev-clock.c b/hw/core/qdev-clock.c index 117f4c6ea4a..a46384a84b7 100644 --- a/hw/core/qdev-clock.c +++ b/hw/core/qdev-clock.c @@ -210,3 +210,14 @@ void qdev_connect_clock_in(DeviceState *dev, const cha= r *name, Clock *source) assert(!dev->realized); clock_set_source(qdev_get_clock_in(dev, name), source); } + +Clock *qdev_ground_clock(void) +{ + static Clock *gnd_clk; + + if (!gnd_clk) { + gnd_clk =3D clock_new(qdev_get_machine(), "gnd"); + } + + return gnd_clk; +} --=20 2.26.3 From nobody Thu May 2 17:58:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.218.48 as permitted sender) client-ip=209.85.218.48; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-f48.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.218.48 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1617949476; cv=none; d=zohomail.com; s=zohoarc; b=mdFfHD4syxQStJMc8NgvaU8QpIWEDq7JXcCI1mroD2aCQdJsu09XtCMt+cWR9caFd+fVWJUBaBYPvhkQkMNF3mkoE0gQ7qUn8CmL08NqyBiGZf50GezBaGIM93crLFqGdy2JW5bysD5N1oDl7TAJNUR3FBkdyW+Cmz1ERkhmb8A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617949476; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/OEqLEQHCmytseRt1FhXxp+Rob399wNsde0XeRnkGgQ=; b=emRM0bO6GnlRyFMb/9pKON5TjMTas8sq4h9FDvTc1iVzk0dRZChM/jnzCCaMpbEIyBC0xZHz4HYFnIW9HThH5MJTkRBY2p3WNRF0NfKE3Qc+90P6Es4Nf8YznkxHSh1CCKwB/u+VUoiNZv1kiJxjFzdWZ+YcDnIauvrmotdlVtQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.218.48 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) by mx.zohomail.com with SMTPS id 1617949476600190.39508975255194; Thu, 8 Apr 2021 23:24:36 -0700 (PDT) Received: by mail-ej1-f48.google.com with SMTP id n2so6844230ejy.7 for ; Thu, 08 Apr 2021 23:24:36 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (17.red-88-21-201.staticip.rima-tde.net. [88.21.201.17]) by smtp.gmail.com with ESMTPSA id ay3sm845372edb.2.2021.04.08.23.24.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Apr 2021 23:24:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/OEqLEQHCmytseRt1FhXxp+Rob399wNsde0XeRnkGgQ=; b=ltZ+3820lLw6oC8xOjK05tEQA2ZV7Fjzd8OCarI9OfHsTY+NUKyaoYnOxRPhtsSRQm 8uGBBx3oMvSTowr3SN33+jgx5Wp+bCKEKx4LqgyNCmlQISba3rl04LV+cot9vw8rNO92 NobHeCeMMbo9VZFaZZl3Foopgh42a555jALD5/rqJ1fO7k8VwVdoQ3IRh/30Mcwor4l6 sRCR2ONs8ovaSJGtwNawSnhFxVgd9K4ZdP3FI1t/ZDtpy9z4m8mhy5kkFLr5YpwoaJeF Cbd9OTiZCfRkCWBGki4i8JE31x093/IQUIwLmvu/PnzjT6F4BSZwXsK+8KVHL+wHyCBQ EHCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=/OEqLEQHCmytseRt1FhXxp+Rob399wNsde0XeRnkGgQ=; b=hjtidYA309RpTTX+mijza6pBXR4AoXb5nEr7jI8rxrQcPr0QcETxKgcUJHgv7D2k8z LTNw0UK19rZ/HyYpcIgIJnZ5TISR2DOS02UHCGBnL40v/VoE5Sx9IQGzT0FReTFkWChD qgYa8asTn4Bkqfnl5FeluHwHWL3oOmTHl9c170EzN4gqLIndolu/PIXs9FL5bCt7BIe1 dgJ9HgFquzjq0c/cu5AAr5fu+KQvPJJWTV7UHI8yi5mL1/Z7vPDlHodroUO1Ef0Qlegv A9xmRRV/A0j4jqIIhB2OadVK7rsMRcYjX3+0CEoNB3KkmhGAgYhdbjZH8TfU18+BAkkZ Gwnw== X-Gm-Message-State: AOAM5332vaWSJp081O6iqsXsVULeoag47DzTWI/ZDXcffqQSyhgfncNY gQ52MQktlukBUd8kFHXcCeY= X-Google-Smtp-Source: ABdhPJyXnHdzktWS6AwWRoja1N2Z48ZZJD7qGZxm922GmRaCtBWzMTSguBD/9KCt+SZT4bgDl6OVMg== X-Received: by 2002:a17:906:170d:: with SMTP id c13mr14302431eje.491.1617949474885; Thu, 08 Apr 2021 23:24:34 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Paolo Bonzini , Luc Michel , Peter Maydell , Damien Hedde , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eduardo Habkost , Andrew Baumann Subject: [RFC PATCH-for-6.1 6/9] hw/misc/bcm2835_cprman: Use qdev_ground_clock() helper Date: Fri, 9 Apr 2021 08:23:58 +0200 Message-Id: <20210409062401.2350436-7-f4bug@amsat.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210409062401.2350436-1-f4bug@amsat.org> References: <20210409062401.2350436-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) The ground clock isn't really an internal component of the CPRMAN peripheral. Use the qdev_ground_clock() helper to access the board ground plane. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/misc/bcm2835_cprman.h | 1 - hw/misc/bcm2835_cprman.c | 7 ++----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/include/hw/misc/bcm2835_cprman.h b/include/hw/misc/bcm2835_cpr= man.h index 3df4ceedd2e..2996ccb4632 100644 --- a/include/hw/misc/bcm2835_cprman.h +++ b/include/hw/misc/bcm2835_cprman.h @@ -204,7 +204,6 @@ struct BCM2835CprmanState { uint32_t xosc_freq; =20 Clock *xosc; - Clock *gnd; }; =20 #endif diff --git a/hw/misc/bcm2835_cprman.c b/hw/misc/bcm2835_cprman.c index 75e6c574d46..5039b7632b4 100644 --- a/hw/misc/bcm2835_cprman.c +++ b/hw/misc/bcm2835_cprman.c @@ -678,9 +678,6 @@ static void cprman_init(Object *obj) } =20 s->xosc =3D clock_new(obj, "xosc"); - s->gnd =3D clock_new(obj, "gnd"); - - clock_set(s->gnd, 0); =20 memory_region_init_io(&s->iomem, obj, &cprman_ops, s, "bcm2835-cprman", 0x2000); @@ -697,7 +694,7 @@ static void connect_mux_sources(BCM2835CprmanState *s, =20 /* For sources from 0 to 3. Source 4 to 9 are mux specific */ Clock * const CLK_SRC_MAPPING[] =3D { - [CPRMAN_CLOCK_SRC_GND] =3D s->gnd, + [CPRMAN_CLOCK_SRC_GND] =3D qdev_ground_clock(), [CPRMAN_CLOCK_SRC_XOSC] =3D s->xosc, [CPRMAN_CLOCK_SRC_TD0] =3D td0, [CPRMAN_CLOCK_SRC_TD1] =3D td1, @@ -708,7 +705,7 @@ static void connect_mux_sources(BCM2835CprmanState *s, Clock *src; =20 if (mapping =3D=3D CPRMAN_CLOCK_SRC_FORCE_GROUND) { - src =3D s->gnd; + src =3D qdev_ground_clock(); } else if (mapping =3D=3D CPRMAN_CLOCK_SRC_DSI0HSCK) { src =3D s->dsi0hsck_mux.out; } else if (i < CPRMAN_CLOCK_SRC_PLLA) { --=20 2.26.3 From nobody Thu May 2 17:58:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.218.53 as permitted sender) client-ip=209.85.218.53; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-f53.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.218.53 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1617949481; cv=none; d=zohomail.com; s=zohoarc; b=K092n+ZXRMHZ5Nvbt4AE+300a23Yjj7CxGdC4eWindQt5f7YVWxN1mbqV6rQ/SngbIvq75nsoWUAjDrA3wXw2H6fewjaxCUYMauA3nD+bCIGLoZH0/ilSGlNyRkIHj+gBS/zMu0NeGt+DTkdeaThIo5qNvvcfKWgSj+z22M3Mg0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617949481; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Ge+UwN7N+4mN3C6ng3RtkaVCXw7LRu2ISOzslpilhag=; b=nybd7aY3lvZsYPGC0eJbO6u2g2A0PJFX6n3gqM12kO2mX/MlirCjs1vdaYfkwI5AsEtbO9bgRUxAV3AVUHNtlVnNy9Hi1by3zCreHqhlorFCfLazG6wqbQQbzs9tm3kqldAO3aIlpwUWs+tqLosxH2m2QIYxdodanZmyxggdyKs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.218.53 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) by mx.zohomail.com with SMTPS id 16179494818681004.9215204397201; Thu, 8 Apr 2021 23:24:41 -0700 (PDT) Received: by mail-ej1-f53.google.com with SMTP id n2so6844591ejy.7 for ; Thu, 08 Apr 2021 23:24:41 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (17.red-88-21-201.staticip.rima-tde.net. [88.21.201.17]) by smtp.gmail.com with ESMTPSA id g26sm705658ejz.70.2021.04.08.23.24.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Apr 2021 23:24:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ge+UwN7N+4mN3C6ng3RtkaVCXw7LRu2ISOzslpilhag=; b=sqI6xGXAI0n0K+8BjBLgH9G7oD1OPFoSjYfbLCqgasErypf378fdNteeFfrbYbaryn fe6HJhebGQQmAU+PKCfWAIhDwL5DnOpLx0Jglp52aGcNoLE6YxpzcjtuNY03p7LISz6v cBI4GmOcXbCywe/Jh77OjuGR/4ilEYSoZgld+e8D8/ZBmU8Cwd4eXiyvjv1Wmh3/Mcw+ 5vzCNTpLC7yZ/ocK2pxYeufZXCjqLzcrRf28eEWspmV9rhHUYXwOop6t4WgdX6yebilW Lbt18y9/DhknaRcb3TOobaL0srBo+IzheDZfL1rO5glGqs13PdVWp3Gkm7smuR+MTVSl v3cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Ge+UwN7N+4mN3C6ng3RtkaVCXw7LRu2ISOzslpilhag=; b=N4Sg0JWeojez7R7nmrrOpPnTnVZWcjssfqBViEK1CHA50aT/b8/I4uxKiwlrhtlfK2 qmhbijCliKJ9S3dr9bsM2RQ5cx8aye8EaeOEu7SwCnxrNInyGNZKkR13ccuNrcRExGCI /IY/9vjAVzRsEa65qowlLg0EW8quHyoUPd/0vfPyDX+02hF3FzSqAXI5QOCGrjCH9Fov tw2K5g7ztJTM7alIxgpYcbauWD3rFi93FJRbFdSR+KSQnzbeAK4tkt56jkY5lFzaIJwA nJnr7Z9iWB60PBEOQ6BTJTq5I2wy6korvsIw8kiPRD8xjvd5YaLNlHDSocmYuDYAA/kO v8nw== X-Gm-Message-State: AOAM531/44s2xpZSS2upDXK4nbB2oxDRHNrJVDXxfnzBkUoiMROUIK8s paUwXi3NveH1T17eKNwLI2Q= X-Google-Smtp-Source: ABdhPJyDUfeN6H/klQeGg95tmYz3oRaFLhxDxpus26sJoIAX5Ug2xbEEgp9xVqR8PaYzAT4NjQo3Kg== X-Received: by 2002:a17:907:93a:: with SMTP id au26mr14718110ejc.47.1617949480146; Thu, 08 Apr 2021 23:24:40 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Paolo Bonzini , Luc Michel , Peter Maydell , Damien Hedde , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eduardo Habkost , Andrew Baumann Subject: [RFC PATCH-for-6.1 7/9] hw/misc/bcm2835_cprman: Feed 'xosc' from the board Date: Fri, 9 Apr 2021 08:23:59 +0200 Message-Id: <20210409062401.2350436-8-f4bug@amsat.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210409062401.2350436-1-f4bug@amsat.org> References: <20210409062401.2350436-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) The XOsc signal isn't a part of the CPRMAN, but comes from a crystal oscillator external to the SoC. Create the oscillator on the board, and propagate it to the CPRMAN. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Peter Maydell --- include/hw/misc/bcm2835_cprman.h | 1 - hw/arm/bcm2835_peripherals.c | 1 + hw/arm/bcm2836.c | 1 + hw/arm/raspi.c | 4 ++++ hw/misc/bcm2835_cprman.c | 5 +---- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/hw/misc/bcm2835_cprman.h b/include/hw/misc/bcm2835_cpr= man.h index 2996ccb4632..52f76489f36 100644 --- a/include/hw/misc/bcm2835_cprman.h +++ b/include/hw/misc/bcm2835_cprman.h @@ -201,7 +201,6 @@ struct BCM2835CprmanState { CprmanDsi0HsckMuxState dsi0hsck_mux; =20 uint32_t regs[CPRMAN_NUM_REGS]; - uint32_t xosc_freq; =20 Clock *xosc; }; diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c index dcff13433e5..a82f2b42f5a 100644 --- a/hw/arm/bcm2835_peripherals.c +++ b/hw/arm/bcm2835_peripherals.c @@ -123,6 +123,7 @@ static void bcm2835_peripherals_init(Object *obj) =20 /* CPRMAN clock manager */ object_initialize_child(obj, "cprman", &s->cprman, TYPE_BCM2835_CPRMAN= ); + qdev_alias_clock(DEVICE(&s->cprman), "xosc-in", DEVICE(s), "xosc-in"); =20 object_property_add_const_link(OBJECT(&s->dwc2), "dma-mr", OBJECT(&s->gpu_bus_mr)); diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c index de7ade2878e..6c238ecb949 100644 --- a/hw/arm/bcm2836.c +++ b/hw/arm/bcm2836.c @@ -63,6 +63,7 @@ static void bcm2836_init(Object *obj) "board-rev"); object_property_add_alias(obj, "vcram-size", OBJECT(&s->peripherals), "vcram-size"); + qdev_alias_clock(DEVICE(&s->peripherals), "xosc-in", DEVICE(s), "xosc-= in"); } =20 static bool bcm283x_common_realize(DeviceState *dev, Error **errp) diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c index 990509d3852..a89f7e17c3a 100644 --- a/hw/arm/raspi.c +++ b/hw/arm/raspi.c @@ -40,6 +40,7 @@ struct RaspiMachineState { /*< private >*/ MachineState parent_obj; /*< public >*/ + Clock *xosc; BCM283XState soc; struct arm_boot_info binfo; }; @@ -277,12 +278,15 @@ static void raspi_machine_init(MachineState *machine) memory_region_add_subregion_overlap(get_system_memory(), 0, machine->ram, 0); =20 + s->xosc =3D machine_create_constant_clock(machine, "xosc", 19200000); + /* Setup the SOC */ object_initialize_child(OBJECT(machine), "soc", &s->soc, board_soc_type(board_rev)); object_property_add_const_link(OBJECT(&s->soc), "ram", OBJECT(machine-= >ram)); object_property_set_int(OBJECT(&s->soc), "board-rev", board_rev, &error_abort); + qdev_connect_clock_in(DEVICE(&s->soc), "xosc-in", s->xosc); qdev_realize(DEVICE(&s->soc), NULL, &error_abort); =20 /* Create and plug in the SD cards */ diff --git a/hw/misc/bcm2835_cprman.c b/hw/misc/bcm2835_cprman.c index 5039b7632b4..33f15d99f63 100644 --- a/hw/misc/bcm2835_cprman.c +++ b/hw/misc/bcm2835_cprman.c @@ -637,8 +637,6 @@ static void cprman_reset(DeviceState *dev) for (i =3D 0; i < CPRMAN_NUM_CLOCK_MUX; i++) { device_cold_reset(DEVICE(&s->clock_muxes[i])); } - - clock_update_hz(s->xosc, s->xosc_freq); } =20 static void cprman_init(Object *obj) @@ -677,7 +675,7 @@ static void cprman_init(Object *obj) g_free(alias); } =20 - s->xosc =3D clock_new(obj, "xosc"); + s->xosc =3D qdev_init_clock_in(DEVICE(obj), "xosc-in", NULL, s, ClockU= pdate); =20 memory_region_init_io(&s->iomem, obj, &cprman_ops, s, "bcm2835-cprman", 0x2000); @@ -776,7 +774,6 @@ static const VMStateDescription cprman_vmstate =3D { }; =20 static Property cprman_properties[] =3D { - DEFINE_PROP_UINT32("xosc-freq-hz", BCM2835CprmanState, xosc_freq, 1920= 0000), DEFINE_PROP_END_OF_LIST() }; =20 --=20 2.26.3 From nobody Thu May 2 17:58:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.218.49 as permitted sender) client-ip=209.85.218.49; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-f49.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.218.49 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1617949487; cv=none; d=zohomail.com; s=zohoarc; b=ENVwHMN6oXPkCjco7dNZt+8vjlFDE5nUVtNEABmGA47EKlfdxTIT7v6/iHkpEYFOm7tEBMQweryrck7b7ql3IADiqIEYVyTM7QhaKK52jlEuoTga/iO6Z1Ypr7PfYXHdn/DyMWp0xA+T6JvuOyTx4qBIAwMcTM9DrerPxZf+vmU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617949487; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nDFbUJf+zSiSog/LYin0LAf7wyvK1G5JKV9wmLaTU9M=; b=dEUEtMu8JB43BgxI9JUNBFTCEuADG15YWTMg2oruujgNGQWKf9v6ia9yNvUAebwavs56HgZV9ooXEKbHHm/E8g8Mk643VnziS1GRLkbWqD1PH7lOL78gD/AWWwnBSckRGL/IT+O75JBJr6XmJkpeEu2xT8o69qmWu6ETnUyuRpo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.218.49 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) by mx.zohomail.com with SMTPS id 1617949487218924.5202345649709; Thu, 8 Apr 2021 23:24:47 -0700 (PDT) Received: by mail-ej1-f49.google.com with SMTP id r12so6865686ejr.5 for ; Thu, 08 Apr 2021 23:24:46 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (17.red-88-21-201.staticip.rima-tde.net. [88.21.201.17]) by smtp.gmail.com with ESMTPSA id b21sm711872ejz.123.2021.04.08.23.24.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Apr 2021 23:24:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nDFbUJf+zSiSog/LYin0LAf7wyvK1G5JKV9wmLaTU9M=; b=uuS4Pk/VAJDOp6Pwxln8iW/mJ4KnaTDRn50NXb+1N5XW12GifvULQ/vjj0op//bMN7 LkAj7c+hNguynBubJgAGCMtSqcXeqwzU8Lmv/GvTxql7KWHFodLx6pLXHBGM2+1PPuZR bfp/fDE5JrTqZ4cznaVDktC2aFy763BbFLvHcOWIMY29k+RvphJ3OEO5fDrfUJsvmMHm /I/IlUxBd8J6ts3c2rxPitHPTCXyogm2DpZ7HKnnQpI9PT1iI/T9d+iwsFtWI9bdU5aV 0kDhAi9dMXLgqAFr03CWuSNjEy2us7nTo42cd+/iYlWT/3AD2MVabsaqyxhyxKfeKB/w 714Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=nDFbUJf+zSiSog/LYin0LAf7wyvK1G5JKV9wmLaTU9M=; b=SFfilcsHWu4kZc0kv2Os8Kvr5f0T+ZwBz8fj8Kv9YamSHN7j934yUOPfQo9oyRLuE0 BXNMLEoe8dEbHtd6aG3WYQrF/9eaJDviLMeFoQKfW2YWRHckYO9pJ4wDvN+uKWoI6aZC w44+UwmrKBFfNXonNe9Qwa0SV4gt9Zr1+S/UvF8pJPWtiTMseY3+BJKLpmronKql/W12 o9ybXzMV1BBmYvOWWINY5d3BwoYK2Xm5kpH+XJP0U6HR2/RCMwoyiyYzfzM6RWgR/RXZ BX0AGL8GFVZi1PdQU1FADzX5U8GJjRBVIllzVIS1AoAmYEobFRrRHdj0L7FqjiEFBgK9 NWZg== X-Gm-Message-State: AOAM533sICofHGmUxANrngM4yqbevX1LJwoqt5d9p+VyDF9x5zN3Z9lK zm/Tj9pJbKvDMtdQF307eGc= X-Google-Smtp-Source: ABdhPJxo+77+8B6ZlCyBZlhyE6lnabwzE/4mu9v6/6AQ6+Trohef5kPe/Q2tCvpfrpxcUzPkBATJUg== X-Received: by 2002:a17:906:e0b:: with SMTP id l11mr14989236eji.111.1617949485397; Thu, 08 Apr 2021 23:24:45 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Paolo Bonzini , Luc Michel , Peter Maydell , Damien Hedde , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [RFC PATCH-for-6.1 8/9] hw/clock: Declare clock_new() internally Date: Fri, 9 Apr 2021 08:24:00 +0200 Message-Id: <20210409062401.2350436-9-f4bug@amsat.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210409062401.2350436-1-f4bug@amsat.org> References: <20210409062401.2350436-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) To enforce correct API usage, restrict the clock creation to hw/core/. The only possible ways to create a clock are: - Constant clock at the board level Using machine_create_constant_clock() in machine_init() - Propagated clock in QDev Using qdev_init_clock_in() or qdev_init_clock_out() in TYPE_DEVICE instance_init(). Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/core/clock-internal.h | 32 ++++++++++++++++++++++++++++++++ include/hw/clock.h | 13 ------------- hw/core/clock.c | 1 + hw/core/machine.c | 1 + hw/core/qdev-clock.c | 1 + MAINTAINERS | 1 + 6 files changed, 36 insertions(+), 13 deletions(-) create mode 100644 hw/core/clock-internal.h diff --git a/hw/core/clock-internal.h b/hw/core/clock-internal.h new file mode 100644 index 00000000000..2207be74c0f --- /dev/null +++ b/hw/core/clock-internal.h @@ -0,0 +1,32 @@ +/* + * Hardware Clocks + * + * Copyright GreenSocs 2016-2020 + * + * Authors: + * Frederic Konrad + * Damien Hedde + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef QEMU_HW_CLOCK_INTERNAL_H +#define QEMU_HW_CLOCK_INTERNAL_H + +#include "hw/clock.h" + +/** + * clock_new: + * @parent: the clock parent + * @name: the clock object name + * + * Helper function to create a new clock and parent it to @parent. There i= s no + * need to call clock_setup_canonical_path on the returned clock as it is = done + * by this function. + * + * @return the newly created clock + */ +Clock *clock_new(Object *parent, const char *name); + +#endif diff --git a/include/hw/clock.h b/include/hw/clock.h index a7187eab95e..47cb65edb32 100644 --- a/include/hw/clock.h +++ b/include/hw/clock.h @@ -109,19 +109,6 @@ extern const VMStateDescription vmstate_clock; */ void clock_setup_canonical_path(Clock *clk); =20 -/** - * clock_new: - * @parent: the clock parent - * @name: the clock object name - * - * Helper function to create a new clock and parent it to @parent. There i= s no - * need to call clock_setup_canonical_path on the returned clock as it is = done - * by this function. - * - * @return the newly created clock - */ -Clock *clock_new(Object *parent, const char *name); - /** * clock_set_callback: * @clk: the clock to register the callback into diff --git a/hw/core/clock.c b/hw/core/clock.c index a42dc3c3d29..bfa54ca0a93 100644 --- a/hw/core/clock.c +++ b/hw/core/clock.c @@ -14,6 +14,7 @@ #include "qemu/osdep.h" #include "qemu/cutils.h" #include "hw/clock.h" +#include "clock-internal.h" #include "trace.h" =20 #define CLOCK_PATH(_clk) (_clk->canonical_path) diff --git a/hw/core/machine.c b/hw/core/machine.c index 41baf80559d..e8bdcd10854 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -35,6 +35,7 @@ #include "exec/confidential-guest-support.h" #include "hw/virtio/virtio.h" #include "hw/virtio/virtio-pci.h" +#include "clock-internal.h" =20 GlobalProperty hw_compat_5_2[] =3D { { "ICH9-LPC", "smm-compat", "on"}, diff --git a/hw/core/qdev-clock.c b/hw/core/qdev-clock.c index a46384a84b7..09e14009fcd 100644 --- a/hw/core/qdev-clock.c +++ b/hw/core/qdev-clock.c @@ -16,6 +16,7 @@ #include "hw/qdev-clock.h" #include "hw/qdev-core.h" #include "qapi/error.h" +#include "clock-internal.h" =20 /* * qdev_init_clocklist: diff --git a/MAINTAINERS b/MAINTAINERS index 58f342108e9..2b10744169c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2925,6 +2925,7 @@ S: Maintained F: include/hw/clock.h F: include/hw/qdev-clock.h F: hw/core/clock.c +F: hw/core/clock-internal.h F: hw/core/clock-vmstate.c F: hw/core/qdev-clock.c F: docs/devel/clocks.rst --=20 2.26.3 From nobody Thu May 2 17:58:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.218.51 as permitted sender) client-ip=209.85.218.51; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-f51.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.218.51 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1617949494; cv=none; d=zohomail.com; s=zohoarc; b=T80zwSTrYU8Vu5XA4tPQg4K1GOonFKH0SJveMW5oE23t8OrKYTDKvwxhexyEvIg26/zKJCgG3JSUeB1XfIiaH05vFUpIhVqVQRftaAyuofb0TGf6zrJIVIpSyg4WceLH+G5LQVXdz+G2VWrpEUO4lL9MnVzNkOgDz58XEvnShQc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617949494; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eG5k+RY3W5mxHR/DqHIpbCfVA2UEY0rp9HYfHHycg/Y=; b=TSFZQhbC7f6hT/+WNhYwibS+7V7nraL1FsPu9Fsim3GmyuVsEzUwX2BP5vo8Ea8NARhYEXcuNTrsygJJA15IvzAeaCXxK0Tu+Z77Xepd04oUwoaUT1gvdf65wY/195FG1MRXiZy/PwjNSwBw5VXy4cCmy7YBTSjMrlhtdoyqZiI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.218.51 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) by mx.zohomail.com with SMTPS id 1617949494268181.73339601878968; Thu, 8 Apr 2021 23:24:54 -0700 (PDT) Received: by mail-ej1-f51.google.com with SMTP id r9so6866041ejj.3 for ; Thu, 08 Apr 2021 23:24:52 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (17.red-88-21-201.staticip.rima-tde.net. [88.21.201.17]) by smtp.gmail.com with ESMTPSA id u15sm834765edx.34.2021.04.08.23.24.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Apr 2021 23:24:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eG5k+RY3W5mxHR/DqHIpbCfVA2UEY0rp9HYfHHycg/Y=; b=AKqMgHWJ0Dqoft8I68l+hHmWod18M96s8AQnYgCnFdnj16WSwkn3EmOf7PMSXBysus xeKhkfdDG6paOAyl7YUvFC9r34cPqf7appmaSXxTiU90eUD2P4sQYkJpR3YCYxiHQOFT ErH43D/swNpqz2cE+/YMxuqmSEivM0i6EHdv4pH22eMSFnQp+UpaDQKuLahbWOwUB9Ri usp9u2ZpWKbJowtblXTEOC1d3ceyGyUdURLJ7eAnQCvaIzD+3j4E88Rp4jIp2HRUzJFF 0p/O/mGra2b464Xh8FQePIHCwj3fRk7Lb6ijBbbaAEGKKva42NT9RDMwFxjpm4LfQY1Y iA1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=eG5k+RY3W5mxHR/DqHIpbCfVA2UEY0rp9HYfHHycg/Y=; b=ANDbvf4Z/d708Ec3iHWj0YG9dvyH7kU5CeHw/Jy4u8ixgAugF5SHnL6IOtdPQfNlxc ZX8ncgRTEGoIAmDcO8qB//m3CQHdGpiij5wl97G+028rbNk8G49sHjmQMBOR3c0kFBda oSyP3MjkSI70iL64TwHCavTqoxFEL9SX9LPsoOFdlRlGuJk9H98i8kbJXAddQ8XxL1cU pAEcuaSwiMNb0VV7rYl5MHhkGYPKBD6Qf2xaojZDu47k6Su4Fa/JRw+OnBrGlZUKYNsM 1AGqTZl5ajXV+bbj8y5QIYgMCwiLF8PlXvmSN7ZWEsZQxbKGyvVlDOwucDELdk2fSUXT vuMw== X-Gm-Message-State: AOAM530VaM8YETcM3uOJjjxsLcEODRSXPPpfa5cY+Bcne6qXqYKTKHxY k6tJKeeWHALVu9fVBD/0JHk= X-Google-Smtp-Source: ABdhPJx5kAPr4OgDeOSgUmG90BXSCAhUQ2ByiPvx1WfHMVigRm5yRX97xnI0Zn6bGIEnLl4N26IeAQ== X-Received: by 2002:a17:906:ff41:: with SMTP id zo1mr14664036ejb.19.1617949490535; Thu, 08 Apr 2021 23:24:50 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Paolo Bonzini , Luc Michel , Peter Maydell , Damien Hedde , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eduardo Habkost , Marcel Apfelbaum Subject: [RFC PATCH-for-6.1 9/9] hw/core/machine: Reset machine clocks using qemu_register_reset() Date: Fri, 9 Apr 2021 08:24:01 +0200 Message-Id: <20210409062401.2350436-10-f4bug@amsat.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210409062401.2350436-1-f4bug@amsat.org> References: <20210409062401.2350436-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) While the documentation mentions: Note that if you are creating a clock with a fixed period which will never change (for example the main clock source of a board), then you'll have nothing else to do. This value will be propagated to other clocks when connecting the clocks together and devices will fetch the right value during the first reset. the clocks created in machine_init() aren't propagating their value because they are never reset (not part of the reset tree, such TYPE_DEVICE). Register a generic reset handler to have them properly reset. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/core/machine.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/core/machine.c b/hw/core/machine.c index e8bdcd10854..2817fe6a567 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -1234,6 +1234,13 @@ void machine_run_board_init(MachineState *machine) phase_advance(PHASE_MACHINE_INITIALIZED); } =20 +static void constant_clock_reset(void *opaque) +{ + Clock *clk =3D opaque; + + clock_propagate(clk); +} + Clock *machine_create_constant_clock(MachineState *machine, const char *name, unsigned freq_hz) { @@ -1241,6 +1248,7 @@ Clock *machine_create_constant_clock(MachineState *ma= chine, =20 clk =3D clock_new(OBJECT(machine), name); clock_set_hz(clk, freq_hz); + qemu_register_reset(constant_clock_reset, clk); =20 return clk; } --=20 2.26.3