hardclock_ticks -> getticks()

This commit is contained in:
maxv 2020-07-03 16:23:02 +00:00
parent 0da96df8e5
commit ef06fc5cad
9 changed files with 46 additions and 47 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: clock.c,v 1.57 2020/05/29 05:35:47 rin Exp $ */
/* $NetBSD: clock.c,v 1.58 2020/07/03 16:23:03 maxv Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.57 2020/05/29 05:35:47 rin Exp $");
__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.58 2020/07/03 16:23:03 maxv Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@ -292,9 +292,9 @@ clk_getcounter(struct timecounter *tc)
u_int counter;
do {
cur_hardclock = hardclock_ticks;
cur_hardclock = getticks();
counter = clk_gettick();
} while (cur_hardclock != hardclock_ticks);
} while (cur_hardclock != getticks());
/*
* Handle the situation of a wrapped interval counter, while

View File

@ -1,4 +1,4 @@
/*$NetBSD: at91st.c,v 1.6 2012/11/12 18:00:36 skrll Exp $*/
/*$NetBSD: at91st.c,v 1.7 2020/07/03 16:23:02 maxv Exp $*/
/*
* AT91RM9200 clock functions
@ -40,7 +40,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: at91st.c,v 1.6 2012/11/12 18:00:36 skrll Exp $");
__KERNEL_RCSID(0, "$NetBSD: at91st.c,v 1.7 2020/07/03 16:23:02 maxv Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -213,8 +213,8 @@ at91st_intr(void *arg)
/* call the kernel timer handler */
hardclock((struct clockframe*) arg);
#if 0
if (hardclock_ticks % (HZ * 10) == 0)
printf("time %i sec\n", hardclock_ticks/HZ);
if (getticks() % (HZ * 10) == 0)
printf("time %i sec\n", getticks()/HZ);
#endif
return 1;
}
@ -333,18 +333,17 @@ microtime(register struct timeval *tvp)
#if 0
extern int hardclock_ticks;
static void tdelay(unsigned int ticks)
{
uint32_t start, end, current;
current = hardclock_ticks;
current = getticks();
start = current;
end = start + ticks;
/* just loop for the specified number of ticks */
while (current < end)
current = hardclock_ticks;
current = getticks();
}
#endif

View File

