diff options
Diffstat (limited to 'common/clock.c')
-rw-r--r-- | common/clock.c | 33 |
1 files changed, 10 insertions, 23 deletions
diff --git a/common/clock.c b/common/clock.c index 1a4931ca83..b300e5798a 100644 --- a/common/clock.c +++ b/common/clock.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-only /* * clock.c - generic clocksource implementation * @@ -6,35 +7,16 @@ * * Copyright (C) 2004, 2005 IBM, John Stultz (johnstul@us.ibm.com) * Copyright (c) 2007 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix - * - * See file CREDITS for list of people who contributed to this - * project. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * */ #include <common.h> #include <init.h> -#include <asm-generic/div64.h> +#include <linux/math64.h> #include <clock.h> -#include <poller.h> +#include <sched.h> static uint64_t time_ns; -/* - * The first timestamp when the clocksource is registered. - * Useful for measuring the time spent in barebox. - */ -uint64_t time_beginning; - static uint64_t dummy_read(void) { static uint64_t dummy_counter; @@ -184,7 +166,7 @@ int is_timeout(uint64_t start_ns, uint64_t time_offset_ns) int ret = is_timeout_non_interruptible(start_ns, time_offset_ns); if (time_offset_ns >= 100 * USECOND) - poller_call(); + resched(); return ret; } @@ -234,8 +216,13 @@ int init_clock(struct clocksource *cs) return ret; } + /* + * If clocksource is freerunning it might have been running for a while + * before barebox started, we only care about the time spent in barebox + * thus we must discard the clocksource cycles up to this exact moment: + */ + cs->cycle_last = cs->read() & cs->mask; current_clock = cs; - time_beginning = get_time_ns(); return 0; } |