All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Osipenko <digetx@gmail.com>
To: Peter Crosthwaite <crosthwaitepeter@gmail.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	qemu-arm <qemu-arm@nongnu.org>,
	QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH v8 2/4] hw/ptimer: Perform tick and counter wrap around if timer already expired
Date: Wed, 6 Jan 2016 23:52:11 +0300	[thread overview]
Message-ID: <568D7E7B.8090505@gmail.com> (raw)
In-Reply-To: <CAPokK=pSmKDdZuinYKiHur=b2hV8WFuN5AO+mB_jQByyQLSgGw@mail.gmail.com>

06.01.2016 16:59, Peter Crosthwaite пишет:

>>>> +
>>>> +            if (expired) {
>>>> +                /* Wrap around periodic counter.  */
>>>> +                counter = s->delta = s->limit - counter % s->limit;
>>>
>>>
>>> Why do you update the delta here?
>>>
>>
>> Because we would want to schedule next tick based on current wrapped around
>> counter value and not some arbitrary delta.
>>
>
> So looking at ptimer_reload(), the new schedule is done relative to
> the VM clock of the when the tick was expected to hit, not the current
> time. But this new delta is going to be relative to the now time and
> then used to update the next tick which will happen relative to
> next_event. Unless you stop or scale the timer, I don't think you need
> to do delta manipulation?
>

Yes, I missed that next_event would be set earlier (like you described) in case 
of expired timer. Thanks for the note, will fix it.

>>> Also can you just get ptimer_reload to do the modulo math for you? If the
>>> timer is !oneshot and expired, then you call ptimer_reload anyway,
>>> which will update next_event. When the expired test returns false
>>> you can just reliably use the original logic involving now and next.
>>>
>>
>> Yes, that's what I changed in V9. Have you received it?
>>
>> https://lists.nongnu.org/archive/html/qemu-devel/2016-01/msg00272.html
>>
>
> Just had a look.
>
> V9 still has the modulo I think?:
>
> +            if (expired && (counter != 0)) {
> +                /* Wrap around periodic counter.  */
> +                counter = s->delta = s->limit - counter % s->limit;
> +            }
>

Modulo is there, I just meant that V9 changed to call ptimer_reload() on counter 
== 0. As noted above, ptimer_reload would adjust next_event, so s->delta
shouldn't be set to the wrapped around counter. However it should be set to the 
limit, since delta might been altered by ptimer_set_count.

-- 
Dmitry

  reply	other threads:[~2016-01-06 20:52 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-05  2:33 [Qemu-devel] [PATCH v8 0/4] PTimer fixes and ARM MPTimer conversion Dmitry Osipenko
2016-01-05  2:33 ` [Qemu-devel] [PATCH v8 1/4] hw/ptimer: Fix issues caused by the adjusted timer limit value Dmitry Osipenko
2016-01-06 12:15   ` Peter Crosthwaite
2016-01-06 13:25     ` Dmitry Osipenko
2016-01-06 13:38       ` Peter Crosthwaite
2016-01-05  2:33 ` [Qemu-devel] [PATCH v8 2/4] hw/ptimer: Perform tick and counter wrap around if timer already expired Dmitry Osipenko
2016-01-06 12:17   ` Peter Crosthwaite
2016-01-06 13:12     ` Dmitry Osipenko
2016-01-06 13:59       ` Peter Crosthwaite
2016-01-06 20:52         ` Dmitry Osipenko [this message]
2016-01-05  2:33 ` [Qemu-devel] [PATCH v8 3/4] hw/ptimer: Update .delta on period/freq change Dmitry Osipenko
2016-01-06 12:17   ` Peter Crosthwaite
2016-01-05  2:33 ` [Qemu-devel] [PATCH v8 4/4] arm_mptimer: Convert to use ptimer Dmitry Osipenko
2016-01-06 13:17   ` Peter Crosthwaite
2016-01-07 14:40     ` Dmitry Osipenko
2016-01-07 17:34     ` 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=568D7E7B.8090505@gmail.com \
    --to=digetx@gmail.com \
    --cc=crosthwaitepeter@gmail.com \
    --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 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.