Skip to contentSkip to conversation

OMAP2/3 GPTIMER: minor optimizations

PATCH In review Paul Walmsley 4 participants 9 messages Oct 14, 2008 – Nov 26, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover OMAP2/3 GPTIMER: minor optimizations

Hello,

these patches implement a few minor optimizations on the omap_dm_timer_set_load() and omap_dm_timer_set_load_start() functions for OMAP2/3. Gory details in the patch descriptions.

Tested on 2430SDP and 3430SDP.

- Paul

---

text data bss dec hex filename

3099539  135104  151144 3385787  33a9bb vmlinux.3430sdp.orig
3099539  135104  151144 3385787  33a9bb vmlinux.3430sdp
 arch/arm/plat-omap/dmtimer.c |   11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)
#1 lore raw

PATCH 1/2 OMAP2/3 GPTIMER: drop redundant pending write check

omap_dm_timer_write_reg() already waits for pending writes to complete, so the extra wait in omap_dm_timer_set_load() is superfluous.

Cc Richard Woodruff <[email protected]>
---
 arch/arm/plat-omap/dmtimer.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)
arch/arm/plat-omap/dmtimer.c +0 -4
index 167ec2f..59be3aa 100644
@@ -539,10 +539,6 @@ void omap_dm_timer_set_load(struct omap_dm_timer *timer, int autoreload,
 	omap_dm_timer_write_reg(timer, OMAP_TIMER_CTRL_REG, l);
 	omap_dm_timer_write_reg(timer, OMAP_TIMER_LOAD_REG, load);
 
-	/* REVISIT: hw feature, ttgr overtaking tldr? */
-	while (readl(timer->io_base + (OMAP_TIMER_WRITE_PEND_REG & 0xff)))
-		cpu_relax();
-
 	omap_dm_timer_write_reg(timer, OMAP_TIMER_TRIGGER_REG, 0);
 }
 
#2 lore raw

PATCH 2/2 OMAP2/3 GPTIMER: skip unnecessary TLDR write during non-autoreload

In reply to Paul Walmsley

The GPTIMER TLDR register does not need to be written if the GPTIMER is not in autoreload mode. This is the usual case for dynamic tick-enabled kernels.

Simulation data indicate that skipping the read that occurs as part of the write should save at least 300-320 ns for each GPTIMER1 timer reprogram. (This assumes L4-Wakeup is at 19MHz and GPTIMER write posting is enabled.) Skipping the write itself probably won't have much impact since it should be posted on the OCP interconnect.

Tested on 2430SDP and 3430SDP.

Cc Richard Woodruff <[email protected]>
---
 arch/arm/plat-omap/dmtimer.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
arch/arm/plat-omap/dmtimer.c +4 -3
index 59be3aa..08028f6 100644
@@ -549,14 +549,15 @@ void omap_dm_timer_set_load_start(struct omap_dm_timer *timer, int autoreload,
 	u32 l;
 
 	l = omap_dm_timer_read_reg(timer, OMAP_TIMER_CTRL_REG);
-	if (autoreload)
+	if (autoreload) {
 		l |= OMAP_TIMER_CTRL_AR;
-	else
+		omap_dm_timer_write_reg(timer, OMAP_TIMER_LOAD_REG, load);
+	} 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);
 }
 
#3 lore raw

RE: [PATCH 2/2] OMAP2/3 GPTIMER: skip unnecessary TLDR write during non-autoreload

Quoted 4 lines
      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);

}

I seem to recall there was a missed interrupt condition which this worked around.

IIRC, the original code didn't bother with the load I added back as a work around as a way to get posted mode working.

Regards,
Richard W.

#4 lore raw

Re: [PATCH 2/2] OMAP2/3 GPTIMER: skip unnecessary TLDR write during non-autoreload

Quoted 8 lines · Woodruff, Richard
Quoted 4 lines
      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);

}

I seem to recall there was a missed interrupt condition which this worked around.

