All of lore.kernel.org
 help / color / mirror / Atom feed
From: Axel Heider <axelheider@gmx.de>
To: qemu-devel@nongnu.org
Cc: qemu-arm@nongnu.org, Peter Maydell <peter.maydell@linaro.org>
Subject: Re: [PATCH qemu.git v2 9/9] hw/timer/imx_epit: fix compare timer handling
Date: Tue, 29 Nov 2022 23:27:23 +0100	[thread overview]
Message-ID: <93a679b3-ddf9-354c-079d-b2e9b0ec9694@gmx.de> (raw)
In-Reply-To: <CAFEAcA-hDkGMnz4iO_V1FHHPer7uSMuNyzoaJu8wuoHY8NpCgg@mail.gmail.com>

Peter,

> If you're correcting behaviour of the timer use here,
> you should start by fixing the way the timers are currently
> created with PTIMER_POLICY_LEGACY. That setting is basically
> "bug-for-bug-compatibility with very old QEMU, for devices
> where nobody really knows what the hardware behaviour should
> be". Where we do know what the hardware's supposed to do and
> we have some way of testing we're not breaking guest code,
> the right thing is to set the correct policy flags for
> the desired behaviour. These are documented in a comment
> near the top of include/hw/ptimer.h.

I would prefer to postpone changing PTIMER_POLICY_LEGACY to a
separate patchset, which is on top of the current one, as this
seems not to be an issue at the moment. Fixing the general isses
on access and ensure the flags are correct seem more pressing,
and this seem unrelated to the timer policy.


> It is modestly harmful because the sequence
>     counter = ptimer_get_count(s->timer_reload);
>     ...
>     ptimer_set_count(s->timer_cmp, counter);
>
> will cause the counter to lose or gain time. This happens because
> when you call "get" the ptimer code will look at the current exact
> time in nanoseconds and tell you the counter value at that point.
> That is probably somewhere in the middle of a timer-clock period
> (which runs at whatever frequency you tell the ptimer to use):
> for argument's sake, suppose the timer-clock counts every 1000ns.
> Suppose at the point of the 'get' the next tick will be in 300ns time.
> When you do a "set" that is assumed to be the result of a guest
> register write of some kind, and will effectively start a new
> timer-clock period. This means the next tick will not be for
> a full 1000ns, and we just lost 300ns (or gained 700ns perhaps).
> So it's better to avoid this kind of "get-and-then-set" code.

I see you point. The "get-and-then-set" was already in the code, I
did not really change this. I have tried to find a better way to
implement this, but could not come up with something so far. Any
suggestions here that is non trivial? Othereise I would prefer to
look into this in a new patch-set, together with replacing the
PTIMER_POLICY_LEGACY.


Axel


  reply	other threads:[~2022-11-29 22:28 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-07 16:42 [PATCH qemu.git v2 0/9] hw/timer/imx_epit: imprive and fix compare timer handling ~axelheider
2022-10-25 10:33 ` [PATCH qemu.git v2 6/9] hw/timer/imx_epit: remove explicit fields cnt and freq ~axelheider
2022-11-18 15:54   ` Peter Maydell
2022-10-25 11:23 ` [PATCH qemu.git v2 3/9] hw/timer/imx_epit: simplify interrupt logic ~axelheider
2022-11-18 15:40   ` Peter Maydell
2022-11-21 17:35     ` Axel Heider
2022-10-25 15:33 ` [PATCH qemu.git v2 1/9] hw/timer/imx_epit: improve comments ~axelheider
2022-11-18 15:35   ` Peter Maydell
2022-10-25 18:32 ` [PATCH qemu.git v2 4/9] hw/timer/imx_epit: software reset clears the interrupt ~axelheider
2022-11-18 15:42   ` Peter Maydell
2022-10-27 13:09 ` [PATCH qemu.git v2 7/9] hw/timer/imx_epit: factor out register write handlers ~axelheider
2022-11-18 16:05   ` Peter Maydell
2022-10-30 23:59 ` [PATCH qemu.git v2 2/9] hw/timer/imx_epit: cleanup CR defines ~axelheider
2022-11-18 15:35   ` Peter Maydell
2022-11-02 15:36 ` [PATCH qemu.git v2 5/9] hw/timer/imx_epit: do not persist CR.SWR bit ~axelheider
2022-11-18 15:47   ` Peter Maydell
2022-11-19 17:41     ` Axel Heider
2022-11-03 11:09 ` [PATCH qemu.git v2 9/9] hw/timer/imx_epit: fix compare timer handling ~axelheider
2022-11-18 19:00   ` Peter Maydell
2022-11-29 22:27     ` Axel Heider [this message]
2022-11-04 15:01 ` [PATCH qemu.git v2 8/9] hw/timer/imx_epit: change reset handling ~axelheider
2022-11-18 15:58   ` Peter Maydell

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=93a679b3-ddf9-354c-079d-b2e9b0ec9694@gmx.de \
    --to=axelheider@gmx.de \
    --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.