mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jules Maselbas <jmaselbas@kalray.eu>
To: barebox@lists.infradead.org
Cc: Jules Maselbas <jmaselbas@kalray.eu>
Subject: [PATCH 1/4] clock: Change cyc2ns return type to uint64_t
Date: Thu, 25 Mar 2021 14:38:34 +0100	[thread overview]
Message-ID: <20210325133837.30866-1-jmaselbas@kalray.eu> (raw)

Using an uint32_t to count nanosec will overflow every ~4sec, this means
that if get_time_ns is not called often enough the time keeping will be
wrong. By changing the return type to uint64_t doesn't fix the underlying
overflow issue but it will take more than 500 years to happen and I think
it's safe to assume this won't be an issue.

Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
---
 include/clock.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/clock.h b/include/clock.h
index d681bf630..e6197e7eb 100644
--- a/include/clock.h
+++ b/include/clock.h
@@ -17,7 +17,7 @@ struct clocksource {
 	int		(*init)(struct clocksource*);
 };
 
-static inline uint32_t cyc2ns(struct clocksource *cs, uint64_t cycles)
+static inline uint64_t cyc2ns(struct clocksource *cs, uint64_t cycles)
 {
         uint64_t ret = cycles;
         ret = (ret * cs->mult) >> cs->shift;
-- 
2.17.1



_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


             reply	other threads:[~2021-03-25 13:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-25 13:38 Jules Maselbas [this message]
2021-03-25 13:38 ` [PATCH 2/4] clock: Update cs->cycle_last when switching clock Jules Maselbas
2021-03-25 13:38 ` [PATCH 3/4] clock: Remove time_beginning Jules Maselbas
2021-03-25 13:38 ` [PATCH 4/4] common: common_console: Rework log_print Jules Maselbas

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=20210325133837.30866-1-jmaselbas@kalray.eu \
    --to=jmaselbas@kalray.eu \
    --cc=barebox@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