From: Stefan Hajnoczi <stefanha@gmail.com>
To: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
Emil Condrea <emilcondrea@gmail.com>,
QEMU Developers <qemu-devel@nongnu.org>,
Stefan Hajnoczi <stefanha@redhat.com>,
Alistair Francis <alistair.francis@xilinx.com>
Subject: Re: [Qemu-devel] [PATCH] replaced get_ticks_per_sec() with constant
Date: Tue, 31 Mar 2015 15:19:11 +0100 [thread overview]
Message-ID: <20150331141911.GD27156@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <CAEgOgz4Wm-2M0pQd-Gv-mk4Y+9DCzNYLVWBkeMiT-yfWOA17EQ@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2798 bytes --]
On Tue, Mar 31, 2015 at 09:46:32AM +1000, Peter Crosthwaite wrote:
> On Tue, Mar 31, 2015 at 7:52 AM, Peter Maydell <peter.maydell@linaro.org> wrote:
> > On 30 March 2015 at 14:01, Stefan Hajnoczi <stefanha@redhat.com> wrote:
> >> On Sat, Mar 28, 2015 at 06:22:11PM +0200, Emil Condrea wrote:
> >>> diff --git a/target-arm/helper.c b/target-arm/helper.c
> >>> index 10886c5..504530a 100644
> >>> --- a/target-arm/helper.c
> >>> +++ b/target-arm/helper.c
> >>> @@ -649,7 +649,7 @@ void pmccntr_sync(CPUARMState *env)
> >>> uint64_t temp_ticks;
> >>>
> >>> temp_ticks = muldiv64(qemu_clock_get_us(QEMU_CLOCK_VIRTUAL),
> >>> - get_ticks_per_sec(), 1000000);
> >>> + NSEC_PER_SEC, 1000000);
> >>>
> >>> if (env->cp15.c9_pmcr & PMCRD) {
> >>> /* Increment once every 64 processor clock cycles */
> >>> @@ -688,7 +688,7 @@ static uint64_t pmccntr_read(CPUARMState *env, const ARMCPRegInfo *ri)
> >>> }
> >>>
> >>> total_ticks = muldiv64(qemu_clock_get_us(QEMU_CLOCK_VIRTUAL),
> >>> - get_ticks_per_sec(), 1000000);
> >>> + NSEC_PER_SEC, 1000000);
> >>>
> >>> if (env->cp15.c9_pmcr & PMCRD) {
> >>> /* Increment once every 64 processor clock cycles */
> >>> @@ -709,7 +709,7 @@ static void pmccntr_write(CPUARMState *env, const ARMCPRegInfo *ri,
> >>> }
> >>>
> >>> total_ticks = muldiv64(qemu_clock_get_us(QEMU_CLOCK_VIRTUAL),
> >>> - get_ticks_per_sec(), 1000000);
> >>> + NSEC_PER_SEC, 1000000);
> >>
> >> Peter: I wonder why the muldiv64() expression is necessary. Is it
> >> intentionally returning the microsecond clock converted to nanoseconds?
> >>
>
> That is the effect but not the intention. In this context,
> get_tick_per_sec() is really trying to be a clock signal frequency
> rate and QEMU ARM is just hardcoding to 1GHz. Because its fixed and in
> terms of real time, your proposed cancellation is possible.
>
> For ARM CPU we are simplifying the CPU clock pin as ns (basically 1GHz
> clock). Ideally this should be parameterisable as this clock is
> controlled outside of the ARM processor.
>
> I think the form of the current code has value for self documentation,
> and maybe should have a comment explaining this 1GHz harcodedness.
> When we get around to parameterising the ARM CPU frequency as a QOM
> property this code should be fixed by doing:
>
> s/NSEC_PER_SEC/s->clock_freq_hz/
>
> So this muldiv in its current form is really preparation for that. Can
> we keep it? Your patch as-is looks good to me.
>
> Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Thanks for explaining.
Stefan
[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]
next prev parent reply other threads:[~2015-03-31 14:19 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-28 16:22 [Qemu-devel] [PATCH] replaced get_ticks_per_sec() with constant Emil Condrea
2015-03-30 13:01 ` Stefan Hajnoczi
2015-03-30 21:52 ` Peter Maydell
2015-03-30 23:46 ` Peter Crosthwaite
2015-03-31 14:19 ` Stefan Hajnoczi [this message]
2015-03-30 13:01 ` Stefan Hajnoczi
2015-03-31 17:16 ` Emil Condrea
2015-07-05 6:15 ` Emil Condrea
2015-07-06 15:11 ` Stefan Hajnoczi
2015-07-08 13:29 ` Emil Condrea
2015-07-09 9:05 ` Stefan Hajnoczi
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=20150331141911.GD27156@stefanha-thinkpad.redhat.com \
--to=stefanha@gmail.com \
--cc=alistair.francis@xilinx.com \
--cc=emilcondrea@gmail.com \
--cc=peter.crosthwaite@xilinx.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.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 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).