From: Peter Maydell <peter.maydell@linaro.org>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: Damien Hedde <damien.hedde@greensocs.com>,
Luc Michel <luc@lmichel.fr>,
Eduardo Habkost <ehabkost@redhat.com>,
QEMU Developers <qemu-devel@nongnu.org>,
qemu-arm <qemu-arm@nongnu.org>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [RFC PATCH-for-6.1 9/9] hw/core/machine: Reset machine clocks using qemu_register_reset()
Date: Mon, 19 Apr 2021 15:27:55 +0100 [thread overview]
Message-ID: <CAFEAcA8-Nd7MNU1pWB0JvnaiHN_o2_iQqhL+j8B_5DVBDh9nSw@mail.gmail.com> (raw)
In-Reply-To: <20210409062401.2350436-10-f4bug@amsat.org>
On Fri, 9 Apr 2021 at 07:24, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> 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é <f4bug@amsat.org>
> ---
> 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);
> }
>
> +static void constant_clock_reset(void *opaque)
> +{
> + Clock *clk = 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 *machine,
>
> clk = clock_new(OBJECT(machine), name);
> clock_set_hz(clk, freq_hz);
> + qemu_register_reset(constant_clock_reset, clk);
You mention this in the cover letter, but I agree that this
isn't really very nice. The machine's reset method ought to
reset the clocks (either explicitly or maybe some day implicitly).
thanks
-- PMM
next prev parent reply other threads:[~2021-04-19 14:30 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-09 6:23 [RFC PATCH-for-6.1 0/9] hw/clock: Strengthen machine (non-qdev) clock propagation Philippe Mathieu-Daudé
2021-04-09 6:23 ` [RFC PATCH-for-6.1 1/9] hw/core/clock: Increase clock propagation trace events verbosity Philippe Mathieu-Daudé
2021-04-09 6:23 ` [RFC PATCH-for-6.1 2/9] hw/core/machine: Add machine_create_constant_clock() helper Philippe Mathieu-Daudé
2021-04-09 6:23 ` [RFC PATCH-for-6.1 3/9] hw/arm: Use new " Philippe Mathieu-Daudé
2021-04-09 6:23 ` [RFC PATCH-for-6.1 4/9] hw/mips: " Philippe Mathieu-Daudé
2021-04-09 6:23 ` [RFC PATCH-for-6.1 5/9] hw/core/qdev-clock: Add qdev_ground_clock() helper Philippe Mathieu-Daudé
2021-04-19 14:22 ` Peter Maydell
2021-04-09 6:23 ` [RFC PATCH-for-6.1 6/9] hw/misc/bcm2835_cprman: Use " Philippe Mathieu-Daudé
2021-04-09 6:23 ` [RFC PATCH-for-6.1 7/9] hw/misc/bcm2835_cprman: Feed 'xosc' from the board Philippe Mathieu-Daudé
2021-04-19 14:24 ` Peter Maydell
2021-04-09 6:24 ` [RFC PATCH-for-6.1 8/9] hw/clock: Declare clock_new() internally Philippe Mathieu-Daudé
2021-04-19 14:26 ` Peter Maydell
2021-04-20 9:27 ` Philippe Mathieu-Daudé
2021-04-09 6:24 ` [RFC PATCH-for-6.1 9/9] hw/core/machine: Reset machine clocks using qemu_register_reset() Philippe Mathieu-Daudé
2021-04-19 14:27 ` Peter Maydell [this message]
2021-04-09 13:12 ` [RFC PATCH-for-6.1 0/9] hw/clock: Strengthen machine (non-qdev) clock propagation Philippe Mathieu-Daudé
2021-04-09 14:11 ` Philippe Mathieu-Daudé
2021-04-09 14:20 ` Philippe Mathieu-Daudé
2021-04-10 13:19 ` Luc Michel
2021-04-10 13:53 ` Philippe Mathieu-Daudé
2021-04-10 15:15 ` Peter Maydell
2021-04-10 16:14 ` Philippe Mathieu-Daudé
2021-04-12 10:11 ` Peter Maydell
2021-04-12 10:31 ` Philippe Mathieu-Daudé
2021-04-12 10:44 ` Peter Maydell
2021-04-12 11:00 ` Philippe Mathieu-Daudé
2021-04-13 19:43 ` Eduardo Habkost
2021-05-03 15:20 ` Igor Mammedov
2021-05-03 16:37 ` Philippe Mathieu-Daudé
2021-04-19 19:39 ` Luc Michel
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=CAFEAcA8-Nd7MNU1pWB0JvnaiHN_o2_iQqhL+j8B_5DVBDh9nSw@mail.gmail.com \
--to=peter.maydell@linaro.org \
--cc=damien.hedde@greensocs.com \
--cc=ehabkost@redhat.com \
--cc=f4bug@amsat.org \
--cc=luc@lmichel.fr \
--cc=pbonzini@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 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).