* [PATCH] ARM: OMAP: timer32k: fix tick count calculation when reprogramming
@ 2006-07-03 15:51 imre.deak
2006-07-05 8:51 ` tony
0 siblings, 1 reply; 3+ messages in thread
From: imre.deak @ 2006-07-03 15:51 UTC (permalink / raw)
To: tony; +Cc: linux-omap-open-source
Reprogramming takes places before putting the CPU into idle mode if
the dynamic tick option is enabled. The timer is then set to expire
at the next pending timer event. Because some time has already passed
since the last reported jiffy we have to wait less than the time
specified in jiffies.
Also make sure we don't set a load value of 0 whose outcome is
unspecified according to the TRM.
Signed-off-by: Imre Deak <imre.deak@solidboot.com>
--
diff --git a/arch/arm/plat-omap/timer32k.c b/arch/arm/plat-omap/timer32k.c
index 6ef5468..946b937 100644
--- a/arch/arm/plat-omap/timer32k.c
+++ b/arch/arm/plat-omap/timer32k.c
@@ -132,6 +132,8 @@ static inline unsigned long omap_32k_syn
static inline void omap_32k_timer_start(unsigned long load_val)
{
if (cpu_class_is_omap1()) {
+ if (!load_val)
+ load_val = 1;
omap_32k_timer_write(load_val, OMAP1_32K_TIMER_TVR);
omap_32k_timer_write(0x0f, OMAP1_32K_TIMER_CR);
}
@@ -236,7 +238,15 @@ static irqreturn_t omap_32k_timer_interr
*/
void omap_32k_timer_reprogram(unsigned long next_tick)
{
- omap_32k_timer_start(JIFFIES_TO_HW_TICKS(next_tick, 32768) + 1);
+ unsigned long ticks = JIFFIES_TO_HW_TICKS(next_tick, 32768) + 1;
+ unsigned long now = omap_32k_sync_timer_read();
+ unsigned long idled = now - omap_32k_last_tick;
+
+ if (idled + 1 < ticks)
+ ticks -= idled;
+ else
+ ticks = 1;
+ omap_32k_timer_start(ticks);
}
static struct irqaction omap_32k_timer_irq;
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ARM: OMAP: timer32k: fix tick count calculation when reprogramming
2006-07-03 15:51 [PATCH] ARM: OMAP: timer32k: fix tick count calculation when reprogramming imre.deak
@ 2006-07-05 8:51 ` tony
2006-07-05 15:58 ` imre.deak
0 siblings, 1 reply; 3+ messages in thread
From: tony @ 2006-07-05 8:51 UTC (permalink / raw)
To: imre.deak; +Cc: linux-omap-open-source
* imre.deak@solidboot.com <imre.deak@solidboot.com> [060703 08:51]:
> Reprogramming takes places before putting the CPU into idle mode if
> the dynamic tick option is enabled. The timer is then set to expire
> at the next pending timer event. Because some time has already passed
> since the last reported jiffy we have to wait less than the time
> specified in jiffies.
Looks good to me. This patch seems to need an update though.
Did you do this to fix some specific problem, or just to improve timer
accuracy?
> Also make sure we don't set a load value of 0 whose outcome is
> unspecified according to the TRM.
OK
Tony
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ARM: OMAP: timer32k: fix tick count calculation when reprogramming
2006-07-05 8:51 ` tony
@ 2006-07-05 15:58 ` imre.deak
0 siblings, 0 replies; 3+ messages in thread
From: imre.deak @ 2006-07-05 15:58 UTC (permalink / raw)
To: tony; +Cc: linux-omap-open-source
On Wed, Jul 05, 2006 at 01:51:04AM -0700, tony@atomide.com wrote:
> * imre.deak@solidboot.com <imre.deak@solidboot.com> [060703 08:51]:
> > Reprogramming takes places before putting the CPU into idle mode if
> > the dynamic tick option is enabled. The timer is then set to expire
> > at the next pending timer event. Because some time has already passed
> > since the last reported jiffy we have to wait less than the time
> > specified in jiffies.
>
> Looks good to me. This patch seems to need an update though.
Sorry, the patch was against an older commit.. The updated one:
diff --git a/arch/arm/plat-omap/timer32k.c b/arch/arm/plat-omap/timer32k.c
index b0119f1..eba5946 100644
--- a/arch/arm/plat-omap/timer32k.c
+++ b/arch/arm/plat-omap/timer32k.c
@@ -106,6 +106,8 @@ static inline unsigned long omap_32k_tim
static inline void omap_32k_timer_start(unsigned long load_val)
{
+ if (!load_val)
+ load_val = 1;
omap_32k_timer_write(load_val, OMAP1_32K_TIMER_TVR);
omap_32k_timer_write(0x0f, OMAP1_32K_TIMER_CR);
}
@@ -230,7 +232,15 @@ static irqreturn_t omap_32k_timer_interr
*/
void omap_32k_timer_reprogram(unsigned long next_tick)
{
- omap_32k_timer_start(JIFFIES_TO_HW_TICKS(next_tick, 32768) + 1);
+ unsigned long ticks = JIFFIES_TO_HW_TICKS(next_tick, 32768) + 1;
+ unsigned long now = omap_32k_sync_timer_read();
+ unsigned long idled = now - omap_32k_last_tick;
+
+ if (idled + 1 < ticks)
+ ticks -= idled;
+ else
+ ticks = 1;
+ omap_32k_timer_start(ticks);
}
static struct irqaction omap_32k_timer_irq;
>
> Did you do this to fix some specific problem, or just to improve timer
> accuracy?
It's about timer accuracy. Currently we are using the system timer
through the hrtimer API and need a 1 jiffy resolution.
--Imre
>
> > Also make sure we don't set a load value of 0 whose outcome is
> > unspecified according to the TRM.
>
> OK
>
> Tony
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-07-05 15:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-03 15:51 [PATCH] ARM: OMAP: timer32k: fix tick count calculation when reprogramming imre.deak
2006-07-05 8:51 ` tony
2006-07-05 15:58 ` imre.deak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox