Make resettodr_lock accessible outside subr_rtc.c. Protect

CLOCK_GETTIME() with the lock.

Now all time-related accesses to the CMOS for RTC should be under the
lock.  This is needed to allow upcoming EFI Runtime Services support
to provide required execution environment for the firmware calls.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
This commit is contained in:
Konstantin Belousov 2016-09-21 10:15:08 +00:00
parent c1538a1365
commit 851194715d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=306089
2 changed files with 4 additions and 1 deletions

View File

@ -75,7 +75,7 @@ __FBSDID("$FreeBSD$");
static device_t clock_dev = NULL;
static long clock_res;
static struct timespec clock_adj;
static struct mtx resettodr_lock;
struct mtx resettodr_lock;
MTX_SYSINIT(resettodr_init, &resettodr_lock, "tod2rl", MTX_DEF);
/* XXX: should be kern. now, it's no longer machdep. */
@ -132,7 +132,9 @@ inittodr(time_t base)
goto wrong_time;
}
/* XXX: We should poll all registered RTCs in case of failure */
mtx_lock(&resettodr_lock);
error = CLOCK_GETTIME(clock_dev, &ts);
mtx_unlock(&resettodr_lock);
if (error != 0 && error != EINVAL) {
printf("warning: clock_gettime failed (%d), the system time "
"will not be set accurately\n", error);

View File

@ -54,6 +54,7 @@
*/
extern int tz_minuteswest;
extern int tz_dsttime;
extern struct mtx resettodr_lock;
int utc_offset(void);