linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: tony@atomide.com (Tony Lindgren)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 01/28] omap: fix clocksource_32k to start from zero
Date: Fri, 23 Apr 2010 16:11:00 -0700	[thread overview]
Message-ID: <20100423231100.31953.40329.stgit@baageli.muru.com> (raw)
In-Reply-To: <20100423230829.31953.17334.stgit@baageli.muru.com>

From: Aaro Koskinen <aaro.koskinen@nokia.com>

When the 32k sync timer is used for sched_clock(), it should count
time from the kernel boot (clocksource init) instead of the last HW
reset. Otherwise printk.time values will jump suddenly during the boot:

	[    0.000000] calling  omap2_clk_arch_init+0x0/0x138 @ 1
	[    0.000000] initcall omap2_clk_arch_init+0x0/0x138 returned -22 after 0 usecs
	[    0.000000] initcall omap2_clk_arch_init+0x0/0x138 returned with error code -22
	[    0.000000] calling  omap_init_clocksource_32k+0x0/0x98 @ 1
	[  508.697937] initcall omap_init_clocksource_32k+0x0/0x98 returned 0 after 0 usecs
	[  508.697967] calling  omap_init_devices+0x0/0x38 @ 1
	[  508.698425] initcall omap_init_devices+0x0/0x38 returned 0 after 0 usecs

This will confuse tools such as scripts/bootgraph.pl.

Signed-off-by: Aaro Koskinen <aaro.koskinen@nokia.com>
Acked-by: Kevin Hilman <khilman@deeprootsystems.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 arch/arm/plat-omap/common.c |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/arch/arm/plat-omap/common.c b/arch/arm/plat-omap/common.c
index 088c1a0..01cbb48 100644
--- a/arch/arm/plat-omap/common.c
+++ b/arch/arm/plat-omap/common.c
@@ -100,10 +100,17 @@ EXPORT_SYMBOL(omap_get_var_config);
 
 #include <linux/clocksource.h>
 
+/*
+ * offset_32k holds the init time counter value. It is then subtracted
+ * from every counter read to achieve a counter that counts time from the
+ * kernel boot (needed for sched_clock()).
+ */
+static u32 offset_32k __read_mostly;
+
 #ifdef CONFIG_ARCH_OMAP16XX
 static cycle_t omap16xx_32k_read(struct clocksource *cs)
 {
-	return omap_readl(OMAP16XX_TIMER_32K_SYNCHRONIZED);
+	return omap_readl(OMAP16XX_TIMER_32K_SYNCHRONIZED) - offset_32k;
 }
 #else
 #define omap16xx_32k_read	NULL
@@ -112,7 +119,7 @@ static cycle_t omap16xx_32k_read(struct clocksource *cs)
 #ifdef CONFIG_ARCH_OMAP2420
 static cycle_t omap2420_32k_read(struct clocksource *cs)
 {
-	return omap_readl(OMAP2420_32KSYNCT_BASE + 0x10);
+	return omap_readl(OMAP2420_32KSYNCT_BASE + 0x10) - offset_32k;
 }
 #else
 #define omap2420_32k_read	NULL
@@ -121,7 +128,7 @@ static cycle_t omap2420_32k_read(struct clocksource *cs)
 #ifdef CONFIG_ARCH_OMAP2430
 static cycle_t omap2430_32k_read(struct clocksource *cs)
 {
-	return omap_readl(OMAP2430_32KSYNCT_BASE + 0x10);
+	return omap_readl(OMAP2430_32KSYNCT_BASE + 0x10) - offset_32k;
 }
 #else
 #define omap2430_32k_read	NULL
@@ -130,7 +137,7 @@ static cycle_t omap2430_32k_read(struct clocksource *cs)
 #ifdef CONFIG_ARCH_OMAP3
 static cycle_t omap34xx_32k_read(struct clocksource *cs)
 {
-	return omap_readl(OMAP3430_32KSYNCT_BASE + 0x10);
+	return omap_readl(OMAP3430_32KSYNCT_BASE + 0x10) - offset_32k;
 }
 #else
 #define omap34xx_32k_read	NULL
@@ -139,7 +146,7 @@ static cycle_t omap34xx_32k_read(struct clocksource *cs)
 #ifdef CONFIG_ARCH_OMAP4
 static cycle_t omap44xx_32k_read(struct clocksource *cs)
 {
-	return omap_readl(OMAP4430_32KSYNCT_BASE + 0x10);
+	return omap_readl(OMAP4430_32KSYNCT_BASE + 0x10) - offset_32k;
 }
 #else
 #define omap44xx_32k_read	NULL
