Skip to contentSkip to conversation

time: add weak annotation to timer_read_counter declaration

PATCH New Rob Herring 3 participants 7 messages Nov 8, 2013 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 time: add weak annotation to timer_read_counter declaration

From: Rob Herring <[email protected]>

A weak annotation is needed in order to prevent link errors when get_ticks is overridden. This fixes sandbox build.

---
 lib/time.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/time.c +1 -1
index 8361ddd..111b493 100644
@@ -37,7 +37,7 @@ unsigned long notrace timer_read_counter(void)
 #endif
 }
 #else
-extern unsigned long timer_read_counter(void);
+extern unsigned long __weak timer_read_counter(void);
 #endif
 
 unsigned long long __weak notrace get_ticks(void)
Signature · 1 line
1.8.1.2
#1 lore raw

PATCH 2/2 sandbox: convert to common time functions

From: Rob Herring <[email protected]>

Convert sandbox to use common time functions.

---
 board/sandbox/sandbox/sandbox.c | 14 ++------------
 include/configs/sandbox.h       |  2 ++
 2 files changed, 4 insertions(+), 12 deletions(-)
board/sandbox/sandbox/sandbox.c +2 -12
index f471cb7..65dcce8 100644
@@ -18,19 +18,9 @@ void flush_cache(unsigned long start, unsigned long size)
 {
 }
 
-ulong get_tbclk(void)
+unsigned long timer_read_counter(void)
 {
-	return CONFIG_SYS_HZ;
-}
-
-unsigned long long get_ticks(void)
-{
-	return get_timer(0);
-}
-
-ulong get_timer(ulong base)
-{
-	return (os_get_nsec() / 1000000) - base;
+	return os_get_nsec() / 1000;
 }
 
 int timer_init(void)
include/configs/sandbox.h +2 -0
index 279abbc..01628e1 100644
@@ -16,6 +16,8 @@
 
 #endif
 
+#define CONFIG_SYS_TIMER_RATE		1000000
+
 #define CONFIG_BOOTSTAGE
 #define CONFIG_BOOTSTAGE_REPORT
 
Signature · 1 line
1.8.1.2
#2 lore raw

PATCH 2/2 sandbox: convert to common time functions

Hi Rob,

Quoted 23 lines · Rob Herring

From: Rob Herring <[email protected]>

Convert sandbox to use common time functions.

---
 board/sandbox/sandbox/sandbox.c | 14 ++------------
 include/configs/sandbox.h       |  2 ++
 2 files changed, 4 insertions(+), 12 deletions(-)
board/sandbox/sandbox/sandbox.c +1 -3
index f471cb7..65dcce8 100644
@@ -18,19 +18,9 @@ void flush_cache(unsigned long start, unsigned long size)
 {
 }
 
-ulong get_tbclk(void)
+unsigned long timer_read_counter(void)
 {
-       return CONFIG_SYS_HZ;
-}

board/sandbox/sandbox/sandbox.c void flush_cache(unsigned long start, unsigned long size) · line 23

Quoted 10 lines
board/sandbox/sandbox/sandbox.c +1 -9
-
-unsigned long long get_ticks(void)
-{
-       return get_timer(0);
-}
-
-ulong get_timer(ulong base)
-{
-       return (os_get_nsec() / 1000000) - base;
+       return os_get_nsec() / 1000;

Doesn't this change the time base to microseconds? It would be good to keep sandbox at milliseconds like other boards. Or did I miss the reason for this change?

Quoted 17 lines
board/sandbox/sandbox/sandbox.c +0 -0
 }
 
 int timer_init(void)
include/configs/sandbox.h +2 -1
index 279abbc..01628e1 100644
@@ -16,6 +16,8 @@
 
 #endif
 
+#define CONFIG_SYS_TIMER_RATE          1000000
+
 #define CONFIG_BOOTSTAGE
 #define CONFIG_BOOTSTAGE_REPORT
 
--
Quoted 2 lines

1.8.1.2

Regards,
Simon

#3 lore raw

PATCH 2/2 sandbox: convert to common time functions

