diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2014-03-18 21:09:29 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2014-03-18 21:09:29 +0000 |
commit | 7e9918e631c8d89e4daeae75c43b6381c34a8610 (patch) | |
tree | 828ea53b259dc12b6fc1e746df56bf065d315300 /sys/arch/alpha | |
parent | 28ea9822515e909938e264f43480fc6f0e335354 (diff) |
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 ipl to the highest
level that has interrupts that grab the kernel lock. This will allow us
to have "mpsafe" interrupt handlers at lower priority levels.
No change for non-MULTIPROCESSOR kernels.
ok miod@
Diffstat (limited to 'sys/arch/alpha')
-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 |