summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorShenwei Wang <shenwei.wang@nxp.com>2017-04-24 13:24:32 -0500
committerAnson Huang <Anson.Huang@nxp.com>2017-06-09 22:22:52 +0800
commit8a9187985f1afd18ddc002beaf45f2a17e616e5e (patch)
tree9d0f74da2fb3932466ecff577f68bd6938a39553 /drivers
parent90ab3c365afd8c612360077f1d5b332b93ba0e25 (diff)
MLK-14748 clocksource: imx-tpm: Increase the min_delta
The current min_delta for TPM clock event is 2 ticks which is too small. As the TPM is running at 3MHz, 2 ticks equal 2/3 us. According to our testing, the interrupt latency will be longer than this min_delta, especially when GPU is running. This patch changed the min_delta to 300 which give the system around 100us for interrupt handling in case the "set_next_event" call is interrupted by other signals. Also a simple validation code is added before the function returns. Signed-off-by: Shenwei Wang <shenwei.wang@nxp.com> Signed-off-by: Bai Ping <ping.bai@nxp.com> (cherry picked from commit 4f882165cc31672f3c98de74ab02b757cb96ad26)
Diffstat (limited to 'drivers')
-rw-r--r--drivers/clocksource/timer-imx-tpm.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/clocksource/timer-imx-tpm.c b/drivers/clocksource/timer-imx-tpm.c
index 608dca163ee9..f7d0d68f35b1 100644
--- a/drivers/clocksource/timer-imx-tpm.c
+++ b/drivers/clocksource/timer-imx-tpm.c
@@ -1,5 +1,6 @@
/*
* Copyright 2016 Freescale Semiconductor, Inc.
+ * Copyright 2017 NXP
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -81,12 +82,15 @@ static int __init tpm_clocksource_init(unsigned long rate)
static int tpm_set_next_event(unsigned long delta,
struct clock_event_device *evt)
{
- unsigned long tmp;
+ unsigned long next, now, ret;
- tmp = __raw_readl(timer_base + TPM_CNT) + delta;
- __raw_writel(tmp, timer_base + TPM_C0V);
+ now = __raw_readl(timer_base + TPM_CNT);
+ next = now + delta;
+ __raw_writel(next, timer_base + TPM_C0V);
+ now = __raw_readl(timer_base + TPM_CNT);
- return 0;
+ ret = next - now;
+ return (ret > delta) ? -ETIME : 0;
}
static int tpm_set_state_oneshot(struct clock_event_device *evt)
@@ -140,7 +144,7 @@ static int __init tpm_clockevent_init(unsigned long rate, int irq)
clockevent_tpm.cpumask = cpumask_of(0);
clockevent_tpm.irq = irq;
clockevents_config_and_register(&clockevent_tpm,
- rate, 2, 0xfffffffe);
+ rate, 300, 0xfffffffe);
return 0;
}