Re: svn commit: r330783 - in head/sys: amd64/include isa x86/isa

2018-03-12 Thread Hans Petter Selasky

On 03/11/18 21:13, Ian Lepore wrote:

-struct mtx atrtc_lock;
+static struct mtx atrtc_lock;
  MTX_SYSINIT(atrtc_lock_init, _lock, "atrtc", MTX_SPIN);
  
+struct mtx atrtc_time_lock;

+MTX_SYSINIT(atrtc_time_lock_init, _time_lock, "atrtc", MTX_DEF);


One of my boxes panics now because there are two locks with same name!

I have:
debug.witness.skipspin=0

In /boot/loader.conf.

--HPS
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r330783 - in head/sys: amd64/include isa x86/isa

2018-03-11 Thread Ian Lepore
Author: ian
Date: Sun Mar 11 20:13:15 2018
New Revision: 330783
URL: https://svnweb.freebsd.org/changeset/base/330783

Log:
  Revert r330780, it was improperly tested and results in taking a spin
  mutex before acquiring sleep mutexes.
  
  Reported by:  kib@

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.hSun Mar 11 19:56:07 2018
(r330782)
+++ head/sys/amd64/include/efi.hSun Mar 11 20:13:15 2018
(r330783)
@@ -48,9 +48,9 @@
 #ifdef _KERNEL
 #include 
 
-#defineEFI_TIME_LOCK() mtx_lock_spin(_lock);
-#defineEFI_TIME_UNLOCK()   mtx_unlock_spin(_lock);
-#defineEFI_TIME_OWNED()mtx_assert(_lock, MA_OWNED);
+#defineEFI_TIME_LOCK() mtx_lock(_time_lock);
+#defineEFI_TIME_UNLOCK()   mtx_unlock(_time_lock);
+#defineEFI_TIME_OWNED()mtx_assert(_time_lock, MA_OWNED);
 #endif
 
 #endif /* __AMD64_INCLUDE_EFI_H_ */

Modified: head/sys/isa/rtc.h
==
--- head/sys/isa/rtc.h  Sun Mar 11 19:56:07 2018(r330782)
+++ head/sys/isa/rtc.h  Sun Mar 11 20:13:15 2018(r330783)
@@ -114,7 +114,7 @@
 #defineRTC_CENTURY 0x32/* current century */
 
 #ifdef _KERNEL
-extern  struct mtx atrtc_lock;
+extern  struct mtx atrtc_time_lock;
 extern int atrtcclock_disable;
 intrtcin(int reg);
 void   atrtc_restore(void);

Modified: head/sys/x86/isa/atrtc.c
==
--- head/sys/x86/isa/atrtc.cSun Mar 11 19:56:07 2018(r330782)
+++ head/sys/x86/isa/atrtc.cSun Mar 11 20:13:15 2018(r330783)
@@ -56,15 +56,16 @@ __FBSDID("$FreeBSD$");
 #include "clock_if.h"
 
 /*
- * 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.
+ * 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.
  */
-struct mtx atrtc_lock;
+static struct mtx atrtc_lock;
 MTX_SYSINIT(atrtc_lock_init, _lock, "atrtc", MTX_SPIN);
 
+struct mtx atrtc_time_lock;
+MTX_SYSINIT(atrtc_time_lock_init, _time_lock, "atrtc", MTX_DEF);
+
 intatrtcclock_disable = 0;
 
 static int rtc_reg = -1;
@@ -327,6 +328,7 @@ atrtc_settime(device_t dev __unused, struct timespec *
clock_ts_to_bcd(ts, , false);
clock_dbgprint_bcd(dev, CLOCK_DBG_WRITE, );
 
+   mtx_lock(_time_lock);
mtx_lock_spin(_lock);
 
/* Disable RTC updates and interrupts.  */
@@ -351,6 +353,7 @@ atrtc_settime(device_t dev __unused, struct timespec *
rtcin_locked(RTC_INTR);
 
mtx_unlock_spin(_lock);
+   mtx_unlock(_time_lock);
 
return (0);
 }
@@ -373,6 +376,7 @@ 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(_time_lock);
while (rtcin(RTC_STATUSA) & RTCSA_TUP)
continue;
mtx_lock_spin(_lock);
@@ -386,6 +390,7 @@ atrtc_gettime(device_t dev, struct timespec *ts)
bct.year |= rtcin_locked(RTC_CENTURY) << 8;
 #endif
mtx_unlock_spin(_lock);
+   mtx_unlock(_time_lock);
/* dow is unused in timespec conversion and we have no nsec info. */
bct.dow  = 0;
bct.nsec = 0;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"