mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Subject: [PATCH 6/9] clocksource: move dummy clock source to init_clock
Date: Fri,  3 Mar 2017 13:34:02 +0100	[thread overview]
Message-ID: <1488544445-20105-6-git-send-email-plagnioj@jcrosoft.com> (raw)
In-Reply-To: <1488544445-20105-1-git-send-email-plagnioj@jcrosoft.com>

And registered it as soon as possible (at pure initcall).
So we not need to check the cs all the time.
As get_time_ns() is one of the most called function of barebox at runtime.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 common/clock.c | 33 ++++++++++++++++++++++++---------
 1 file changed, 24 insertions(+), 9 deletions(-)

diff --git a/common/clock.c b/common/clock.c
index 1090b605f..0d581c2c7 100644
--- a/common/clock.c
+++ b/common/clock.c
@@ -36,9 +36,32 @@ static uint64_t time_ns;
  */
 uint64_t time_beginning;
 
+static uint64_t dummy_read(void)
+{
+	static uint64_t dummy_counter;
+
+	dummy_counter += CONFIG_CLOCKSOURCE_DUMMY_RATE;
+
+	return dummy_counter;
+}
+
+static struct clocksource dummy_cs = {
+	.shift = 0,
+	.mult = 1,
+	.read = dummy_read,
+	.mask = CLOCKSOURCE_MASK(64),
+	.priority = -1,
+};
+
+static int dummy_csrc_init(void)
+{
+	return init_clock(&dummy_cs);
+}
+pure_initcall(dummy_csrc_init);
+
 static int dummy_csrc_warn(void)
 {
-	if (!current_clock) {
+	if (current_clock == &dummy_cs) {
 		pr_warn("Warning: Using dummy clocksource\n");
 	}
 
@@ -55,14 +78,6 @@ uint64_t get_time_ns(void)
 	uint64_t cycle_now, cycle_delta;
 	uint64_t ns_offset;
 
-	if (!cs) {
-		static uint64_t dummy_counter;
-
-		dummy_counter += CONFIG_CLOCKSOURCE_DUMMY_RATE;
-
-		return dummy_counter;
-	}
-
 	/* read clocksource: */
 	cycle_now = cs->read() & cs->mask;
 
-- 
2.11.0


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

  parent reply	other threads:[~2017-03-03 12:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-03 12:32 [PATCH 0/9] add generic EFI timer Jean-Christophe PLAGNIOL-VILLARD
2017-03-03 12:33 ` [PATCH 1/9] efi: add prototype and definition for creating and closing event Jean-Christophe PLAGNIOL-VILLARD
2017-03-03 12:33   ` [PATCH 2/9] efi: add prototype and definition for setting timer Jean-Christophe PLAGNIOL-VILLARD
2017-03-03 12:33   ` [PATCH 3/9] efi: move LoaderTimeInitUSec and LoaderDevicePartUUID to postcore initcall Jean-Christophe PLAGNIOL-VILLARD
2017-03-03 12:34   ` [PATCH 4/9] efi: move x86 clocksource init at core initcall level Jean-Christophe PLAGNIOL-VILLARD
2017-03-03 12:34   ` [PATCH 5/9] clocksource: allow to have multiple device from clock source Jean-Christophe PLAGNIOL-VILLARD
2017-03-03 12:34   ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2017-03-03 12:34   ` [PATCH 7/9] efi: move x86 clocksource to device/driver Jean-Christophe PLAGNIOL-VILLARD
2017-03-03 12:34   ` [PATCH 8/9] efi: clocksoure: add EFI event timer Jean-Christophe PLAGNIOL-VILLARD
2017-03-07  7:41     ` Sascha Hauer
2017-03-03 12:34   ` [PATCH 9/9] efi: add veriable to report secure boot support and status Jean-Christophe PLAGNIOL-VILLARD

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=1488544445-20105-6-git-send-email-plagnioj@jcrosoft.com \
    --to=plagnioj@jcrosoft.com \
    --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