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 Maydell <peter.maydell@linaro.org>,
Peter Crosthwaite <crosthwaitepeter@gmail.com>
Subject: Re: [Qemu-devel] [PATCH] hw/ptimer: Don't wrap around counter for expired timer that uses tick handler
Date: Sat, 25 Jun 2016 15:20:53 +0300 [thread overview]
Message-ID: <a6cc2add-14fc-a05f-d440-e00d2029cb4e@gmail.com> (raw)
In-Reply-To: <d0f7648b-81e9-c4d9-d9d4-87e06422b441@ilande.co.uk>
On 25.06.2016 13:04, Mark Cave-Ayland wrote:
> On 24/06/16 21:29, 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 is IRQ handler.
>>
>> 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 7f89001..620ac2e 100644
>> --- a/hw/core/ptimer.c
>> +++ b/hw/core/ptimer.c
>> @@ -98,10 +98,10 @@ uint64_t ptimer_get_count(ptimer_state *s)
>> bool oneshot = (s->enabled == 2);
>>
>> /* Figure out the current counter value. */
>> - if (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;
>> @@ -148,7 +148,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,
>
> Thanks for the patch, however I am unable to apply this to git master with git
> am or directly using patch:
>
> $ patch -p1 < timer.eml
> (Stripping trailing CRs from patch.)
> patching file hw/core/ptimer.c
> Hunk #1 FAILED at 98.
> Hunk #2 succeeded at 143 (offset -5 lines).
> 1 out of 2 hunks FAILED -- saving rejects to file hw/core/ptimer.c.rej
>
> Does it need to be rebased before it can be applied?
>
>
> ATB,
>
> Mark.
>
Yes, but it's my overlook. I made it on top of tainted branch, will send V2.
Sorry and thanks for trying it and letting me know.
--
Dmitry
prev parent reply other threads:[~2016-06-25 12:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-24 20:29 [Qemu-devel] [PATCH] hw/ptimer: Don't wrap around counter for expired timer that uses tick handler Dmitry Osipenko
2016-06-25 10:04 ` Mark Cave-Ayland
2016-06-25 12:20 ` Dmitry Osipenko [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=a6cc2add-14fc-a05f-d440-e00d2029cb4e@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).