@ -1,4 +1,4 @@
/*$NetBSD: at91tctmr.c,v 1.8 2020/05/29 12:30:38 rin Exp $*/
/*$NetBSD: at91tctmr.c,v 1.9 2020/07/03 16:23:02 maxv Exp $*/
/*
* AT91 Timer Counter (TC) based clock functions
@ -40,7 +40,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: at91tctmr.c,v 1.8 2020/05/29 12:30:38 rin Exp $");
__KERNEL_RCSID(0, "$NetBSD: at91tctmr.c,v 1.9 2020/07/03 16:23:02 maxv Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -302,20 +302,20 @@ static void udelay(unsigned int usec)
unsigned footick = (sc->sc_timerclock * 64ULL / 1000000UL);
if (usec > 0) {
prev_ticks = hardclock_ticks;
prev_ticks = getticks();
__insn_barrier();
prev_cvr = READ_TC(sc, TC_CV);
ticks = hardclock_ticks;
ticks = getticks();
__insn_barrier();
if (ticks != prev_ticks) {
prev_cvr = READ_TC(sc, TC_CV);
prev_ticks = ticks;
}
for (;;) {
ticks = hardclock_ticks;
ticks = getticks();
__insn_barrier();
cvr = READ_TC(sc, TC_CV);
ticks2 = hardclock_ticks;
ticks2 = getticks();
__insn_barrier();
if (ticks2 != ticks) {
cvr = READ_TC(sc, TC_CV);

View File

@ -1,4 +1,4 @@
/* $NetBSD: clock.c,v 1.61 2020/05/29 12:30:39 rin Exp $ */
/* $NetBSD: clock.c,v 1.62 2020/07/03 16:23:03 maxv Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.61 2020/05/29 12:30:39 rin Exp $");
__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.62 2020/07/03 16:23:03 maxv Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@ -280,7 +280,7 @@ clk_getcounter(struct timecounter *tc)
static uint32_t lastcount;
s = splhigh();
cur_hardclock = hardclock_ticks;
cur_hardclock = getticks();
ipra = MFP->mf_ipra;
tadr = MFP->mf_tadr;
delta = divisor - tadr;

View File

@ -1,4 +1,4 @@
/* $NetBSD: clock.c,v 1.59 2020/05/29 12:30:41 rin Exp $ */
/* $NetBSD: clock.c,v 1.60 2020/07/03 16:23:03 maxv Exp $ */
/*
* Copyright (c) 1995 Ludd, University of Lule}, Sweden.
* All rights reserved.
@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.59 2020/05/29 12:30:41 rin Exp $");
__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.60 2020/07/03 16:23:03 maxv Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -66,13 +66,13 @@ vax_diag_get_counter(struct timecounter *tc)
u_int counter;
do {
cur_hardclock = hardclock_ticks;
cur_hardclock = getticks();
counter = *(volatile u_int *)&ka46_cpu->vc_diagtimu;
} while (cur_hardclock != hardclock_ticks);
} while (cur_hardclock != getticks());
counter = (counter & 0x3ff) + (counter >> 16) * 1024;
return counter + hardclock_ticks * tick;
return counter + getticks() * tick;
}
#endif
@ -84,13 +84,13 @@ vax_mfpr_get_counter(struct timecounter *tc)
static int prev_count, prev_hardclock;
do {
cur_hardclock = hardclock_ticks;
cur_hardclock = getticks();
counter = mfpr(PR_ICR) + tick;
} while (cur_hardclock != hardclock_ticks);
} while (cur_hardclock != getticks());
/*
* Handle interval counter wrapping with interrupts blocked.
* If the current hardclock_ticks is less than what we saw
* If the current getticks() is less than what we saw
* previously, use the previous value.
* If the interval counter is smaller, assume it has wrapped,
* and if the [adjusted] current hardclock ticks is the same

View File

@ -1,4 +1,4 @@
/* $NetBSD: completion.h,v 1.6 2017/01/11 11:42:09 skrll Exp $ */
/* $NetBSD: completion.h,v 1.7 2020/07/03 16:23:02 maxv Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@ -191,7 +191,7 @@ wait_for_completion_interruptible_timeout(struct completion *completion,
unsigned long ticks)
{
/* XXX Arithmetic overflow...? */
unsigned int start = hardclock_ticks, now;
unsigned int start = getticks(), now;
int error;
mutex_enter(&completion->c_lock);
@ -202,7 +202,7 @@ wait_for_completion_interruptible_timeout(struct completion *completion,
&completion->c_lock, ticks);
if (error)
goto out;
now = hardclock_ticks;
now = getticks();
if (ticks < (now - start)) {
error = EWOULDBLOCK;
goto out;

View File

@ -1,4 +1,4 @@
/* $NetBSD: drm_wait_netbsd.h,v 1.16 2020/02/14 04:37:43 riastradh Exp $ */
/* $NetBSD: drm_wait_netbsd.h,v 1.17 2020/07/03 16:23:02 maxv Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@ -140,10 +140,10 @@ DRM_SPIN_WAKEUP_ALL(drm_waitqueue_t *q, spinlock_t *interlock)
(RET) = -EBUSY; /* Match Linux... */ \
break; \
} \
_dswo_start = hardclock_ticks; \
_dswo_start = getticks(); \
/* XXX errno NetBSD->Linux */ \
(RET) = -cv_timedwait_sig((Q), &(INTERLOCK)->sl_lock, 1); \
_dswo_end = hardclock_ticks; \
_dswo_end = getticks(); \
if (_dswo_end - _dswo_start < _dswo_ticks) \
_dswo_ticks -= _dswo_end - _dswo_start; \
else \
@ -239,11 +239,11 @@ DRM_SPIN_WAKEUP_ALL(drm_waitqueue_t *q, spinlock_t *interlock)
(RET) = 0; \
break; \
} \
_dtwu_start = hardclock_ticks; \
_dtwu_start = getticks(); \
/* XXX errno NetBSD->Linux */ \
(RET) = -WAIT((Q), &(INTERLOCK)->mtx_lock, \
MIN(_dtwu_ticks, INT_MAX/2)); \
_dtwu_end = hardclock_ticks; \
_dtwu_end = getticks(); \
if ((_dtwu_end - _dtwu_start) < _dtwu_ticks) \
_dtwu_ticks -= _dtwu_end - _dtwu_start; \
else \
@ -314,11 +314,11 @@ DRM_SPIN_WAKEUP_ALL(drm_waitqueue_t *q, spinlock_t *interlock)
(RET) = 0; \
break; \
} \
_dstwu_start = hardclock_ticks; \
_dstwu_start = getticks(); \
/* XXX errno NetBSD->Linux */ \
(RET) = -WAIT((Q), &(INTERLOCK)->sl_lock, \
MIN(_dstwu_ticks, INT_MAX/2)); \
_dstwu_end = hardclock_ticks; \
_dstwu_end = getticks(); \
if ((_dstwu_end - _dstwu_start) < _dstwu_ticks) \
_dstwu_ticks -= _dstwu_end - _dstwu_start; \
else \

