svn commit: r330780 - in head/sys: amd64/include isa x86/isa
Ian Lepore
ian at FreeBSD.org
Sun Mar 11 19:23:00 UTC 2018
Author: ian
Date: Sun Mar 11 19:22:58 2018
New Revision: 330780
URL: https://svnweb.freebsd.org/changeset/base/330780
Log:
Eliminate atrtc_time_lock, and use atrtc_lock for efirtc locking.
Modified:
head/sys/amd64/include/efi.h
head/sys/isa/rtc.h
head/sys/x86/isa/atrtc.c
Modified: head/sys/amd64/include/efi.h
==============================================================================
--- head/sys/amd64/include/efi.h Sun Mar 11 19:14:01 2018 (r330779)
+++ head/sys/amd64/include/efi.h Sun Mar 11 19:22:58 2018 (r330780)
@@ -48,9 +48,9 @@
#ifdef _KERNEL
#include <isa/rtc.h>
-#define EFI_TIME_LOCK() mtx_lock(&atrtc_time_lock);
-#define EFI_TIME_UNLOCK() mtx_unlock(&atrtc_time_lock);
-#define EFI_TIME_OWNED() mtx_assert(&atrtc_time_lock, MA_OWNED);
+#define EFI_TIME_LOCK() mtx_lock_spin(&atrtc_lock);
+#define EFI_TIME_UNLOCK() mtx_unlock_spin(&atrtc_lock);
+#define EFI_TIME_OWNED() mtx_assert(&atrtc_lock, MA_OWNED);
#endif
#endif /* __AMD64_INCLUDE_EFI_H_ */
Modified: head/sys/isa/rtc.h
==============================================================================
--- head/sys/isa/rtc.h Sun Mar 11 19:14:01 2018 (r330779)
+++ head/sys/isa/rtc.h Sun Mar 11 19:22:58 2018 (r330780)
@@ -114,7 +114,7 @@
#define RTC_CENTURY 0x32 /* current century */
#ifdef _KERNEL
-extern struct mtx atrtc_time_lock;
+extern struct mtx atrtc_lock;
extern int atrtcclock_disable;
int rtcin(int reg);
void atrtc_restore(void);
Modified: head/sys/x86/isa/atrtc.c
==============================================================================
--- head/sys/x86/isa/atrtc.c Sun Mar 11 19:14:01 2018 (r330779)
+++ head/sys/x86/isa/atrtc.c Sun Mar 11 19:22:58 2018 (r330780)
@@ -56,16 +56,15 @@ __FBSDID("$FreeBSD$");
#include "clock_if.h"
/*
- * atrtc_lock protects low-level access to individual hardware registers.
- * atrtc_time_lock protects the entire sequence of accessing multiple registers
- * to read or write the date and time.
+ * atrtc_lock protects access to the RTC ioports, which are accessed by this
+ * driver, the nvram(4) driver (via rtcin()/writertc() calls), and the rtc code
+ * in efi runtime services. The efirt wrapper code directly locks atrtc lock
+ * using the EFI_TIME_LOCK/UNLOCK() macros which are defined to use this mutex
+ * on x86 platforms.
*/
-static struct mtx atrtc_lock;
+struct mtx atrtc_lock;
MTX_SYSINIT(atrtc_lock_init, &atrtc_lock, "atrtc", MTX_SPIN | MTX_NOPROFILE);
-struct mtx atrtc_time_lock;
-MTX_SYSINIT(atrtc_time_lock_init, &atrtc_time_lock, "atrtc", MTX_DEF);
-
int atrtcclock_disable = 0;
static int rtc_reg = -1;
@@ -328,7 +327,6 @@ atrtc_settime(device_t dev __unused, struct timespec *
clock_ts_to_bcd(ts, &bct, false);
clock_dbgprint_bcd(dev, CLOCK_DBG_WRITE, &bct);
- mtx_lock(&atrtc_time_lock);
mtx_lock_spin(&atrtc_lock);
/* Disable RTC updates and interrupts. */
@@ -353,7 +351,6 @@ atrtc_settime(device_t dev __unused, struct timespec *
rtcin_locked(RTC_INTR);
mtx_unlock_spin(&atrtc_lock);
- mtx_unlock(&atrtc_time_lock);
return (0);
}
@@ -376,7 +373,6 @@ atrtc_gettime(device_t dev, struct timespec *ts)
* to make sure that no more than 240us pass after we start reading,
* and try again if so.
*/
- mtx_lock(&atrtc_time_lock);
while (rtcin(RTC_STATUSA) & RTCSA_TUP)
continue;
mtx_lock_spin(&atrtc_lock);
@@ -390,7 +386,6 @@ atrtc_gettime(device_t dev, struct timespec *ts)
bct.year |= rtcin_locked(RTC_CENTURY) << 8;
#endif
mtx_unlock_spin(&atrtc_lock);
- mtx_unlock(&atrtc_time_lock);
/* dow is unused in timespec conversion and we have no nsec info. */
bct.dow = 0;
bct.nsec = 0;
More information about the svn-src-all
mailing list