From: Guenter Roeck <linux@roeck-us.net>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-arm <qemu-arm@nongnu.org>, QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-arm] [PATCH] hw/char/cmsdk-apb-timer: Correctly identify and set one-shot mode
Date: Tue, 26 Jun 2018 10:59:00 -0700 [thread overview]
Message-ID: <20180626175900.GA4307@roeck-us.net> (raw)
In-Reply-To: <CAFEAcA_8TAWdkgTzPPE7eggP4UAHjVPmcXiEa_-RCxDBphJ4HA@mail.gmail.com>
On Tue, Jun 26, 2018 at 06:17:44PM +0100, Peter Maydell wrote:
> On 19 June 2018 at 03:08, Guenter Roeck <linux@roeck-us.net> wrote:
> > The CMSDK APB timer is currently always configured as periodic timer.
> > This results in the following messages when trying to boot Linux.
> >
> > Timer with delta zero, disabling
> >
> > If the timer limit set with the RELOAD command is 0, the timer
> > needs to be enabled as one-shot timer.
> >
> > Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> > ---
> > hw/timer/cmsdk-apb-timer.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/hw/timer/cmsdk-apb-timer.c b/hw/timer/cmsdk-apb-timer.c
> > index 9878746..79c1b49 100644
> > --- a/hw/timer/cmsdk-apb-timer.c
> > +++ b/hw/timer/cmsdk-apb-timer.c
> > @@ -119,7 +119,7 @@ static void cmsdk_apb_timer_write(void *opaque, hwaddr offset, uint64_t value,
> > }
> > s->ctrl = value & 0xf;
> > if (s->ctrl & R_CTRL_EN_MASK) {
> > - ptimer_run(s->timer, 0);
> > + ptimer_run(s->timer, ptimer_get_limit(s->timer) == 0);
> > } else {
> > ptimer_stop(s->timer);
> > }
> > --
> > 2.7.4
>
> Thanks for this patch. I was wondering whether it would be better
> just to remove the fprintf message instead. I'll either apply
> this or send a patch to do that before 3.0, anyway.
>
If I recall correctly, I tried that, and it did not help.
The messages don't happen too often, and the message itself
does not cause a problem. Issue is that the interrupts happen
at the wrong time or not at all (after a while, ie after the
configured one-shot time expires), and the kernel really doesn't
like that.
I think the underlying problem was that the periodic timer counts
the period down (based on the time set for the one-shot timer),
stops with the "Timer with delta zero, disabling" message once
the period reaches 0, and does not fire anymore afterwards.
As a result, the kernel fails to boot maybe 90% of the time.
I should probably have mentioned that in more detail in the
commit log.
> I think we also want to make sure we convert back to a
> periodic timer if the reload register is written with a nonzero
> value before the timer expires (and that if that happens after
> the timer expired that we restart the timer). Thinking about
> this is also on my todo list.
>
I thought that was handled in the Linux driver by disabling
the timer, updating the period, and then re-enabling it in
periodic mode, but I may have misinterpreted the code.
Guenter
WARNING: multiple messages have this Message-ID (diff)
From: Guenter Roeck <linux@roeck-us.net>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-arm <qemu-arm@nongnu.org>, QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] hw/char/cmsdk-apb-timer: Correctly identify and set one-shot mode
Date: Tue, 26 Jun 2018 10:59:00 -0700 [thread overview]
Message-ID: <20180626175900.GA4307@roeck-us.net> (raw)
In-Reply-To: <CAFEAcA_8TAWdkgTzPPE7eggP4UAHjVPmcXiEa_-RCxDBphJ4HA@mail.gmail.com>
On Tue, Jun 26, 2018 at 06:17:44PM +0100, Peter Maydell wrote:
> On 19 June 2018 at 03:08, Guenter Roeck <linux@roeck-us.net> wrote:
> > The CMSDK APB timer is currently always configured as periodic timer.
> > This results in the following messages when trying to boot Linux.
> >
> > Timer with delta zero, disabling
> >
> > If the timer limit set with the RELOAD command is 0, the timer
> > needs to be enabled as one-shot timer.
> >
> > Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> > ---
> > hw/timer/cmsdk-apb-timer.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/hw/timer/cmsdk-apb-timer.c b/hw/timer/cmsdk-apb-timer.c
> > index 9878746..79c1b49 100644
> > --- a/hw/timer/cmsdk-apb-timer.c
> > +++ b/hw/timer/cmsdk-apb-timer.c
> > @@ -119,7 +119,7 @@ static void cmsdk_apb_timer_write(void *opaque, hwaddr offset, uint64_t value,
> > }
> > s->ctrl = value & 0xf;
> > if (s->ctrl & R_CTRL_EN_MASK) {
> > - ptimer_run(s->timer, 0);
> > + ptimer_run(s->timer, ptimer_get_limit(s->timer) == 0);
> > } else {
> > ptimer_stop(s->timer);
> > }
> > --
> > 2.7.4
>
> Thanks for this patch. I was wondering whether it would be better
> just to remove the fprintf message instead. I'll either apply
> this or send a patch to do that before 3.0, anyway.
>
If I recall correctly, I tried that, and it did not help.
The messages don't happen too often, and the message itself
does not cause a problem. Issue is that the interrupts happen
at the wrong time or not at all (after a while, ie after the
configured one-shot time expires), and the kernel really doesn't
like that.
I think the underlying problem was that the periodic timer counts
the period down (based on the time set for the one-shot timer),
stops with the "Timer with delta zero, disabling" message once
the period reaches 0, and does not fire anymore afterwards.
As a result, the kernel fails to boot maybe 90% of the time.
I should probably have mentioned that in more detail in the
commit log.
> I think we also want to make sure we convert back to a
> periodic timer if the reload register is written with a nonzero
> value before the timer expires (and that if that happens after
> the timer expired that we restart the timer). Thinking about
> this is also on my todo list.
>
I thought that was handled in the Linux driver by disabling
the timer, updating the period, and then re-enabling it in
periodic mode, but I may have misinterpreted the code.
Guenter
next prev parent reply other threads:[~2018-06-26 17:59 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-19 2:08 [Qemu-devel] [PATCH] hw/char/cmsdk-apb-timer: Correctly identify and set one-shot mode Guenter Roeck
2018-06-26 17:17 ` [Qemu-arm] " Peter Maydell
2018-06-26 17:17 ` [Qemu-devel] " Peter Maydell
2018-06-26 17:59 ` Guenter Roeck [this message]
2018-06-26 17:59 ` Guenter Roeck
2018-06-26 18:10 ` [Qemu-arm] " Peter Maydell
2018-06-26 18:10 ` [Qemu-devel] " Peter Maydell
2018-06-26 18:43 ` [Qemu-arm] " Guenter Roeck
2018-06-26 18:43 ` [Qemu-devel] " Guenter Roeck
2018-06-26 20:00 ` [Qemu-arm] " Guenter Roeck
2018-06-26 20:00 ` [Qemu-devel] " Guenter Roeck
2018-07-02 15:05 ` Peter Maydell
2018-07-02 15:29 ` [Qemu-arm] " Peter Maydell
2018-07-02 15:29 ` [Qemu-devel] " Peter Maydell
2018-07-02 16:27 ` [Qemu-arm] " Guenter Roeck
2018-07-02 16:27 ` [Qemu-devel] " Guenter Roeck
2018-07-02 16:46 ` [Qemu-arm] " Peter Maydell
2018-07-02 16:46 ` [Qemu-devel] " Peter Maydell
2018-07-02 17:05 ` [Qemu-arm] " Guenter Roeck
2018-07-02 17:05 ` [Qemu-devel] " Guenter Roeck
2018-07-02 17:10 ` [Qemu-arm] " Peter Maydell
2018-07-02 17:10 ` [Qemu-devel] " Peter Maydell
2018-07-02 17:57 ` Guenter Roeck
2018-07-02 18:06 ` [Qemu-arm] " Peter Maydell
2018-07-02 18:06 ` [Qemu-devel] " Peter Maydell
2018-07-02 18:37 ` [Qemu-arm] " Guenter Roeck
2018-07-02 18:37 ` [Qemu-devel] " Guenter Roeck
2018-07-03 17:06 ` Peter Maydell
2018-07-03 18:49 ` [Qemu-arm] " Guenter Roeck
2018-07-03 18:49 ` [Qemu-devel] " Guenter Roeck
2018-07-03 20:08 ` [Qemu-arm] " Peter Maydell
2018-07-03 20:08 ` [Qemu-devel] " 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=20180626175900.GA4307@roeck-us.net \
--to=linux@roeck-us.net \
--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.