public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
From: Tony Lindgren <tony@atomide.com>
To: linux-arm-kernel@lists.arm.linux.org.uk
Cc: linux-omap@vger.kernel.org, Richard Woodruff <r-woodruff2@ti.com>,
	Tony Lindgren <tony@atomide.com>
Subject: [PATCH 02/21] ARM: OMAP: DMTimer: Optimize by adding load and start
Date: Fri,  6 Jun 2008 18:30:34 -0700	[thread overview]
Message-ID: <1212802253-17797-3-git-send-email-tony@atomide.com> (raw)
In-Reply-To: <1212802253-17797-2-git-send-email-tony@atomide.com>

From: Richard Woodruff <r-woodruff2@ti.com>

This patch optimizes the timer load and start sequence.  By combining the
load and start a needless posted wait can be removed from the system timer
execution path.

* Before patch register writes are taking up .078% @ 500MHz during idle.

 Address                 |total  |min  |max      |avr     |count|ratio%
 old\process\default_idle|7.369s |0.0us|999.902ms|14.477ms|509. |62.661%
 ld\Global\cpu_v7_do_idle|4.265s |0.0us|375.786ms|24.374ms|175. |36.270%
                (UNKNOWN)|17.503ms|0.us|531.080us|5.119us|3419. |0.148%
 r\omap_dm_timer_set_load|8.135ms|0.0us|79.887us|15.065us|540.  |0.069% <--
 \vmlinux-old\Global\_end|2.023ms|0.0us|4.000us|0.560us|3613.   |0.017%
 -old\Global\__raw_readsw|1.962ms|0.0us|108.610us|9.167us|214.  |0.016%
 old\smc91x\smc_interrupt|1.353ms|0.0us|10.212us|2.348us|576.   |0.011%
 s/namei\__link_path_walk|1.161ms|0.0us|4.310us|0.762us|  1524. |0.009%
 \omap_dm_timer_write_reg|1.085ms|0.0us|126.150us|2.153us|504.  |0.009% <--

* After patch timer functions do not show up in top listings for long captures.

Signed-off-by: Richard Woodruff <r-woodruff2@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>

