From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Aleksandar Rikalo" <aleksandar.rikalo@syrmia.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Luc Michel" <luc.michel@greensocs.com>,
"Jiaxun Yang" <jiaxun.yang@flygoat.com>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>
Subject: [PATCH v2 2/4] target/mips: Don't use clock_get_ns() in clock period calculation
Date: Tue, 15 Dec 2020 15:09:27 +0000 [thread overview]
Message-ID: <20201215150929.30311-3-peter.maydell@linaro.org> (raw)
In-Reply-To: <20201215150929.30311-1-peter.maydell@linaro.org>
Currently the MIPS code uses the old clock_get_ns() API to
calculate a time length in nanoseconds:
cpu->cp0_count_rate * clock_get_ns(MIPS_CPU(cpu)->clock)
This relies on the clock having a period which is an exact number
of nanoseconds.
Switch to the new clock_ticks_to_ns() function, which does the
multiplication internally at a higher precision.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Luc Michel <luc@lmichel.fr>
---
target/mips/cpu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/target/mips/cpu.c b/target/mips/cpu.c
index aadc6f8e74d..eea14f3b52f 100644
--- a/target/mips/cpu.c
+++ b/target/mips/cpu.c
@@ -380,8 +380,8 @@ static void mips_cp0_period_set(MIPSCPU *cpu)
{
CPUMIPSState *env = &cpu->env;
- env->cp0_count_ns = cpu->cp0_count_rate
- * clock_get_ns(MIPS_CPU(cpu)->clock);
+ env->cp0_count_ns = clock_ticks_to_ns(MIPS_CPU(cpu)->clock,
+ cpu->cp0_count_rate);
assert(env->cp0_count_ns);
}
--
2.20.1
next prev parent reply other threads:[~2020-12-15 15:10 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-15 15:09 [PATCH v2 0/4] clock: Get rid of clock_get_ns() Peter Maydell
2020-12-15 15:09 ` [PATCH v2 1/4] clock: Introduce clock_ticks_to_ns() Peter Maydell
2020-12-15 15:21 ` Richard Henderson
2020-12-15 19:48 ` Luc Michel
2020-12-15 15:09 ` Peter Maydell [this message]
2020-12-15 15:09 ` [PATCH v2 3/4] clock: Remove clock_get_ns() Peter Maydell
2020-12-15 15:09 ` [PATCH v2 4/4] clock: Define and use new clock_display_freq() Peter Maydell
2020-12-15 15:29 ` [PATCH v2 0/4] clock: Get rid of clock_get_ns() Philippe Mathieu-Daudé
2020-12-15 23:08 ` Philippe Mathieu-Daudé
2021-01-01 20:35 ` Philippe Mathieu-Daudé
2021-01-03 13:47 ` 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=20201215150929.30311-3-peter.maydell@linaro.org \
--to=peter.maydell@linaro.org \
--cc=aleksandar.rikalo@syrmia.com \
--cc=f4bug@amsat.org \
--cc=jiaxun.yang@flygoat.com \
--cc=luc.michel@greensocs.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.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).