| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: ww_mutex.h,v 1.1 2014/07/16 20:59:58 riastradh Exp $ */ | | 1 | /* $NetBSD: ww_mutex.h,v 1.2 2014/07/22 02:38:31 riastradh Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2014 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2014 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Taylor R. Campbell. | | 8 | * by Taylor R. Campbell. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -134,27 +134,31 @@ struct ww_mutex { | | | @@ -134,27 +134,31 @@ struct ww_mutex { |
134 | union { | | 134 | union { |
135 | struct lwp *owner; | | 135 | struct lwp *owner; |
136 | struct ww_acquire_ctx *ctx; | | 136 | struct ww_acquire_ctx *ctx; |
137 | } wwm_u; | | 137 | } wwm_u; |
138 | struct ww_class *wwm_class; | | 138 | struct ww_class *wwm_class; |
139 | struct rb_tree wwm_waiters; | | 139 | struct rb_tree wwm_waiters; |
140 | kcondvar_t wwm_cv; | | 140 | kcondvar_t wwm_cv; |
141 | }; | | 141 | }; |
142 | | | 142 | |
143 | static inline void | | 143 | static inline void |
144 | ww_mutex_init(struct ww_mutex *mutex, struct ww_class *class) | | 144 | ww_mutex_init(struct ww_mutex *mutex, struct ww_class *class) |
145 | { | | 145 | { |
146 | | | 146 | |
147 | mutex_init(&mutex->wwm_lock, MUTEX_DEFAULT, IPL_NONE); | | 147 | /* |
| | | 148 | * XXX Apparently Linux takes these with spin locks held. That |
| | | 149 | * strikes me as a bad idea, but so it is... |
| | | 150 | */ |
| | | 151 | mutex_init(&mutex->wwm_lock, MUTEX_DEFAULT, IPL_VM); |
148 | mutex->wwm_state = WW_UNLOCKED; | | 152 | mutex->wwm_state = WW_UNLOCKED; |
149 | mutex->wwm_class = class; | | 153 | mutex->wwm_class = class; |
150 | rb_tree_init(&mutex->wwm_waiters, &ww_acquire_ctx_rb_ops); | | 154 | rb_tree_init(&mutex->wwm_waiters, &ww_acquire_ctx_rb_ops); |
151 | cv_init(&mutex->wwm_cv, "linuxwwm"); | | 155 | cv_init(&mutex->wwm_cv, "linuxwwm"); |
152 | } | | 156 | } |
153 | | | 157 | |
154 | static inline void | | 158 | static inline void |
155 | ww_mutex_destroy(struct ww_mutex *mutex) | | 159 | ww_mutex_destroy(struct ww_mutex *mutex) |
156 | { | | 160 | { |
157 | | | 161 | |
158 | cv_destroy(&mutex->wwm_cv); | | 162 | cv_destroy(&mutex->wwm_cv); |
159 | #if 0 | | 163 | #if 0 |
160 | rb_tree_destroy(&mutex->wwm_waiters, &ww_acquire_ctx_rb_ops); | | 164 | rb_tree_destroy(&mutex->wwm_waiters, &ww_acquire_ctx_rb_ops); |