From owner-svn-src-all@freebsd.org Wed Sep 21 10:15:09 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A80E3BE3BFF; Wed, 21 Sep 2016 10:15:09 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 74E54F56; Wed, 21 Sep 2016 10:15:09 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u8LAF8eO093689; Wed, 21 Sep 2016 10:15:08 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u8LAF8PS093687; Wed, 21 Sep 2016 10:15:08 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201609211015.u8LAF8PS093687@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 21 Sep 2016 10:15:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r306089 - in head/sys: kern sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Sep 2016 10:15:09 -0000 Author: kib Date: Wed Sep 21 10:15:08 2016 New Revision: 306089 URL: https://svnweb.freebsd.org/changeset/base/306089 Log: 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 Modified: head/sys/kern/subr_rtc.c head/sys/sys/clock.h Modified: head/sys/kern/subr_rtc.c ============================================================================== --- head/sys/kern/subr_rtc.c Wed Sep 21 10:10:36 2016 (r306088) +++ head/sys/kern/subr_rtc.c Wed Sep 21 10:15:08 2016 (r306089) @@ -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); Modified: head/sys/sys/clock.h ============================================================================== --- head/sys/sys/clock.h Wed Sep 21 10:10:36 2016 (r306088) +++ head/sys/sys/clock.h Wed Sep 21 10:15:08 2016 (r306089) @@ -54,6 +54,7 @@ */ extern int tz_minuteswest; extern int tz_dsttime; +extern struct mtx resettodr_lock; int utc_offset(void);