summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Lepore <ian@FreeBSD.org>2015-08-12 20:50:20 +0000
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-10-12 07:04:10 +0200
commitf1463c8bdd6c967501365ca37e662d763864167b (patch)
tree7f1d291321a6b25e8cacff1c045976f34a117b13
parenttimecounter: Merge FreeBSD change r286429 (diff)
downloadrtems-f1463c8bdd6c967501365ca37e662d763864167b.tar.bz2
timecounter: Merge FreeBSD change r286701
If a specific timecounter has been chosen via sysctl, and a new timecounter with higher quality registers (presumably in a module that has just been loaded), do not undo the user's choice by switching to the new timecounter. Document that behavior, and also the fact that there is no way to unregister a timecounter (and thus no way to unload a module containing one). Update #3175.
-rw-r--r--cpukit/score/src/kern_tc.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/cpukit/score/src/kern_tc.c b/cpukit/score/src/kern_tc.c
index bb8a3f110d..e6e952facd 100644
--- a/cpukit/score/src/kern_tc.c
+++ b/cpukit/score/src/kern_tc.c
@@ -242,6 +242,8 @@ SYSCTL_PROC(_kern_timecounter, OID_AUTO, alloweddeviation,
CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, 0, 0,
sysctl_kern_timecounter_adjprecision, "I",
"Allowed time interval deviation in percents");
+
+static int tc_chosen; /* Non-zero if a specific tc was chosen via sysctl. */
#endif /* __rtems__ */
static void tc_windup(void);
@@ -1344,10 +1346,13 @@ tc_init(struct timecounter *tc)
"quality", CTLFLAG_RD, &(tc->tc_quality), 0,
"goodness of time counter");
/*
- * Never automatically use a timecounter with negative quality.
+ * Do not automatically switch if the current tc was specifically
+ * chosen. Never automatically use a timecounter with negative quality.
* Even though we run on the dummy counter, switching here may be
- * worse since this timecounter may not be monotonous.
+ * worse since this timecounter may not be monotonic.
*/
+ if (tc_chosen)
+ return;
if (tc->tc_quality < 0)
return;
if (tc->tc_quality < timecounter->tc_quality)
@@ -1630,9 +1635,12 @@ sysctl_kern_timecounter_hardware(SYSCTL_HANDLER_ARGS)
strlcpy(newname, tc->tc_name, sizeof(newname));
error = sysctl_handle_string(oidp, &newname[0], sizeof(newname), req);
- if (error != 0 || req->newptr == NULL ||
- strcmp(newname, tc->tc_name) == 0)
+ if (error != 0 || req->newptr == NULL)
return (error);
+ /* Record that the tc in use now was specifically chosen. */
+ tc_chosen = 1;
+ if (strcmp(newname, tc->tc_name) == 0)
+ return (0);
for (newtc = timecounters; newtc != NULL; newtc = newtc->tc_next) {
if (strcmp(newname, newtc->tc_name) != 0)
continue;
@@ -1661,7 +1669,7 @@ SYSCTL_PROC(_kern_timecounter, OID_AUTO, hardware, CTLTYPE_STRING | CTLFLAG_RW,
"Timecounter hardware selected");
-/* Report or change the active timecounter hardware. */
+/* Report the available timecounter hardware. */
static int
sysctl_kern_timecounter_choice(SYSCTL_HANDLER_ARGS)
{