From: Dmitry Osipenko <digetx@gmail.com>
To: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>,
QEMU Developers <qemu-devel@nongnu.org>,
qemu-arm@nongnu.org
Cc: Peter Crosthwaite <crosthwaitepeter@gmail.com>,
Peter Maydell <peter.maydell@linaro.org>
Subject: Re: [Qemu-devel] [PATCH v2] hw/ptimer: Don't wrap around counter for expired timer that uses tick handler
Date: Sat, 25 Jun 2016 16:59:37 +0300 [thread overview]
Message-ID: <22cbcf06-a43d-efbc-d83e-c2d1301b8e57@gmail.com> (raw)
In-Reply-To: <d626bd7a-c54e-d2c9-10a8-3d8ab572d472@ilande.co.uk>
On 25.06.2016 16:20, Mark Cave-Ayland wrote:
> On 25/06/16 13:35, Dmitry Osipenko wrote:
>
>> Software should see timer counter wrap around only after IRQ being triggered.
>> Change returned counter value to "1" for the expired timer and avoid returning
>> wrapped around counter value in periodic mode for the timer that has bottom-half
>> handler setup, assuming it drives timer IRQ.
>>
>> This fixes regression introduced by the commit 5a50307 ("hw/ptimer: Perform
>> counter wrap around if timer already expired") on SPARC emulated machine as
>> reported by Mark Cave-Ayland.
>>
>> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
>> ---
>> hw/core/ptimer.c | 8 +++++---
>> 1 file changed, 5 insertions(+), 3 deletions(-)
>>
>> diff --git a/hw/core/ptimer.c b/hw/core/ptimer.c
>> index 05b0c27..8006442 100644
>> --- a/hw/core/ptimer.c
>> +++ b/hw/core/ptimer.c
>> @@ -93,10 +93,10 @@ uint64_t ptimer_get_count(ptimer_state *s)
>> bool oneshot = (s->enabled == 2);
>>
>> /* Figure out the current counter value. */
>> - if (s->period == 0 || (expired && (oneshot || use_icount))) {
>> + if (expired && (oneshot || use_icount || s->bh != NULL)) {
>> /* Prevent timer underflowing if it should already have
>> triggered. */
>> - counter = 0;
>> + counter = 1;
>> } else {
>> uint64_t rem;
>> uint64_t div;
>> @@ -143,7 +143,9 @@ uint64_t ptimer_get_count(ptimer_state *s)
>>
>> if (expired && counter != 0) {
>> /* Wrap around periodic counter. */
>> - counter = s->limit - (counter - 1) % s->limit;
>> + counter = s->delta = s->limit - (counter - 1) % s->limit;
>> + /* Re-arm timer according to the wrapped around value. */
>> + ptimer_reload(s);
>> }
>> }
>> } else {
>>
>
> Hi Dmitry,
>
> I ran through all of my OpenBIOS test images for qemu-system-sparc and AFAICT
> this fixes the issue without introducing any further regressions so:
>
> Tested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
>
>
> Many thanks,
>
> Mark.
>
Great! Thanks for testing it.
--
Dmitry
next prev parent reply other threads:[~2016-06-25 13:59 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-25 12:35 [Qemu-devel] [PATCH v2] hw/ptimer: Don't wrap around counter for expired timer that uses tick handler Dmitry Osipenko
2016-06-25 12:47 ` Dmitry Osipenko
2016-06-25 13:20 ` Mark Cave-Ayland
2016-06-25 13:59 ` Dmitry Osipenko [this message]
2016-06-27 13:27 ` Peter Maydell
2016-06-27 18:26 ` Dmitry Osipenko
2016-06-30 15:02 ` Peter Maydell
2016-06-30 19:01 ` Dmitry Osipenko
2016-07-01 16:36 ` Peter Maydell
2016-07-01 17:49 ` Dmitry Osipenko
2016-07-04 9:55 ` Peter Maydell
2016-07-07 10:53 ` Peter Maydell
2016-07-07 12:20 ` Dmitry Osipenko
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=22cbcf06-a43d-efbc-d83e-c2d1301b8e57@gmail.com \
--to=digetx@gmail.com \
--cc=crosthwaitepeter@gmail.com \
--cc=mark.cave-ayland@ilande.co.uk \
--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).