IIRC, the original code didn't bother with the load I added back as a work around as a way to get posted mode working.

Well these seem to be working based on some quick timer tests. Pushing so we can verify it ;)

Tony

#5 lore raw

RE: [PATCH 2/2] OMAP2/3 GPTIMER: skip unnecessary TLDR write during non-autoreload

Quoted 6 lines · Woodruff, Richard
Quoted 5 lines
Quoted 4 lines
      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);

}

Quoted 8 lines
Quoted 1 line

I seem to recall there was a missed interrupt condition which this worked

around.

Quoted 2 lines

IIRC, the original code didn't bother with the load I added back as a work

around as a way to get posted mode working.

Well these seem to be working based on some quick timer tests. Pushing so we can verify it ;)

This kind of change might be better tested on the PM branch. It's the kind of thing more likely to work with PM disabled. Testing in both is good, PM for many things is less forgiving...

Regards,
Richard W.

#6 lore raw

Re: [PATCH 2/2] OMAP2/3 GPTIMER: skip unnecessary TLDR write during non-autoreload

Quoted 9 lines · Woodruff, Richard
Quoted 9 lines · Woodruff, Richard
Quoted 6 lines
Quoted 4 lines
      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);

}

I seem to recall there was a missed interrupt condition which this worked

around.

Quoted 1 line
Quoted 7 lines
Quoted 5 lines
Quoted 1 line

IIRC, the original code didn't bother with the load I added back as a work

around as a way to get posted mode working.

Well these seem to be working based on some quick timer tests. Pushing so we can verify it ;)

This kind of change might be better tested on the PM branch. It's the kind of thing more likely to work with PM disabled. Testing in both is good, PM for many things is less forgiving...

OK, let's not push them yet then. Kevin promised to run some timer tests on them on Monday, so let's wait for that.

Regards,

Tony

Acked-by
#7 lore raw

Re: [PATCH 2/2] OMAP2/3 GPTIMER: skip unnecessary TLDR write during non-autoreload

In reply to Woodruff, Richard
Quoted 10 lines · Richard
Quoted 10 lines · Woodruff, Richard
Quoted 6 lines
Quoted 4 lines
      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);

}

I seem to recall there was a missed interrupt condition which this worked

around.

Quoted 2 lines

IIRC, the original code didn't bother with the load I added back as a work

Quoted 8 lines
Quoted 4 lines

around as a way to get posted mode working.

Well these seem to be working based on some quick timer tests. Pushing so we can verify it ;)

This kind of change might be better tested on the PM branch. It's the kind of thing more likely to work with PM disabled. Testing in both is good, PM for many things is less forgiving...

I validated these patches on the PM branch.

I used cyclictest to test lots of timer reprogramming, and also tested in both RET-while-idle and OFF-while-idle for low frequency timer reprogramming.

#8 lore raw

Re: [PATCH 2/2] OMAP2/3 GPTIMER: skip unnecessary TLDR write during non-autoreload

Quoted 21 lines · Kevin Hilman
Quoted 10 lines · Richard
Quoted 10 lines · Woodruff, Richard
Quoted 6 lines
Quoted 4 lines
      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);

}

I seem to recall there was a missed interrupt condition which this worked

around.

Quoted 2 lines

IIRC, the original code didn't bother with the load I added back as a work

Quoted 8 lines
Quoted 4 lines

around as a way to get posted mode working.

Well these seem to be working based on some quick timer tests. Pushing so we can verify it ;)

This kind of change might be better tested on the PM branch. It's the kind of thing more likely to work with PM disabled. Testing in both is good, PM for many things is less forgiving...

Quoted 7 lines

I validated these patches on the PM branch.

I used cyclictest to test lots of timer reprogramming, and also tested in both RET-while-idle and OFF-while-idle for low frequency timer reprogramming.

Thanks for testing, pushing them to l-o today and adding to omap2-upstream queue.

Regards,

Tony