diff options
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/alpha/alpha/mutex.c | 4 | ||||
-rw-r--r-- | sys/arch/alpha/include/mutex.h | 21 |
2 files changed, 20 insertions, 5 deletions
diff --git a/sys/arch/alpha/alpha/mutex.c b/sys/arch/alpha/alpha/mutex.c index a1b8c471653..b10d89b2584 100644 --- a/sys/arch/alpha/alpha/mutex.c +++ b/sys/arch/alpha/alpha/mutex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mutex.c,v 1.10 2014/02/01 21:23:10 miod Exp $ */ +/* $OpenBSD: mutex.c,v 1.11 2014/03/18 21:09:28 kettenis Exp $ */ /* * Copyright (c) 2004 Artur Grabowski <art@openbsd.org> @@ -64,7 +64,7 @@ try_lock(struct mutex *mtx) } void -mtx_init(struct mutex *mtx, int wantipl) +__mtx_init(struct mutex *mtx, int wantipl) { mtx->mtx_oldipl = IPL_NONE; mtx->mtx_wantipl = wantipl; diff --git a/sys/arch/alpha/include/mutex.h b/sys/arch/alpha/include/mutex.h index 88a8cc95112..a4aeca3c63d 100644 --- a/sys/arch/alpha/include/mutex.h +++ b/sys/arch/alpha/include/mutex.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mutex.h,v 1.5 2014/01/28 22:04:07 miod Exp $ */ +/* $OpenBSD: mutex.h,v 1.6 2014/03/18 21:09:28 kettenis Exp $ */ /* * Copyright (c) 2004 Artur Grabowski <art@openbsd.org> @@ -35,9 +35,24 @@ struct mutex { void *mtx_owner; }; -void mtx_init(struct mutex *, int); +/* + * To prevent lock ordering problems with the kernel lock, we need to + * make sure we block all interrupts that can grab the kernel lock. + * The simplest way to achieve this is to make sure mutexes always + * raise the interrupt priority level to the highest level that has + * interrupts that grab the kernel lock. + */ +#ifdef MULTIPROCESSOR +#define __MUTEX_IPL(ipl) \ + (((ipl) > IPL_NONE && (ipl) < IPL_AUDIO) ? IPL_AUDIO : (ipl)) +#else +#define __MUTEX_IPL(ipl) (ipl) +#endif + +#define MUTEX_INITIALIZER(ipl) { 0, __MUTEX_IPL((ipl)), IPL_NONE, NULL } -#define MUTEX_INITIALIZER(ipl) { 0, (ipl), IPL_NONE, NULL } +void __mtx_init(struct mutex *, int); +#define mtx_init(mtx, ipl) __mtx_init((mtx), __MUTEX_IPL((ipl))) #ifdef DIAGNOSTIC #ifdef MULTIPROCESSOR |