From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-arm@nongnu.org, qemu-devel@nongnu.org
Subject: [PATCH 1/2] hw/core/ptimer: Support ptimer being disabled by timer callback
Date: Thu, 15 Oct 2020 16:18:28 +0100 [thread overview]
Message-ID: <20201015151829.14656-2-peter.maydell@linaro.org> (raw)
In-Reply-To: <20201015151829.14656-1-peter.maydell@linaro.org>
In ptimer_reload(), we call the callback function provided by the
timer device that is using the ptimer. This callback might disable
the ptimer. The code mostly handles this correctly, except that
we'll still print the warning about "Timer with delta zero,
disabling" if the now-disabled timer happened to be set such that it
would fire again immediately if it were enabled (eg because the
limit/reload value is zero).
Suppress the spurious warning message and the unnecessary
repeat-deletion of the underlying timer in this case.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/core/ptimer.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/hw/core/ptimer.c b/hw/core/ptimer.c
index c6d2beb1dac..2aa97cb665c 100644
--- a/hw/core/ptimer.c
+++ b/hw/core/ptimer.c
@@ -117,6 +117,10 @@ static void ptimer_reload(ptimer_state *s, int delta_adjust)
}
if (delta == 0) {
+ if (s->enabled == 0) {
+ /* trigger callback disabled the timer already */
+ return;
+ }
if (!qtest_enabled()) {
fprintf(stderr, "Timer with delta zero, disabling\n");
}
--
2.20.1
next prev parent reply other threads:[~2020-10-15 15:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-15 15:18 [PATCH 0/2] armv7m_systick: Rewrite to use ptimers Peter Maydell
2020-10-15 15:18 ` Peter Maydell [this message]
2020-10-26 21:45 ` [PATCH 1/2] hw/core/ptimer: Support ptimer being disabled by timer callback Philippe Mathieu-Daudé
2020-10-15 15:18 ` [PATCH 2/2] hw/timer/armv7m_systick: Rewrite to use ptimers Peter Maydell
2020-10-15 15:31 ` Peter Maydell
2020-10-26 21:57 ` Philippe Mathieu-Daudé
2020-10-26 20:42 ` [PATCH 0/2] armv7m_systick: " Peter Maydell
2020-10-26 20:54 ` 罗勇刚(Yonggang Luo)
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=20201015151829.14656-2-peter.maydell@linaro.org \
--to=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).