Use separate mutexes for atrtc and i8254 locking. Change all the strange
un-function-like RTC_LOCK/UNLOCK macro usage into normal function calls. Since there is no longer any need to handle register access from a debugger context, those function calls can just be regular mutex lock/unlock calls. Requested by: bde
This commit is contained in:
parent
1629f3ec27
commit
95221efb08
@ -114,7 +114,6 @@
|
||||
#define RTC_CENTURY 0x32 /* current century */
|
||||
|
||||
#ifdef _KERNEL
|
||||
extern struct mtx clock_lock;
|
||||
extern struct mtx atrtc_time_lock;
|
||||
extern int atrtcclock_disable;
|
||||
int rtcin(int reg);
|
||||
|
@ -56,15 +56,15 @@ __FBSDID("$FreeBSD$");
|
||||
#include "clock_if.h"
|
||||
|
||||
/*
|
||||
* clock_lock protects low-level access to individual hardware registers.
|
||||
* 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.
|
||||
*/
|
||||
#define RTC_LOCK do { if (!kdb_active) mtx_lock_spin(&clock_lock); } while (0)
|
||||
#define RTC_UNLOCK do { if (!kdb_active) mtx_unlock_spin(&clock_lock); } while (0)
|
||||
static struct mtx atrtc_lock;
|
||||
MTX_SYSINIT(atrtc_lock_init, &atrtc_lock, "atrtc", MTX_SPIN | MTX_NOPROFILE);
|
||||
|
||||
struct mtx atrtc_time_lock;
|
||||
MTX_SYSINIT(atrtc_lock_init, &atrtc_time_lock, "atrtc", MTX_DEF);
|
||||
MTX_SYSINIT(atrtc_time_lock_init, &atrtc_time_lock, "atrtc", MTX_DEF);
|
||||
|
||||
int atrtcclock_disable = 0;
|
||||
|
||||
@ -108,9 +108,9 @@ rtcin(int reg)
|
||||
{
|
||||
u_char val;
|
||||
|
||||
RTC_LOCK;
|
||||
mtx_lock_spin(&atrtc_lock);
|
||||
val = rtcin_locked(reg);
|
||||
RTC_UNLOCK;
|
||||
mtx_unlock_spin(&atrtc_lock);
|
||||
return (val);
|
||||
}
|
||||
|
||||
@ -118,9 +118,9 @@ void
|
||||
writertc(int reg, u_char val)
|
||||
{
|
||||
|
||||
RTC_LOCK;
|
||||
mtx_lock_spin(&atrtc_lock);
|
||||
rtcout_locked(reg, val);
|
||||
RTC_UNLOCK;
|
||||
mtx_unlock_spin(&atrtc_lock);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -321,7 +321,7 @@ atrtc_settime(device_t dev __unused, struct timespec *ts)
|
||||
clock_dbgprint_bcd(dev, CLOCK_DBG_WRITE, &bct);
|
||||
|
||||
mtx_lock(&atrtc_time_lock);
|
||||
RTC_LOCK;
|
||||
mtx_lock_spin(&atrtc_lock);
|
||||
|
||||
/* Disable RTC updates and interrupts. */
|
||||
rtcout_locked(RTC_STATUSB, RTCSB_HALT | RTCSB_24HR);
|
||||
@ -344,7 +344,7 @@ atrtc_settime(device_t dev __unused, struct timespec *ts)
|
||||
rtcout_locked(RTC_STATUSB, rtc_statusb);
|
||||
rtcin_locked(RTC_INTR);
|
||||
|
||||
RTC_UNLOCK;
|
||||
mtx_unlock_spin(&atrtc_lock);
|
||||
mtx_unlock(&atrtc_time_lock);
|
||||
|
||||
return (0);
|
||||
@ -371,7 +371,7 @@ atrtc_gettime(device_t dev, struct timespec *ts)
|
||||
mtx_lock(&atrtc_time_lock);
|
||||
while (rtcin(RTC_STATUSA) & RTCSA_TUP)
|
||||
continue;
|
||||
RTC_LOCK;
|
||||
mtx_lock_spin(&atrtc_lock);
|
||||
bct.sec = rtcin_locked(RTC_SEC);
|
||||
bct.min = rtcin_locked(RTC_MIN);
|
||||
bct.hour = rtcin_locked(RTC_HRS);
|
||||
@ -381,7 +381,7 @@ atrtc_gettime(device_t dev, struct timespec *ts)
|
||||
#ifdef USE_RTC_CENTURY
|
||||
bct.year |= rtcin_locked(RTC_CENTURY) << 8;
|
||||
#endif
|
||||
RTC_UNLOCK;
|
||||
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;
|
||||
|
@ -83,7 +83,7 @@ TUNABLE_INT("hw.i8254.freq", &i8254_freq);
|
||||
int i8254_max_count;
|
||||
static int i8254_timecounter = 1;
|
||||
|
||||
struct mtx clock_lock;
|
||||
static struct mtx clock_lock;
|
||||
static struct intsrc *i8254_intsrc;
|
||||
static uint16_t i8254_lastcount;
|
||||
static uint16_t i8254_offset;
|
||||
|
Loading…
x
Reference in New Issue
Block a user