Skip to content

Commit

Permalink
clock: initialize dummy clocksource statically
Browse files Browse the repository at this point in the history
Assigning the dummy clocksource in a initcall has the problem that
get_time_ns() crashes before that initcall is executed. This happens
when dmesg support is enabled in conjunction with CONFIG_DEBUG_INITCALLS.
In this case the dmesg code wants to have the timestamp of a log
message.
Solve this by setting the current clocksource to the dummy clock
statically and not at runtime. This way we always have a dummy
clock available.

Fixes:
commit 8972eb7
Author: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
Date:   Fri Mar 3 13:34:02 2017 +0100

    clocksource: move dummy clock source to init_clock

Signed-off-by: Sascha Hauer <[email protected]>
  • Loading branch information
saschahauer committed May 5, 2017
1 parent 587afe8 commit e5f2191
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions common/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include <clock.h>
#include <poller.h>

static struct clocksource *current_clock;
static uint64_t time_ns;

/*
Expand All @@ -53,11 +52,7 @@ static struct clocksource dummy_cs = {
.priority = -1,
};

static int dummy_csrc_init(void)
{
return init_clock(&dummy_cs);
}
pure_initcall(dummy_csrc_init);
static struct clocksource *current_clock = &dummy_cs;

static int dummy_csrc_warn(void)
{
Expand Down

0 comments on commit e5f2191

Please sign in to comment.