From: Stafford Horne <shorne@gmail.com>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH 2/2] hw/openrisc: Fixed undercounting of TTCR in continuous mode
Date: Sat, 23 Nov 2024 17:11:37 +0000 [thread overview]
Message-ID: <Z0IMyRB3O4Q9s5eG@antec> (raw)
In-Reply-To: <0105f2c1-9390-4557-bfad-668a328ce951@linaro.org>
On Sat, Nov 23, 2024 at 07:39:57AM -0600, Richard Henderson wrote:
> On 11/23/24 04:38, Stafford Horne wrote:
> > + or1k_timer->ttcr = or1k_timer->ttcr_offset +
> > + (now - or1k_timer->clk_offset + TIMER_PERIOD - 1) / TIMER_PERIOD;
>
> Better using DIV_ROUND_UP.
Sure, I can change it to that.
> > + /* Zero the count by applying a negative offset to the counter */
> > + or1k_timer->ttcr_offset += UINT32_MAX - (cpu->env.ttmr & TTMR_TP);
>
> Since UINT32_MAX is -1 in this context, this appears to be off-by-one.
> I think -(ttmr & mask) alone is correct.
Thanks, I did send a mail to Joel asking about this bit. He didn't respond for 2
weeks to I just sent the patch as is as it appears to work. As I understand,
yes UINT32_MAX is just -1. But why the -1? I guess it's because after
ttcr_offset is updated we call cpu_openrisc_timer_update() which calls
cpu_openrisc_count_update() to update ttcr. Since a few _ns would have passed
and we are rounding up it will update ttcr to 0.
But maybe I am reading too much into it.
If you think that makes sense I could add a comment as such, also I would prefer
to change to UINT32_MAX to -1.
-Stafford
next prev parent reply other threads:[~2024-11-23 17:12 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-23 10:38 [PATCH 0/2] Misc OpenRISC fixes for 9.2.0 Stafford Horne
2024-11-23 10:38 ` [PATCH 1/2] hw/openrisc/openrisc_sim: keep serial@90000000 as default Stafford Horne
2024-11-25 14:02 ` Peter Maydell
2024-12-01 6:44 ` Stafford Horne
2024-12-01 6:57 ` Stafford Horne
2024-12-02 10:54 ` Peter Maydell
2024-11-23 10:38 ` [PATCH 2/2] hw/openrisc: Fixed undercounting of TTCR in continuous mode Stafford Horne
2024-11-23 13:39 ` Richard Henderson
2024-11-23 17:11 ` Stafford Horne [this message]
2024-11-23 21:11 ` Richard Henderson
2024-11-23 12:12 ` [PATCH 0/2] Misc OpenRISC fixes for 9.2.0 Michael Tokarev
2024-11-23 17:01 ` Stafford Horne
2024-11-24 5:03 ` Michael Tokarev
2024-11-24 7:39 ` Stafford Horne
-- strict thread matches above, loose matches on Subject: below --
2024-12-19 20:08 [PATCH 2/2] hw/openrisc: Fixed undercounting of TTCR in continuous mode Joel Holdsworth
2024-12-19 21:50 ` Stafford Horne
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=Z0IMyRB3O4Q9s5eG@antec \
--to=shorne@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.