From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 1/4] ARM: imx: allow timer counter to roll over
Date: Tue, 4 Dec 2012 15:44:59 +0000 [thread overview]
Message-ID: <20121204154459.GG14363@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <1354632915-27134-2-git-send-email-shawn.guo@linaro.org>
On Tue, Dec 04, 2012 at 10:55:12PM +0800, Shawn Guo wrote:
> The timer is configured in free-run mode. The counter should be
> allowed to roll over to 0 when reaching 0xffffffff. Let's do that
> by always returning 0 in set_next_event.
Are you sure this is correct? It looks wrong to me.
If the time set by the next event has passed, you must return -ETIME
from set_next_event() so that the generic timer code can compensate
for the missed event and recalculate it, otherwise you will end up
having to wait a full count cycle before receiving the next event.
If you find that you're being passed such a small increment that you're
constantly hitting that condition, you need to increase your minimum
waited interval.
> diff --git a/arch/arm/mach-imx/time.c b/arch/arm/mach-imx/time.c
> index f017302..858098c 100644
> --- a/arch/arm/mach-imx/time.c
> +++ b/arch/arm/mach-imx/time.c
> @@ -139,8 +139,7 @@ static int mx1_2_set_next_event(unsigned long evt,
>
> __raw_writel(tcmp, timer_base + MX1_2_TCMP);
>
> - return (int)(tcmp - __raw_readl(timer_base + MX1_2_TCN)) < 0 ?
> - -ETIME : 0;
> + return 0;
So what this code was doing is: tcmp is the counter value we expect with
the expected event time added. This may wrap 32-bits. We subtract the
current timer value after we've set the compare register. If the current
timer value was larger than the expected event time, we return -ETIME.
That to me sounds 100% correct. Your replacement code of always returning
zero looks wrong.
next prev parent reply other threads:[~2012-12-04 15:44 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-04 14:55 [PATCH v2 0/4] Support imx6q WAIT mode Shawn Guo
2012-12-04 14:55 ` [PATCH v2 1/4] ARM: imx: allow timer counter to roll over Shawn Guo
2012-12-04 15:44 ` Russell King - ARM Linux [this message]
2012-12-05 12:14 ` Shawn Guo
2012-12-05 12:09 ` Russell King - ARM Linux
2012-12-06 9:34 ` Shawn Guo
2012-12-06 14:54 ` [PATCH v3 1/4] ARM: imx: return zero in case next event gets a large increment Shawn Guo
2012-12-04 14:55 ` [PATCH v2 2/4] ARM: imx: mask gpc interrupts initially Shawn Guo
2012-12-04 14:55 ` [PATCH v2 3/4] ARM: imx: move imx6q_cpuidle_driver into a separate file Shawn Guo
2012-12-04 14:55 ` [PATCH v2 4/4] ARM: imx6q: support WAIT mode using cpuidle Shawn Guo
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=20121204154459.GG14363@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=linux-arm-kernel@lists.infradead.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).