Skip to contentSkip to conversation

ARM: davinci: convert to clockevents_config_and_register

PATCH New Uwe Kleine-König 3 participants 9 messages Sep 24, 2013 – Oct 16, 2013

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

PATCH 1/1 ARM: davinci: convert to clockevents_config_and_register

clockevents_config_and_register is superior compared to setting shift/mult and {min,max}_delta_ns by hand.

---
Hello,

I wonder where the 50 us limit comes from. This is not a hardware limit, is it?

Best regards
Uwe

 arch/arm/mach-davinci/time.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
arch/arm/mach-davinci/time.c +3 -7
index 7a55b5c..627bf8b 100644
@@ -331,7 +331,6 @@ static void davinci_set_mode(enum clock_event_mode mode,
 
 static struct clock_event_device clockevent_davinci = {
 	.features       = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
-	.shift		= 32,
 	.set_next_event	= davinci_set_next_event,
 	.set_mode	= davinci_set_mode,
 };
@@ -397,14 +396,11 @@ void __init davinci_timer_init(void)
 
 	/* setup clockevent */
 	clockevent_davinci.name = id_to_name[timers[TID_CLOCKEVENT].id];
-	clockevent_davinci.mult = div_sc(davinci_clock_tick_rate, NSEC_PER_SEC,
-					 clockevent_davinci.shift);
-	clockevent_davinci.max_delta_ns =
-		clockevent_delta2ns(0xfffffffe, &clockevent_davinci);
-	clockevent_davinci.min_delta_ns = 50000; /* 50 usec */
 
 	clockevent_davinci.cpumask = cpumask_of(0);
-	clockevents_register_device(&clockevent_davinci);
+	/* min tick corresponds to 50 usec assuming a 24 MHz clock */
+	clockevents_config_and_register(&clockevent_davinci,
+		davinci_clock_tick_rate, 1200, 0xfffffffe);
 
 	for (i=0; i< ARRAY_SIZE(timers); i++)
 		timer32_config(&timers[i]);
Signature · 1 line
1.8.4.rc3
#1 lore raw

PATCH 1/1 ARM: davinci: convert to clockevents_config_and_register

Hello,

Quoted 10 lines · Uwe Kleine-K?nig

clockevents_config_and_register is superior compared to setting shift/mult and {min,max}_delta_ns by hand.

---
Hello,

I wonder where the 50 us limit comes from. This is not a hardware limit, is it?

ping; I didn't get any feedback on this yet, also it's not in next.

Best regards
Uwe

Quoted 37 lines
 arch/arm/mach-davinci/time.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
arch/arm/mach-davinci/time.c +3 -7
index 7a55b5c..627bf8b 100644
@@ -331,7 +331,6 @@ static void davinci_set_mode(enum clock_event_mode mode,
 
 static struct clock_event_device clockevent_davinci = {
 	.features       = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
-	.shift		= 32,
 	.set_next_event	= davinci_set_next_event,
 	.set_mode	= davinci_set_mode,
 };
@@ -397,14 +396,11 @@ void __init davinci_timer_init(void)
 
 	/* setup clockevent */
 	clockevent_davinci.name = id_to_name[timers[TID_CLOCKEVENT].id];
-	clockevent_davinci.mult = div_sc(davinci_clock_tick_rate, NSEC_PER_SEC,
-					 clockevent_davinci.shift);
-	clockevent_davinci.max_delta_ns =
-		clockevent_delta2ns(0xfffffffe, &clockevent_davinci);
-	clockevent_davinci.min_delta_ns = 50000; /* 50 usec */
 
 	clockevent_davinci.cpumask = cpumask_of(0);
-	clockevents_register_device(&clockevent_davinci);
+	/* min tick corresponds to 50 usec assuming a 24 MHz clock */
+	clockevents_config_and_register(&clockevent_davinci,
+		davinci_clock_tick_rate, 1200, 0xfffffffe);
 
 	for (i=0; i< ARRAY_SIZE(timers); i++)
 		timer32_config(&timers[i]);
Signature · 1 line
1.8.4.rc3
Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#2 lore raw

PATCH 1/1 ARM: davinci: convert to clockevents_config_and_register

Uwe,

Quoted 6 lines · Uwe Kleine-K?nig

Hello,

Quoted 3 lines · Uwe Kleine-K?nig

clockevents_config_and_register is superior compared to setting shift/mult and {min,max}_delta_ns by hand.

Quoted 8 lines
Quoted 7 lines

---
Hello,

I wonder where the 50 us limit comes from. This is not a hardware limit, is it?

ping; I didn't get any feedback on this yet, also it's not in next.

Apologies for the delay. I am yet to look at it because I am traveling ATM. I will look at it during this week and provide feedback.

Thanks,
Sekhar

#3 lore raw

PATCH 1/1 ARM: davinci: convert to clockevents_config_and_register

In reply to Uwe Kleine-König
Quoted 33 lines · Uwe Kleine-K?nig

clockevents_config_and_register is superior compared to setting shift/mult and {min,max}_delta_ns by hand.

---
Hello,

I wonder where the 50 us limit comes from. This is not a hardware limit, is it?

Best regards
Uwe

 arch/arm/mach-davinci/time.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
arch/arm/mach-davinci/time.c +0 -2
index 7a55b5c..627bf8b 100644
@@ -331,7 +331,6 @@ static void davinci_set_mode(enum clock_event_mode mode,
 
 static struct clock_event_device clockevent_davinci = {
 	.features       = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
-	.shift		= 32,
 	.set_next_event	= davinci_set_next_event,
 	.set_mode	= davinci_set_mode,
 };
@@ -397,14 +396,11 @@ void __init davinci_timer_init(void)
 
 	/* setup clockevent */
 	clockevent_davinci.name = id_to_name[timers[TID_CLOCKEVENT].id];
-	clockevent_davinci.mult = div_sc(davinci_clock_tick_rate, NSEC_PER_SEC,

arch/arm/mach-davinci/time.c void __init davinci_timer_init(void) · line 403

Quoted 10 lines
arch/arm/mach-davinci/time.c +3 -5
-					 clockevent_davinci.shift);
-	clockevent_davinci.max_delta_ns =
-		clockevent_delta2ns(0xfffffffe, &clockevent_davinci);
-	clockevent_davinci.min_delta_ns = 50000; /* 50 usec */
 
 	clockevent_davinci.cpumask = cpumask_of(0);
-	clockevents_register_device(&clockevent_davinci);
+	/* min tick corresponds to 50 usec assuming a 24 MHz clock */
+	clockevents_config_and_register(&clockevent_davinci,
+		davinci_clock_tick_rate, 1200, 0xfffffffe);

Min ticks can be set to 1, IMO. I think the 50usec limit used earlier should have actually been 50ns assuming a 24MHz clock.

Prabhakar,

Can you please test this patch on a DaVinci platform you have with 1200 replaced with 1. I currently do not have access to a board.

Thanks,
Sekhar

#4 lore raw

PATCH 1/1 ARM: davinci: convert to clockevents_config_and_register

Hi Sekhar,

Quoted 3 lines · Sekhar Nori
Quoted 2 lines · Uwe Kleine-K?nig

clockevents_config_and_register is superior compared to setting shift/mult and {min,max}_delta_ns by hand.

[snip]

Quoted 11 lines

arch/arm/mach-davinci/time.c void __init davinci_timer_init(void) · line 403

Quoted 2 lines
arch/arm/mach-davinci/time.c +1 -0
+		davinci_clock_tick_rate, 1200, 0xfffffffe);

Min ticks can be set to 1, IMO. I think the 50usec limit used earlier should have actually been 50ns assuming a 24MHz clock.

Prabhakar,

Can you please test this patch on a DaVinci platform you have with 1200 replaced with 1. I currently do not have access to a board.

I have boot tested this patch on OMAP-L138 and tested the uptime (with min ticks set to 1), should that be enough ?

Thanks,
--Prabhakar Lad

#5 lore raw

PATCH v2 1/1 ARM: davinci: convert to clockevents_config_and_register

clockevents_config_and_register is superior compared to setting shift/mult and {min,max}_delta_ns by hand.

---

Quoted 2 lines · Prabhakar Lad

I have boot tested this patch on OMAP-L138 and tested the uptime (with min ticks set to 1), should that be enough ?

I don't know for sure, but I guess so. If you agree, here is an updated patch.

Best regards
Uwe

 arch/arm/mach-davinci/time.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
arch/arm/mach-davinci/time.c +2 -7
index 7a55b5c..29a1a5d 100644
@@ -331,7 +331,6 @@ static void davinci_set_mode(enum clock_event_mode mode,
 
 static struct clock_event_device clockevent_davinci = {
 	.features       = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
-	.shift		= 32,
 	.set_next_event	= davinci_set_next_event,
 	.set_mode	= davinci_set_mode,
 };
@@ -397,14 +396,10 @@ void __init davinci_timer_init(void)
 
 	/* setup clockevent */
 	clockevent_davinci.name = id_to_name[timers[TID_CLOCKEVENT].id];
-	clockevent_davinci.mult = div_sc(davinci_clock_tick_rate, NSEC_PER_SEC,
-					 clockevent_davinci.shift);
-	clockevent_davinci.max_delta_ns =
-		clockevent_delta2ns(0xfffffffe, &clockevent_davinci);
-	clockevent_davinci.min_delta_ns = 50000; /* 50 usec */
 
 	clockevent_davinci.cpumask = cpumask_of(0);
-	clockevents_register_device(&clockevent_davinci);
+	clockevents_config_and_register(&clockevent_davinci,
+		davinci_clock_tick_rate, 1, 0xfffffffe);
 
 	for (i=0; i< ARRAY_SIZE(timers); i++)
 		timer32_config(&timers[i]);
Signature · 1 line
1.8.4.rc3
#6 lore raw

PATCH v2 1/1 ARM: davinci: convert to clockevents_config_and_register

Quoted 35 lines · Uwe Kleine-K?nig

clockevents_config_and_register is superior compared to setting shift/mult and {min,max}_delta_ns by hand.

---

Quoted 2 lines · Prabhakar Lad

I have boot tested this patch on OMAP-L138 and tested the uptime (with min ticks set to 1), should that be enough ?

I don't know for sure, but I guess so. If you agree, here is an updated patch.

Best regards
Uwe

 arch/arm/mach-davinci/time.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
arch/arm/mach-davinci/time.c +0 -1
index 7a55b5c..29a1a5d 100644
@@ -331,7 +331,6 @@ static void davinci_set_mode(enum clock_event_mode mode,
 
 static struct clock_event_device clockevent_davinci = {
 	.features       = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
-	.shift		= 32,
 	.set_next_event	= davinci_set_next_event,
 	.set_mode	= davinci_set_mode,
 };
@@ -397,14 +396,10 @@ void __init davinci_timer_init(void)
 
 	/* setup clockevent */
 	clockevent_davinci.name = id_to_name[timers[TID_CLOCKEVENT].id];

arch/arm/mach-davinci/time.c void __init davinci_timer_init(void) · line 402

Quoted 10 lines
arch/arm/mach-davinci/time.c +2 -6
-	clockevent_davinci.mult = div_sc(davinci_clock_tick_rate, NSEC_PER_SEC,
-					 clockevent_davinci.shift);
-	clockevent_davinci.max_delta_ns =
-		clockevent_delta2ns(0xfffffffe, &clockevent_davinci);
-	clockevent_davinci.min_delta_ns = 50000; /* 50 usec */
 
 	clockevent_davinci.cpumask = cpumask_of(0);
-	clockevents_register_device(&clockevent_davinci);
+	clockevents_config_and_register(&clockevent_davinci,
+		davinci_clock_tick_rate, 1, 0xfffffffe);

checkpatch --strict complains about alignment of line break. Fixed locally.

Thanks,
Sekhar

#7 lore raw

PATCH v2 1/1 ARM: davinci: convert to clockevents_config_and_register

Hello,

Quoted 42 lines · Sekhar Nori
Quoted 41 lines · Uwe Kleine-K?nig

clockevents_config_and_register is superior compared to setting shift/mult and {min,max}_delta_ns by hand.

---

Quoted 2 lines · Prabhakar Lad

I have boot tested this patch on OMAP-L138 and tested the uptime (with min ticks set to 1), should that be enough ?

I don't know for sure, but I guess so. If you agree, here is an updated patch.

Best regards
Uwe

 arch/arm/mach-davinci/time.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
arch/arm/mach-davinci/time.c +0 -6
index 7a55b5c..29a1a5d 100644
@@ -331,7 +331,6 @@ static void davinci_set_mode(enum clock_event_mode mode,
 
 static struct clock_event_device clockevent_davinci = {
 	.features       = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
-	.shift		= 32,
 	.set_next_event	= davinci_set_next_event,
 	.set_mode	= davinci_set_mode,
 };
@@ -397,14 +396,10 @@ void __init davinci_timer_init(void)
 
 	/* setup clockevent */
 	clockevent_davinci.name = id_to_name[timers[TID_CLOCKEVENT].id];
-	clockevent_davinci.mult = div_sc(davinci_clock_tick_rate, NSEC_PER_SEC,
-					 clockevent_davinci.shift);
-	clockevent_davinci.max_delta_ns =
-		clockevent_delta2ns(0xfffffffe, &clockevent_davinci);
-	clockevent_davinci.min_delta_ns = 50000; /* 50 usec */
 
Quoted 6 lines

arch/arm/mach-davinci/time.c void __init davinci_timer_init(void) · line 402

Quoted 4 lines
arch/arm/mach-davinci/time.c +2 -1
 	clockevent_davinci.cpumask = cpumask_of(0);
-	clockevents_register_device(&clockevent_davinci);
+	clockevents_config_and_register(&clockevent_davinci,
+		davinci_clock_tick_rate, 1, 0xfffffffe);

checkpatch --strict complains about alignment of line break. Fixed locally.

I used the same style as in other places in that file.

Another thought that came to me is that it's probably worth mentioning that the min_delta_ns is changed from 50 usec to 1 hw tick. Something like:

Note that the minimum delay is changed from 50 us to 1 hw tick (which corresponds to 42 ns assuming a 24 MHz clock). It's expected that the old value was miscalculated.

That would be interesting in case that the patch results in regressions.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#8 lore raw

PATCH v2 1/1 ARM: davinci: convert to clockevents_config_and_register

Quoted 45 lines · Uwe Kleine-K?nig

Hello,

Quoted 42 lines · Sekhar Nori
Quoted 41 lines · Uwe Kleine-K?nig

clockevents_config_and_register is superior compared to setting shift/mult and {min,max}_delta_ns by hand.

---

Quoted 2 lines · Prabhakar Lad

I have boot tested this patch on OMAP-L138 and tested the uptime (with min ticks set to 1), should that be enough ?

I don't know for sure, but I guess so. If you agree, here is an updated patch.

Best regards
Uwe

 arch/arm/mach-davinci/time.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
arch/arm/mach-davinci/time.c +0 -6
index 7a55b5c..29a1a5d 100644
@@ -331,7 +331,6 @@ static void davinci_set_mode(enum clock_event_mode mode,
 
 static struct clock_event_device clockevent_davinci = {
 	.features       = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
-	.shift		= 32,
 	.set_next_event	= davinci_set_next_event,
 	.set_mode	= davinci_set_mode,
 };
@@ -397,14 +396,10 @@ void __init davinci_timer_init(void)
 
 	/* setup clockevent */
 	clockevent_davinci.name = id_to_name[timers[TID_CLOCKEVENT].id];
-	clockevent_davinci.mult = div_sc(davinci_clock_tick_rate, NSEC_PER_SEC,
-					 clockevent_davinci.shift);
-	clockevent_davinci.max_delta_ns =
-		clockevent_delta2ns(0xfffffffe, &clockevent_davinci);
-	clockevent_davinci.min_delta_ns = 50000; /* 50 usec */
 
Quoted 7 lines
Quoted 6 lines

arch/arm/mach-davinci/time.c void __init davinci_timer_init(void) · line 402

Quoted 4 lines
arch/arm/mach-davinci/time.c +2 -1
 	clockevent_davinci.cpumask = cpumask_of(0);
-	clockevents_register_device(&clockevent_davinci);
+	clockevents_config_and_register(&clockevent_davinci,
+		davinci_clock_tick_rate, 1, 0xfffffffe);

checkpatch --strict complains about alignment of line break. Fixed locally.

I used the same style as in other places in that file.

Okay, but I prefer to fix for new code.

Quoted 10 lines

Another thought that came to me is that it's probably worth mentioning that the min_delta_ns is changed from 50 usec to 1 hw tick. Something like:

Note that the minimum delay is changed from 50 us to 1 hw tick (which corresponds to 42 ns assuming a 24 MHz clock). It's expected that the old value was miscalculated.

That would be interesting in case that the patch results in regressions.

Too late as I already sent my pull request. Adding this to patch description would have been nice, I agree.

Thanks,
Sekhar