From: Igor Mammedov <imammedo@redhat.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: "Damien Hedde" <damien.hedde@greensocs.com>,
"chen huacai" <zltjiangshi@gmail.com>,
"Aleksandar Rikalo" <aleksandar.rikalo@syrmia.com>,
"Luc Michel" <luc@lmichel.fr>,
"Eduardo Habkost" <ehabkost@redhat.com>,
"Paul Burton" <paulburton@kernel.org>,
qemu-level <qemu-devel@nongnu.org>,
"Hervé Poussineau" <hpoussin@reactos.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Huacai Chen" <chenhc@lemote.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Aurelien Jarno" <aurelien@aurel32.net>,
"Richard Henderson" <rth@twiddle.net>
Subject: Re: [PATCH v3 12/20] hw/mips/r4k: Explicit CPU frequency is 200 MHz
Date: Wed, 21 Oct 2020 14:38:32 +0200 [thread overview]
Message-ID: <20201021143832.30ec99b3@redhat.com> (raw)
In-Reply-To: <2c0fde77-4618-d5c2-3281-56ed706a9d2d@amsat.org>
On Mon, 12 Oct 2020 10:34:48 +0200
Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> Hi Huacai,
>
> On 10/11/20 5:52 AM, chen huacai wrote:
> > Hi, Philippe,
> >
> > On Sun, Oct 11, 2020 at 4:43 AM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> >>
> >> Since its introduction in commit 6af0bf9c7c3,
> >> the 'r4k' machine runs at 200 MHz.
> >>
> >> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> >> ---
> >> hw/mips/r4k.c | 8 +++++++-
> >> 1 file changed, 7 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/hw/mips/r4k.c b/hw/mips/r4k.c
> >> index 3487013a4a1..e64687b505a 100644
> >> --- a/hw/mips/r4k.c
> >> +++ b/hw/mips/r4k.c
> >> @@ -37,6 +37,7 @@
> >> #include "sysemu/reset.h"
> >> #include "sysemu/runstate.h"
> >> #include "qemu/error-report.h"
> >> +#include "hw/qdev-clock.h"
> >>
> >> #define MAX_IDE_BUS 2
> >>
> >> @@ -184,6 +185,7 @@ void mips_r4k_init(MachineState *machine)
> >> int bios_size;
> >> MIPSCPU *cpu;
> >> CPUMIPSState *env;
> >> + Clock *cpuclk;
> >> ResetData *reset_info;
> >> int i;
> >> qemu_irq *i8259;
> >> @@ -193,7 +195,11 @@ void mips_r4k_init(MachineState *machine)
> >> int be;
> >>
> >> /* init CPUs */
> >> - cpu = MIPS_CPU(cpu_create(machine->cpu_type));
> >> + cpu = MIPS_CPU(object_new(machine->cpu_type));
> >> + cpuclk = clock_new(OBJECT(machine), "cpu-refclk");
> >> + clock_set_hz(cpuclk, 200000000); /* 200 MHz */
> >> + qdev_connect_clock_in(DEVICE(cpu), "clk-in", cpuclk);
> >> + qdev_realize(DEVICE(cpu), NULL, &error_abort);
> >
> > Can we add a new parameter to cpu_create() and set the freq in the core code?
>
> Adding a new parameter seems a good idea.
>
> Both maintainers of the core code are reluctant to add
> a CPU clock to the core code, see:
> https://www.mail-archive.com/qemu-devel@nongnu.org/msg747589.html
> https://www.mail-archive.com/qemu-devel@nongnu.org/msg747612.html
> Which is why I restricted that to the MIPS CPUs.
>
the reason for that is that it's used only by a handful of devices
and not widespread.
> On ARM, Damien started to use clocks on the Zynq SoC (merged):
> https://www.mail-archive.com/qemu-devel@nongnu.org/msg694604.html
> Luc is working on adding a clock manager to the Broadcom SoC:
> https://lists.gnu.org/archive/html/qemu-devel/2020-10/msg02840.html
>
> I also started converting one UART devices:
> https://www.mail-archive.com/qemu-devel@nongnu.org/msg727972.html
>
> So IMO the core code will soon require this. Maybe we will add it
> during the next development window.
>
> Meanwhile I can add a mips_cpu_create_with_clock() in preparation
boards that need property settings in between object_new() and realize()
typically open code just that and/or use plug/preplug handler(callback)
to set properties. preplug handler should work with cpu_create() just fine.
If you have multiple mips boards that will new clock mechanism,
mips_cpu_create_with_clock() wrapper would work as well (it's a bit less
complicated compared to preplug handler but not too much)
> of cpu_create_with_clock().
>
> >
> > Huacai
> >> env = &cpu->env;
> >>
> >> reset_info = g_malloc0(sizeof(ResetData));
> >> --
> >> 2.26.2
> >>
> >
> >
>
next prev parent reply other threads:[~2020-10-21 12:40 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-10 20:42 [PATCH v3 00/20] hw/mips: Set CPU frequency Philippe Mathieu-Daudé
2020-10-10 20:43 ` [PATCH v3 01/20] util/cutils: Introduce freq_to_str() to display Hertz units Philippe Mathieu-Daudé
2020-10-10 20:43 ` [PATCH v3 02/20] qdev-monitor: Display frequencies scaled to SI unit Philippe Mathieu-Daudé
2020-10-10 20:43 ` [PATCH v3 03/20] hw/qdev-clock: Display error hint when clock is missing from device Philippe Mathieu-Daudé
2020-10-10 20:43 ` [PATCH v3 04/20] hw/core/clock: add the clock_new helper function Philippe Mathieu-Daudé
2020-10-10 20:43 ` [PATCH v3 05/20] target/mips: Move cpu_mips_get_random() with CP0 helpers Philippe Mathieu-Daudé
2020-10-12 7:35 ` Luc Michel
2020-10-10 20:43 ` [PATCH v3 06/20] target/mips/cp0_timer: Explicit unit in variable name Philippe Mathieu-Daudé
2020-10-10 20:43 ` [PATCH v3 07/20] target/mips/cp0_timer: Document TIMER_PERIOD origin Philippe Mathieu-Daudé
2020-10-10 20:43 ` [PATCH v3 08/20] target/mips: Move cp0_count_ns to CPUMIPSState Philippe Mathieu-Daudé
2020-10-12 5:42 ` Jiaxun Yang
2020-10-10 20:43 ` [PATCH v3 09/20] target/mips/cpu: Calculate the CP0 timer period using the CPU frequency Philippe Mathieu-Daudé
2020-10-12 5:48 ` Jiaxun Yang
2020-10-10 20:43 ` [PATCH v3 10/20] target/mips/cpu: Make cp0_count_rate a property Philippe Mathieu-Daudé
2020-10-10 20:43 ` [PATCH v3 11/20] target/mips/cpu: Allow the CPU to use dynamic frequencies Philippe Mathieu-Daudé
2020-10-10 20:43 ` [PATCH v3 12/20] hw/mips/r4k: Explicit CPU frequency is 200 MHz Philippe Mathieu-Daudé
2020-10-11 3:52 ` chen huacai
2020-10-12 8:34 ` Philippe Mathieu-Daudé
2020-10-21 12:38 ` Igor Mammedov [this message]
2020-10-10 20:43 ` [PATCH v3 13/20] hw/mips/fuloong2e: Set CPU frequency to 533 MHz Philippe Mathieu-Daudé
2020-10-12 5:54 ` Jiaxun Yang
2020-10-10 20:43 ` [PATCH v3 14/20] hw/mips/mipssim: Correct CPU frequency Philippe Mathieu-Daudé
2020-10-10 20:43 ` [PATCH v3 15/20] hw/mips/jazz: Correct CPU frequencies Philippe Mathieu-Daudé
2020-10-10 20:43 ` [PATCH v3 16/20] hw/mips/cps: Expose input clock and connect it to CPU cores Philippe Mathieu-Daudé
2020-10-10 20:43 ` [PATCH v3 17/20] hw/mips/boston: Set CPU frequency to 1 GHz Philippe Mathieu-Daudé
2020-10-10 20:43 ` [PATCH v3 18/20] hw/mips/malta: Set CPU frequency to 320 MHz Philippe Mathieu-Daudé
2020-10-10 20:43 ` [PATCH v3 19/20] hw/mips/cps: Do not allow use without input clock Philippe Mathieu-Daudé
2020-10-10 20:43 ` [PATCH v3 20/20] target/mips/cpu: Display warning when CPU is used " Philippe Mathieu-Daudé
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=20201021143832.30ec99b3@redhat.com \
--to=imammedo@redhat.com \
--cc=aleksandar.rikalo@syrmia.com \
--cc=alex.bennee@linaro.org \
--cc=aurelien@aurel32.net \
--cc=berrange@redhat.com \
--cc=chenhc@lemote.com \
--cc=damien.hedde@greensocs.com \
--cc=ehabkost@redhat.com \
--cc=f4bug@amsat.org \
--cc=hpoussin@reactos.org \
--cc=luc@lmichel.fr \
--cc=paulburton@kernel.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
--cc=zltjiangshi@gmail.com \
/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.