[rtems commit] timecounter: Initialize tc_lock earlier

Sebastian Huber sebh at rtems.org
Mon Feb 21 13:14:59 UTC 2022


Module:    rtems
Branch:    master
Commit:    ede2278d8d7c3fe436ec9b4b94d82e23f21d984e
Changeset: http://git.rtems.org/rtems/commit/?id=ede2278d8d7c3fe436ec9b4b94d82e23f21d984e

Author:    Mark Johnston <markj at FreeBSD.org>
Date:      Fri Nov 19 17:29:28 2021 -0500

timecounter: Initialize tc_lock earlier

Hyper-V wants to register its MSR-based timecounter during
SI_SUB_HYPERVISOR, before SI_SUB_LOCK, since an emulated 8254 may not be
available for DELAY().  So we cannot use MTX_SYSINIT to initialize the
timecounter lock.

PR:		259878
Reviewed by:	kib
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33014

---

 cpukit/score/src/kern_tc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/cpukit/score/src/kern_tc.c b/cpukit/score/src/kern_tc.c
index ea7d9ec..c0f67df 100644
--- a/cpukit/score/src/kern_tc.c
+++ b/cpukit/score/src/kern_tc.c
@@ -219,7 +219,6 @@ static struct timecounter *timecounters = &dummy_timecounter;
 
 /* Mutex to protect the timecounter list. */
 static struct mtx tc_lock;
-MTX_SYSINIT(tc_lock, &tc_lock, "tc", MTX_DEF);
 
 int tc_min_ticktock_freq = 1;
 #else /* __rtems__ */
@@ -2378,6 +2377,8 @@ inittimehands(void *dummy)
 
 	TUNABLE_STR_FETCH("kern.timecounter.hardware", tc_from_tunable,
 	    sizeof(tc_from_tunable));
+
+	mtx_init(&tc_lock, "tc", NULL, MTX_DEF);
 }
 SYSINIT(timehands, SI_SUB_TUNABLES, SI_ORDER_ANY, inittimehands, NULL);
 



More information about the vc mailing list