On Sun, Mar 11, 2018 at 07:22:58PM +0000, Ian Lepore wrote:
> 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);

I do not understand how this can work. You changed EFI_TIME_LOCK() to
spinlock.  As result, the spinlock is taken before efi_enter() is called.
efi_enter() locks the pmap and efi_lock, both of which are sleepable
mutexes.  Also, arch efirt code is allowed to take arch-specific
sleepable mutexes and perhaps some spinlocks (but currently does not).

The first context switch when either of the listed sleepable mutexes
are contested and the thread is taken off CPU would panic.  I suspect
that some invariants check might fire earlier.
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to