@@ -227,6 +234,8 @@ static int __init omap_init_clocksource_32k(void)
 		clocksource_32k.mult = clocksource_hz2mult(32768,
 					    clocksource_32k.shift);
 
+		offset_32k = clocksource_32k.read(&clocksource_32k);
+
 		if (clocksource_register(&clocksource_32k))
 			printk(err, clocksource_32k.name);
 	}

  reply	other threads:[~2010-04-23 23:11 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-23 23:10 [PATCH 00/28] omap fixes for v2.6.34-rc5 Tony Lindgren
2010-04-23 23:11 ` Tony Lindgren [this message]
2010-04-23 23:11 ` [PATCH 02/28] arm: omap1: remove dead code from timer32k.c Tony Lindgren
2010-04-23 23:11 ` [PATCH 03/28] omap: gpio: fix incorrect matching of IRQ_TYPE_EDGE_BOTH Tony Lindgren
2010-04-23 23:11 ` [PATCH 04/28] omap: DMA: Init CDAC to zero Tony Lindgren
2010-04-23 23:11 ` [PATCH 05/28] omap4: Fix build break when used with gcc-4.4.1 (2009-q3) Tony Lindgren
2010-04-23 23:11 ` [PATCH 06/28] omap2: Fix ARM processor check for 24xx Tony Lindgren
2010-04-23 23:11 ` [PATCH 07/28] omap: Fix n8x0 mmc_mmc_init compile warnings and typos Tony Lindgren
2010-04-23 23:11 ` [PATCH 08/28] omap3: Fix EHCI port for IGEP v2 board Tony Lindgren
2010-04-23 23:11 ` [PATCH 09/28] OMAP4-HSMMC: FIX for MMC5 Controller IRQ Base Tony Lindgren
2010-04-23 23:11 ` [PATCH 10/28] OMAP4: Fix for CONTROL register Base Tony Lindgren
2010-04-23 23:11 ` [PATCH 11/28] omap: Devkit8000: Fix wrong usb port on Devkit8000 Tony Lindgren
2010-04-23 23:11 ` [PATCH 12/28] OMAP4: Clocks: Change SPI Instance Names Tony Lindgren
2010-04-23 23:11 ` [PATCH 13/28] omap: fix the compile error if CONFIG_MTD_NAND_OMAP2 is notenabled Tony Lindgren
2010-04-23 23:11 ` [PATCH 14/28] omap: remove one of the define of INT_34XX_BENCH_MPU_EMUL Tony Lindgren
2010-04-23 23:11 ` [PATCH 15/28] AM3517: initialize i2c subsystem after mux subsystem Tony Lindgren
2010-04-23 23:11 ` [PATCH 16/28] omap: fix a gpmc nand problem Tony Lindgren
2010-04-23 23:11 ` [PATCH 17/28] omap: rx51_defconfig: Remove duplicate phonet Tony Lindgren
2010-04-23 23:11 ` [PATCH 18/28] omap: rx51_defconfig: Remove CONFIG_SYSFS_DEPRECATED*=y options Tony Lindgren
2010-04-23 23:11 ` [PATCH 19/28] omap4: Fix McBSP4 base address Tony Lindgren
2010-04-23 23:11 ` [PATCH 20/28] omap: board-sdp-flash.c: Fix typos in debug output Tony Lindgren
2010-04-23 23:11 ` [PATCH 21/28] n8x0_defconfig: remove CONFIG_NILFS2_FS override Tony Lindgren
2010-04-23 23:11 ` [PATCH 22/28] omap: Devkit8000: Fix typo in supplies Tony Lindgren
2010-04-23 23:11 ` [PATCH 23/28] omap: Devkit8000: Add missing package selection Tony Lindgren
2010-04-23 23:12 ` [PATCH 24/28] omap: Devkit8000: Fix typo in pin name Tony Lindgren
2010-04-23 23:12 ` [PATCH 25/28] omap: Devkit8000: Remove unnecessary include file Tony Lindgren
2010-04-23 23:12 ` [PATCH 26/28] omap: Devkit8000: Change position of init calls Tony Lindgren
2010-04-23 23:12 ` [PATCH 27/28] omap: Devkit8000: Remove unused pins Tony Lindgren
2010-04-23 23:12 ` [PATCH 28/28] omap: delete unused bootloader tag variables Tony Lindgren

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=20100423231100.31953.40329.stgit@baageli.muru.com \
    --to=tony@atomide.com \
    --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).