diff --git a/arch/arm/mach-omap2/timer-gp.c b/arch/arm/mach-omap2/timer-gp.c
index 78d05f2..557603f 100644
--- a/arch/arm/mach-omap2/timer-gp.c
+++ b/arch/arm/mach-omap2/timer-gp.c
@@ -59,8 +59,7 @@ static struct irqaction omap2_gp_timer_irq = {
 static int omap2_gp_timer_set_next_event(unsigned long cycles,
 					 struct clock_event_device *evt)
 {
-	omap_dm_timer_set_load(gptimer, 0, 0xffffffff - cycles);
-	omap_dm_timer_start(gptimer);
+	omap_dm_timer_set_load_start(gptimer, 0, 0xffffffff - cycles);
 
 	return 0;
 }
@@ -77,8 +76,7 @@ static void omap2_gp_timer_set_mode(enum clock_event_mode mode,
 		period = clk_get_rate(omap_dm_timer_get_fclk(gptimer)) / HZ;
 		period -= 1;
 
-		omap_dm_timer_set_load(gptimer, 1, 0xffffffff - period);
-		omap_dm_timer_start(gptimer);
+		omap_dm_timer_set_load_start(gptimer, 1, 0xffffffff - period);
 		break;
 	case CLOCK_EVT_MODE_ONESHOT:
 		break;
@@ -172,8 +170,7 @@ static void __init omap2_gp_clocksource_init(void)
 	tick_rate = clk_get_rate(omap_dm_timer_get_fclk(gpt));
 	tick_period = (tick_rate / HZ) - 1;
 
-	omap_dm_timer_set_load(gpt, 1, 0);
-	omap_dm_timer_start(gpt);
+	omap_dm_timer_set_load_start(gpt, 1, 0);
 
 	clocksource_gpt.mult =
 		clocksource_khz2mult(tick_rate/1000, clocksource_gpt.shift);
diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c
index 822b6bb..f22506a 100644
--- a/arch/arm/plat-omap/dmtimer.c
+++ b/arch/arm/plat-omap/dmtimer.c
@@ -546,6 +546,24 @@ void omap_dm_timer_set_load(struct omap_dm_timer *timer, int autoreload,
 	omap_dm_timer_write_reg(timer, OMAP_TIMER_TRIGGER_REG, 0);
 }
 
+/* Optimized set_load which removes costly spin wait in timer_start */
+void omap_dm_timer_set_load_start(struct omap_dm_timer *timer, int autoreload,
+                            unsigned int load)
+{
+	u32 l;
+
+	l = omap_dm_timer_read_reg(timer, OMAP_TIMER_CTRL_REG);
+	if (autoreload)
+		l |= OMAP_TIMER_CTRL_AR;
+	else
+		l &= ~OMAP_TIMER_CTRL_AR;
+	l |= OMAP_TIMER_CTRL_ST;
+
+	omap_dm_timer_write_reg(timer, OMAP_TIMER_COUNTER_REG, load);
+	omap_dm_timer_write_reg(timer, OMAP_TIMER_LOAD_REG, load);
+	omap_dm_timer_write_reg(timer, OMAP_TIMER_CTRL_REG, l);
+}
+
 void omap_dm_timer_set_match(struct omap_dm_timer *timer, int enable,
 			     unsigned int match)
 {
@@ -560,7 +578,6 @@ void omap_dm_timer_set_match(struct omap_dm_timer *timer, int enable,
 	omap_dm_timer_write_reg(timer, OMAP_TIMER_MATCH_REG, match);
 }
 
-
 void omap_dm_timer_set_pwm(struct omap_dm_timer *timer, int def_on,
 			   int toggle, int trigger)
 {
diff --git a/include/asm-arm/arch-omap/dmtimer.h b/include/asm-arm/arch-omap/dmtimer.h
index fefb276..02b29e8 100644
--- a/include/asm-arm/arch-omap/dmtimer.h
+++ b/include/asm-arm/arch-omap/dmtimer.h
@@ -66,6 +66,7 @@ void omap_dm_timer_stop(struct omap_dm_timer *timer);
 
 void omap_dm_timer_set_source(struct omap_dm_timer *timer, int source);
 void omap_dm_timer_set_load(struct omap_dm_timer *timer, int autoreload, unsigned int value);
+void omap_dm_timer_set_load_start(struct omap_dm_timer *timer, int autoreload, unsigned int value);
 void omap_dm_timer_set_match(struct omap_dm_timer *timer, int enable, unsigned int match);
 void omap_dm_timer_set_pwm(struct omap_dm_timer *timer, int def_on, int toggle, int trigger);
 void omap_dm_timer_set_prescaler(struct omap_dm_timer *timer, int prescaler);

  reply	other threads:[~2008-06-07  1:30 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <omap-upstream-20080607182613-0-21>
2008-06-07  1:30 ` [PATCH 00/21] Omap upstream patches for post 2.6.26 Tony Lindgren
2008-06-07  1:30   ` [PATCH 01/21] ARM: OMAP: DMTimer: Use posted mode Tony Lindgren
2008-06-07  1:30     ` Tony Lindgren [this message]
2008-06-07  1:30       ` [PATCH 03/21] ARM: OMAP: Add OMAP3430 base defines Tony Lindgren
2008-06-07  1:30         ` [PATCH 04/21] ARM: OMAP: DMA: Make channels dynamic for multi-boot Tony Lindgren
2008-06-07  1:30           ` [PATCH 05/21] ARM: OMAP: DMA: Remove __REG access Tony Lindgren
2008-06-07  1:30             ` [PATCH 06/21] ARM: OMAP: DMA: Clean-up code Tony Lindgren
2008-06-07  1:30               ` [PATCH 07/21] ARM: OMAP: SRAM: Move sram-fn.S from plat-omap to mach-omap1 Tony Lindgren
2008-06-07  1:30                 ` [PATCH 08/21] ARM: OMAP: SRAM: Move omap2 sram-fn.S to sram242x.S Tony Lindgren
2008-06-07  1:30                   ` [PATCH 09/21] ARM: OMAP: SRAM: Split sram24xx.S into sram242x.S and sram243x.S Tony Lindgren
2008-06-07  1:30                     ` [PATCH 10/21] ARM: OMAP: McBSP: Coding style cleanup on arch/arm/plat-omap/mcbsp.c Tony Lindgren
2008-06-07  1:30                       ` [PATCH 11/21] ARM: OMAP: McBSP: Prepare for splitting into omap1 and omap2 code Tony Lindgren
2008-06-07  1:30                         ` [PATCH 12/21] ARM: OMAP: McBSP: Add support for mcbsp on mach-omap1 Tony Lindgren
2008-06-07  1:30                           ` [PATCH 13/21] ARM: OMAP: McBSP: Add support for mcbsp on mach-omap2 Tony Lindgren
2008-06-07  1:30                             ` [PATCH 14/21] ARM: OMAP: Clean up interrupt lines to fix warnings for multi-omap Tony Lindgren
2008-06-07  1:30                               ` [PATCH 15/21] ARM: OMAP: CLKFW: Initial debugfs support for omap clock framework Tony Lindgren
2008-06-07  1:30                                 ` [PATCH 16/21] ARM: OMAP: Change omap_cf.c and omap_nor.c to use omap_readw/writew instead of __REG Tony Lindgren
     [not found]                                   ` <1212802253-17797-17-git-send-email-tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2008-06-07  1:30                                     ` [PATCH 17/21] ARM: OMAP: USB: Change omap USB code to use omap_read/write " Tony Lindgren
2008-06-07  1:30                                       ` [PATCH 18/21] ARM: OMAP: Remove __REG access for multi-omap Tony Lindgren
2008-06-07  1:30                                         ` [PATCH 19/21] ARM: OMAP: Introduce omap_globals and prcm access functions " Tony Lindgren
2008-06-07  1:30                                           ` [PATCH 20/21] ARM: OMAP: Turn CM and PRM access into functions Tony Lindgren
2008-06-07  1:30                                             ` [PATCH 21/21] ARM: OMAP: Add OMAP chip type structure; clean up mach-omap2/id.c Tony Lindgren
2008-06-14  9:22                                               ` Russell King - ARM Linux
2008-06-17 15:43                                                 ` Paul Walmsley
2008-06-14  9:17                                             ` [PATCH 20/21] ARM: OMAP: Turn CM and PRM access into functions Russell King - ARM Linux
2008-06-14  9:09                                           ` [PATCH 19/21] ARM: OMAP: Introduce omap_globals and prcm access functions for multi-omap Russell King - ARM Linux
2008-06-17  7:46                                             ` Tony Lindgren
2008-06-22 14:08                                               ` Russell King - ARM Linux
2008-06-14  9:06                                         ` [PATCH 18/21] ARM: OMAP: Remove __REG access " Russell King - ARM Linux
2008-06-14  8:17                         ` [PATCH 11/21] ARM: OMAP: McBSP: Prepare for splitting into omap1 and omap2 code Russell King - ARM Linux
2008-06-17  8:41                           ` Tony Lindgren
2008-06-23  9:39                             ` Tony Lindgren
2008-06-23 10:34                               ` [PATCH 11/21] ARM: OMAP: McBSP: Prepare for splitting intoomap1 " shekhar, chandra
2008-06-14  8:19                       ` [PATCH 10/21] ARM: OMAP: McBSP: Coding style cleanup on arch/arm/plat-omap/mcbsp.c Russell King - ARM Linux
2008-06-23  9:02                         ` Tony Lindgren
2008-06-14  8:05                   ` [PATCH 08/21] ARM: OMAP: SRAM: Move omap2 sram-fn.S to sram242x.S Russell King - ARM Linux
2008-06-17  7:36                     ` Tony Lindgren
2008-06-22 14:06                       ` Russell King - ARM Linux
2008-06-17  7:34                 ` [PATCH 07/21] ARM: OMAP: SRAM: Move sram-fn.S from plat-omap to mach-omap1 Tony Lindgren
2008-06-22 14:06                   ` Russell King - ARM Linux
2008-06-14  8:13               ` [PATCH 06/21] ARM: OMAP: DMA: Clean-up code Russell King - ARM Linux
2008-06-17  7:27                 ` Tony Lindgren
2008-06-22 14:06                   ` Russell King - ARM Linux
2008-06-14  8:04             ` [PATCH 05/21] ARM: OMAP: DMA: Remove __REG access Russell King - ARM Linux
2008-06-17  7:22               ` Tony Lindgren
2008-06-22 14:05                 ` Russell King - ARM Linux
2008-06-14  8:03           ` [PATCH 04/21] ARM: OMAP: DMA: Make channels dynamic for multi-boot Russell King - ARM Linux
2008-06-14  8:01         ` [PATCH 03/21] ARM: OMAP: Add OMAP3430 base defines Russell King - ARM Linux
2008-06-17  7:19           ` Tony Lindgren
2008-06-14  8:20       ` [PATCH 02/21] ARM: OMAP: DMTimer: Optimize by adding load and start Russell King - ARM Linux

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=1212802253-17797-3-git-send-email-tony@atomide.com \
    --to=tony@atomide.com \
    --cc=linux-arm-kernel@lists.arm.linux.org.uk \
    --cc=linux-omap@vger.kernel.org \
    --cc=r-woodruff2@ti.com \
    /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