Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 3 Oct 2019 11:40:21 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Bruce Evans <brde@optusnet.com.au>
Cc:        Sebastian Huber <sebastian.huber@embedded-brains.de>, FreeBSD <freebsd-hackers@freebsd.org>
Subject:   Re: Why is tc_get_timecount() called two times in tc_init()?
Message-ID:  <20191003084021.GI44691@kib.kiev.ua>
In-Reply-To: <20191003030837.C2787@besplex.bde.org>
References:  <0e27fb3e-0f60-68e1-dbba-f17c3d91c332@embedded-brains.de> <20191002140040.GA44691@kib.kiev.ua> <20191003013314.O2151@besplex.bde.org> <20191002163946.GE44691@kib.kiev.ua> <20191003030837.C2787@besplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Oct 03, 2019 at 03:12:26AM +1000, Bruce Evans wrote:
> On Wed, 2 Oct 2019, Konstantin Belousov wrote:
> 
> > On Thu, Oct 03, 2019 at 02:25:46AM +1000, Bruce Evans wrote:
> >> On Wed, 2 Oct 2019, Konstantin Belousov wrote:
> > So the conclusion is that the second call can be removed, am I right ?
> 
> Yes.
> 
> All tc_get_timecount() functions should be checked for doing sufficient
> initialization in one call (so that deltas for subsequent calls are
> correct).

This should be it.

But, is even a single call to tc_get_timecount() needed for "warmup" ?

diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c
index 382d139617d..28d0d738a58 100644
--- a/sys/dev/acpica/acpi.c
+++ b/sys/dev/acpica/acpi.c
@@ -3191,7 +3191,6 @@ acpi_resync_clock(struct acpi_softc *sc)
      * Warm up timecounter again and reset system clock.
      */
     (void)timecounter->tc_get_timecount(timecounter);
-    (void)timecounter->tc_get_timecount(timecounter);
     inittodr(time_second + sc->acpi_sleep_delay);
 }
 
diff --git a/sys/dev/acpica/acpi_timer.c b/sys/dev/acpica/acpi_timer.c
index 34a832089a2..d768397a785 100644
--- a/sys/dev/acpica/acpi_timer.c
+++ b/sys/dev/acpica/acpi_timer.c
@@ -274,7 +274,6 @@ acpi_timer_resume_handler(struct timecounter *newtc)
 			    "restoring timecounter, %s -> %s\n",
 			    tc->tc_name, newtc->tc_name);
 		(void)newtc->tc_get_timecount(newtc);
-		(void)newtc->tc_get_timecount(newtc);
 		timecounter = newtc;
 	}
 }
diff --git a/sys/dev/xen/control/control.c b/sys/dev/xen/control/control.c
index 98ab5bf3a6b..1e132f4d866 100644
--- a/sys/dev/xen/control/control.c
+++ b/sys/dev/xen/control/control.c
@@ -303,7 +303,6 @@ xctrl_suspend()
 	 * Warm up timecounter again and reset system clock.
 	 */
 	timecounter->tc_get_timecount(timecounter);
-	timecounter->tc_get_timecount(timecounter);
 	inittodr(time_second);
 
 #ifdef EARLY_AP_STARTUP
diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c
index 9920a9a9304..847fbbbf35d 100644
--- a/sys/kern/kern_tc.c
+++ b/sys/kern/kern_tc.c
@@ -1257,7 +1257,6 @@ tc_init(struct timecounter *tc)
 	    tc->tc_frequency < timecounter->tc_frequency)
 		return;
 	(void)tc->tc_get_timecount(tc);
-	(void)tc->tc_get_timecount(tc);
 	timecounter = tc;
 }
 
@@ -1519,7 +1518,6 @@ sysctl_kern_timecounter_hardware(SYSCTL_HANDLER_ARGS)
 
 		/* Warm up new timecounter. */
 		(void)newtc->tc_get_timecount(newtc);
-		(void)newtc->tc_get_timecount(newtc);
 
 		timecounter = newtc;
 
@@ -2011,7 +2009,6 @@ inittimecounter(void *dummy)
 
 	/* warm up new timecounter (again) and get rolling. */
 	(void)timecounter->tc_get_timecount(timecounter);
-	(void)timecounter->tc_get_timecount(timecounter);
 	mtx_lock_spin(&tc_setclock_mtx);
 	tc_windup(NULL);
 	mtx_unlock_spin(&tc_setclock_mtx);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20191003084021.GI44691>