From: "Andrew Jeffery" <andrew@aj.id.au>
To: "Peter Maydell" <peter.maydell@linaro.org>
Cc: "Cédric Le Goater" <clg@kaod.org>, qemu-arm <qemu-arm@nongnu.org>,
"QEMU Developers" <qemu-devel@nongnu.org>,
"Joel Stanley" <joel@jms.id.au>
Subject: Re: [PATCH v5] target-arm: Make the counter tick relative to cntfrq
Date: Fri, 20 Sep 2019 15:39:36 +0930 [thread overview]
Message-ID: <327db2f1-a146-472c-89f3-9187b2cb5f70@www.fastmail.com> (raw)
In-Reply-To: <CAFEAcA_h80VQVC0jE7v8kmsuXU=16+KXSKQ-qhuRNTct7X6X7g@mail.gmail.com>
On Wed, 18 Sep 2019, at 01:44, Peter Maydell wrote:
> On Thu, 12 Sep 2019 at 07:56, Andrew Jeffery <andrew@aj.id.au> wrote:
> > diff --git a/target/arm/helper.c b/target/arm/helper.c
> > index 507026c9154b..09975704d47f 100644
> > --- a/target/arm/helper.c
> > +++ b/target/arm/helper.c
> > @@ -2409,7 +2409,21 @@ static CPAccessResult gt_stimer_access(CPUARMState *env,
> >
> > static uint64_t gt_get_countervalue(CPUARMState *env)
> > {
> > - return qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) / GTIMER_SCALE;
> > + uint64_t effective;
> > +
> > + /*
> > + * Deal with quantized clock scaling by calculating the effective frequency
> > + * in terms of the timer scale.
> > + */
> > + if (env->cp15.c14_cntfrq <= NANOSECONDS_PER_SECOND) {
> > + uint32_t scale = NANOSECONDS_PER_SECOND / env->cp15.c14_cntfrq;
> > + effective = NANOSECONDS_PER_SECOND / scale;
> > + } else {
> > + effective = NANOSECONDS_PER_SECOND;
> > + }
>
> What is this doing, and why didn't we need to do it before?
I'll fix all of your other comments, but I think this question in particular is best
answered by turning the patch into a short series. It's a bit of a complex story.
I'll try to split what's going on into smaller steps so what I've done above is
better documented. The short story is there's asymmetry between converting
time to ticks and ticks to time that leads us to schedule timers in the past for
most CNTFRQ values if we don't do something like the above.
Andrew
prev parent reply other threads:[~2019-09-20 6:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-12 6:56 [Qemu-devel] [PATCH v5] target-arm: Make the counter tick relative to cntfrq Andrew Jeffery
2019-09-17 16:14 ` Peter Maydell
2019-09-17 19:25 ` Richard Henderson
2019-09-20 6:14 ` Andrew Jeffery
2019-09-20 6:09 ` Andrew Jeffery [this message]
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=327db2f1-a146-472c-89f3-9187b2cb5f70@www.fastmail.com \
--to=andrew@aj.id.au \
--cc=clg@kaod.org \
--cc=joel@jms.id.au \
--cc=peter.maydell@linaro.org \
--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).