Skip to content

Commit 5df9150

Browse files
jacob.jun.pan@linux.intel.comKAGA-KOKO
authored andcommitted
x86: mrst: Remove apb timer read workaround
APB timer current count was unreliable in the earlier silicon, which could result in time going backwards. This problem has been fixed in the current silicon stepping. This patch removes the workaround which was used to check and prevent timer rolling back when APB timer is used as clocksource device. The workaround code was also flawed by potential race condition around the cached read value last_read. Though a fix can be done by assigning last_read to a local variable at the beginning of apbt_read_clocksource(), but this is not necessary anymore. [ tglx: A sane timer on an Intel chip - I can't believe it ] Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com> Cc: Arjan van de Ven <arjan@linux.intel.com> Cc: Alan Cox <alan@linux.intel.com> LKML-Reference: <1298065374-25532-1-git-send-email-jacob.jun.pan@linux.intel.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
1 parent 13884c6 commit 5df9150

1 file changed

Lines changed: 4 additions & 56 deletions

File tree

‎arch/x86/kernel/apb_timer.c‎

Lines changed: 4 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -506,64 +506,12 @@ static int apbt_next_event(unsigned long delta,
506506
return 0;
507507
}
508508

509-
/*
510-
* APB timer clock is not in sync with pclk on Langwell, which translates to
511-
* unreliable read value caused by sampling error. the error does not add up
512-
* overtime and only happens when sampling a 0 as a 1 by mistake. so the time
513-
* would go backwards. the following code is trying to prevent time traveling
514-
* backwards. little bit paranoid.
515-
*/
516509
static cycle_t apbt_read_clocksource(struct clocksource *cs)
517510
{
518-
unsigned long t0, t1, t2;
519-
static unsigned long last_read;
520-
521-
bad_count:
522-
t1 = apbt_readl(phy_cs_timer_id,
523-
APBTMR_N_CURRENT_VALUE);
524-
t2 = apbt_readl(phy_cs_timer_id,
525-
APBTMR_N_CURRENT_VALUE);
526-
if (unlikely(t1 < t2)) {
527-
pr_debug("APBT: read current count error %lx:%lx:%lx\n",
528-
t1, t2, t2 - t1);
529-
goto bad_count;
530-
}
531-
/*
532-
* check against cached last read, makes sure time does not go back.
533-
* it could be a normal rollover but we will do tripple check anyway
534-
*/
535-
if (unlikely(t2 > last_read)) {
536-
/* check if we have a normal rollover */
537-
unsigned long raw_intr_status =
538-
apbt_readl_reg(APBTMRS_RAW_INT_STATUS);
539-
/*
540-
* cs timer interrupt is masked but raw intr bit is set if
541-
* rollover occurs. then we read EOI reg to clear it.
542-
*/
543-
if (raw_intr_status & (1 << phy_cs_timer_id)) {
544-
apbt_readl(phy_cs_timer_id, APBTMR_N_EOI);
545-
goto out;
546-
}
547-
pr_debug("APB CS going back %lx:%lx:%lx ",
548-
t2, last_read, t2 - last_read);
549-
bad_count_x3:
550-
pr_debug("triple check enforced\n");
551-
t0 = apbt_readl(phy_cs_timer_id,
552-
APBTMR_N_CURRENT_VALUE);
553-
udelay(1);
554-
t1 = apbt_readl(phy_cs_timer_id,
555-
APBTMR_N_CURRENT_VALUE);
556-
udelay(1);
557-
t2 = apbt_readl(phy_cs_timer_id,
558-
APBTMR_N_CURRENT_VALUE);
559-
if ((t2 > t1) || (t1 > t0)) {
560-
printk(KERN_ERR "Error: APB CS tripple check failed\n");
561-
goto bad_count_x3;
562-
}
563-
}
564-
out:
565-
last_read = t2;
566-
return (cycle_t)~t2;
511+
unsigned long current_count;
512+
513+
current_count = apbt_readl(phy_cs_timer_id, APBTMR_N_CURRENT_VALUE);
514+
return (cycle_t)~current_count;
567515
}
568516

569517
static int apbt_clocksource_register(void)

0 commit comments

Comments
 (0)