View File

@ -1,4 +1,4 @@
/* $NetBSD: sched.h,v 1.14 2020/03/14 18:08:39 ad Exp $ */
/* $NetBSD: sched.h,v 1.15 2020/07/03 16:23:02 maxv Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@ -74,10 +74,10 @@ schedule_timeout_uninterruptible(long timeout)
return 0;
}
start = hardclock_ticks;
start = getticks();
/* Caller is expected to loop anyway, so no harm in truncating. */
(void)kpause("loonix", false /*!intr*/, MIN(timeout, INT_MAX), NULL);
end = hardclock_ticks;
end = getticks();
remain = timeout - (end - start);
return remain > 0 ? remain : 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_fence.c,v 1.15 2019/04/16 10:00:04 mrg Exp $ */
/* $NetBSD: linux_fence.c,v 1.16 2020/07/03 16:23:02 maxv Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: linux_fence.c,v 1.15 2019/04/16 10:00:04 mrg Exp $");
__KERNEL_RCSID(0, "$NetBSD: linux_fence.c,v 1.16 2020/07/03 16:23:02 maxv Exp $");
#include <sys/atomic.h>
#include <sys/condvar.h>
@ -543,7 +543,7 @@ fence_wait_any_timeout(struct fence **fences, uint32_t nfences, bool intr,
*/
mutex_enter(&common.lock);
while (timeout > 0 && !common.done) {
start = hardclock_ticks;
start = getticks();
__insn_barrier();
if (intr) {
if (timeout != MAX_SCHEDULE_TIMEOUT) {
@ -563,7 +563,7 @@ fence_wait_any_timeout(struct fence **fences, uint32_t nfences, bool intr,
ret = 0;
}
}
end = hardclock_ticks;
end = getticks();
__insn_barrier();
if (ret) {
if (ret == -ERESTART)
@ -677,7 +677,7 @@ fence_default_wait(struct fence *fence, bool intr, long timeout)
/* Find out what our deadline is so we can handle spurious wakeup. */
if (timeout < MAX_SCHEDULE_TIMEOUT) {
now = hardclock_ticks;
now = getticks();
__insn_barrier();
starttime = now;
deadline = starttime + timeout;
@ -690,7 +690,7 @@ fence_default_wait(struct fence *fence, bool intr, long timeout)
* give up.
*/
if (timeout < MAX_SCHEDULE_TIMEOUT) {
now = hardclock_ticks;
now = getticks();
__insn_barrier();
if (deadline <= now)
break;