From: Alistair Francis <alistair23@gmail.com>
To: Andrew Jones <ajones@ventanamicro.com>
Cc: qemu-devel@nongnu.org, qemu-riscv@nongnu.org,
Anup Patel <apatel@ventanamicro.com>,
palmer@dabbelt.com, alistair.francis@wdc.com,
bmeng.cn@gmail.com, liwei1518@gmail.com,
zhiwei_liu@linux.alibaba.com,
Daniel Henrique Barboza <dbarboza@ventanamicro.com>,
atishp@rivosinc.com
Subject: Re: [PATCH] target/riscv: Stop timer with infinite timecmp
Date: Tue, 3 Sep 2024 10:54:24 +1000 [thread overview]
Message-ID: <CAKmqyKPBhKkOZAHw05BO9wmDNPiymOf3Bvc_z0zVWZ86VaNm6A@mail.gmail.com> (raw)
In-Reply-To: <20240829084002.1805006-2-ajones@ventanamicro.com>
On Thu, Aug 29, 2024 at 6:40 PM Andrew Jones <ajones@ventanamicro.com> wrote:
>
> While the spec doesn't state it, setting timecmp to UINT64_MAX is
> another way to stop a timer, as it's considered setting the next
> timer event to occur at infinity. And, even if the time CSR does
> eventually reach UINT64_MAX, the very next tick will bring it back to
> zero, once again less than timecmp. For this reason
> riscv_timer_write_timecmp() special cases UINT64_MAX. However, if a
> previously set timecmp has not yet expired, then setting timecmp to
> UINT64_MAX to disable / stop it would not work, as the special case
> left the previous QEMU timer active, which would then still deliver
> an interrupt at that previous timecmp time. Ensure the stopped timer
> will not still deliver an interrupt by also deleting the QEMU timer
> in the UINT64_MAX special case.
>
> Fixes: ae0edf2188b3 ("target/riscv: No need to re-start QEMU timer when timecmp == UINT64_MAX")
> Signed-off-by: Andrew Jones <ajones@ventanamicro.com>
Thanks!
Applied to riscv-to-apply.next
Alistair
> ---
> target/riscv/time_helper.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/target/riscv/time_helper.c b/target/riscv/time_helper.c
> index 8d245bed3ae3..bc0d9a0c4c35 100644
> --- a/target/riscv/time_helper.c
> +++ b/target/riscv/time_helper.c
> @@ -92,6 +92,7 @@ void riscv_timer_write_timecmp(CPURISCVState *env, QEMUTimer *timer,
> * equals UINT64_MAX.
> */
> if (timecmp == UINT64_MAX) {
> + timer_del(timer);
> return;
> }
>
> --
> 2.45.2
>
>
prev parent reply other threads:[~2024-09-03 0:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-29 8:40 [PATCH] target/riscv: Stop timer with infinite timecmp Andrew Jones
2024-08-29 23:46 ` Alistair Francis
2024-08-30 11:05 ` Vladimir Isaev
2024-08-30 14:50 ` Andrew Jones
2024-08-30 17:47 ` Vladimir Isaev
2024-09-03 0:54 ` Alistair Francis [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=CAKmqyKPBhKkOZAHw05BO9wmDNPiymOf3Bvc_z0zVWZ86VaNm6A@mail.gmail.com \
--to=alistair23@gmail.com \
--cc=ajones@ventanamicro.com \
--cc=alistair.francis@wdc.com \
--cc=apatel@ventanamicro.com \
--cc=atishp@rivosinc.com \
--cc=bmeng.cn@gmail.com \
--cc=dbarboza@ventanamicro.com \
--cc=liwei1518@gmail.com \
--cc=palmer@dabbelt.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=zhiwei_liu@linux.alibaba.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).