Quoted 32 lines · Simon Glass

Hi Rob,

Quoted 29 lines · Rob Herring

From: Rob Herring <[email protected]>

Convert sandbox to use common time functions.

---
 board/sandbox/sandbox/sandbox.c | 14 ++------------
 include/configs/sandbox.h       |  2 ++
 2 files changed, 4 insertions(+), 12 deletions(-)
board/sandbox/sandbox/sandbox.c +1 -9
index f471cb7..65dcce8 100644
@@ -18,19 +18,9 @@ void flush_cache(unsigned long start, unsigned long size)
 {
 }
 
-ulong get_tbclk(void)
+unsigned long timer_read_counter(void)
 {
-       return CONFIG_SYS_HZ;
-}
-
-unsigned long long get_ticks(void)
-{
-       return get_timer(0);
-}
-
Quoted 8 lines

board/sandbox/sandbox/sandbox.c void flush_cache(unsigned long start, unsigned long size) · line 23

Quoted 4 lines
board/sandbox/sandbox/sandbox.c +1 -3
-ulong get_timer(ulong base)
-{
-       return (os_get_nsec() / 1000000) - base;
+       return os_get_nsec() / 1000;

Doesn't this change the time base to microseconds? It would be good to keep sandbox at milliseconds like other boards. Or did I miss the reason for this change?

get_timer is still millisec. get_ticks is the "raw" counter ticks which is in microsec for sandbox. Some boards are equal here and some are not. The advantage of the latter is udelay has better resolution. However, in the case of sandbox, it uses the OS usleep so this doesn't matter.

Rob

#4 lore raw

PATCH 2/2 sandbox: convert to common time functions

Hi Rob,

Quoted 42 lines · Rob Herring
Quoted 32 lines · Simon Glass

Hi Rob,

Quoted 29 lines · Rob Herring

From: Rob Herring <[email protected]>

Convert sandbox to use common time functions.

---
 board/sandbox/sandbox/sandbox.c | 14 ++------------
 include/configs/sandbox.h       |  2 ++
 2 files changed, 4 insertions(+), 12 deletions(-)
board/sandbox/sandbox/sandbox.c +1 -9
index f471cb7..65dcce8 100644
@@ -18,19 +18,9 @@ void flush_cache(unsigned long start, unsigned long size)
 {
 }
 
-ulong get_tbclk(void)
+unsigned long timer_read_counter(void)
 {
-       return CONFIG_SYS_HZ;
-}
-
-unsigned long long get_ticks(void)
-{
-       return get_timer(0);
-}
-
Quoted 8 lines

board/sandbox/sandbox/sandbox.c void flush_cache(unsigned long start, unsigned long size) · line 23

Quoted 4 lines
board/sandbox/sandbox/sandbox.c +1 -3
-ulong get_timer(ulong base)
-{
-       return (os_get_nsec() / 1000000) - base;
+       return os_get_nsec() / 1000;

Doesn't this change the time base to microseconds? It would be good to keep sandbox at milliseconds like other boards. Or did I miss the reason for this change?

Quoted 5 lines

get_timer is still millisec. get_ticks is the "raw" counter ticks which is in microsec for sandbox. Some boards are equal here and some are not. The advantage of the latter is udelay has better resolution. However, in the case of sandbox, it uses the OS usleep so this doesn't matter.

OK that sounds good. I missed your timer patches at the time.

Regards,
Simon

#5 lore raw

PATCH 2/2 sandbox: convert to common time functions

In reply to Rob Herring
Quoted 5 lines · Rob Herring

From: Rob Herring <[email protected]>

Convert sandbox to use common time functions.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20131108/008c203c/attachment.pgp>
#6 lore raw

PATCH 1/2 time: add weak annotation to timer_read_counter declaration

In reply to Rob Herring
Quoted 6 lines · Rob Herring

From: Rob Herring <[email protected]>

A weak annotation is needed in order to prevent link errors when get_ticks is overridden. This fixes sandbox build.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20131108/58d446d4/attachment.pgp>