Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | |
| 2 | /****************************************************************************** |
| 3 | * |
| 4 | * Module Name: exmutex - ASL Mutex Acquire/Release functions |
| 5 | * |
| 6 | *****************************************************************************/ |
| 7 | |
| 8 | /* |
| 9 | * Copyright (C) 2000 - 2005, R. Byron Moore |
| 10 | * All rights reserved. |
| 11 | * |
| 12 | * Redistribution and use in source and binary forms, with or without |
| 13 | * modification, are permitted provided that the following conditions |
| 14 | * are met: |
| 15 | * 1. Redistributions of source code must retain the above copyright |
| 16 | * notice, this list of conditions, and the following disclaimer, |
| 17 | * without modification. |
| 18 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer |
| 19 | * substantially similar to the "NO WARRANTY" disclaimer below |
| 20 | * ("Disclaimer") and any redistribution must be conditioned upon |
| 21 | * including a substantially similar Disclaimer requirement for further |
| 22 | * binary redistribution. |
| 23 | * 3. Neither the names of the above-listed copyright holders nor the names |
| 24 | * of any contributors may be used to endorse or promote products derived |
| 25 | * from this software without specific prior written permission. |
| 26 | * |
| 27 | * Alternatively, this software may be distributed under the terms of the |
| 28 | * GNU General Public License ("GPL") version 2 as published by the Free |
| 29 | * Software Foundation. |
| 30 | * |
| 31 | * NO WARRANTY |
| 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 33 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 34 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR |
| 35 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 36 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 37 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 38 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 39 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 40 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
| 41 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 42 | * POSSIBILITY OF SUCH DAMAGES. |
| 43 | */ |
| 44 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | #include <acpi/acpi.h> |
| 46 | #include <acpi/acinterp.h> |
| 47 | |
| 48 | #define _COMPONENT ACPI_EXECUTER |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 49 | ACPI_MODULE_NAME("exmutex") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 51 | /* Local prototypes */ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 52 | static void |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 53 | acpi_ex_link_mutex(union acpi_operand_object *obj_desc, |
| 54 | struct acpi_thread_state *thread); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | |
| 56 | /******************************************************************************* |
| 57 | * |
| 58 | * FUNCTION: acpi_ex_unlink_mutex |
| 59 | * |
| 60 | * PARAMETERS: obj_desc - The mutex to be unlinked |
| 61 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 62 | * RETURN: None |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | * |
| 64 | * DESCRIPTION: Remove a mutex from the "acquired_mutex" list |
| 65 | * |
| 66 | ******************************************************************************/ |
| 67 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 68 | void acpi_ex_unlink_mutex(union acpi_operand_object *obj_desc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 70 | struct acpi_thread_state *thread = obj_desc->mutex.owner_thread; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | |
| 72 | if (!thread) { |
| 73 | return; |
| 74 | } |
| 75 | |
| 76 | /* Doubly linked list */ |
| 77 | |
| 78 | if (obj_desc->mutex.next) { |
| 79 | (obj_desc->mutex.next)->mutex.prev = obj_desc->mutex.prev; |
| 80 | } |
| 81 | |
| 82 | if (obj_desc->mutex.prev) { |
| 83 | (obj_desc->mutex.prev)->mutex.next = obj_desc->mutex.next; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 84 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | thread->acquired_mutex_list = obj_desc->mutex.next; |
| 86 | } |
| 87 | } |
| 88 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | /******************************************************************************* |
| 90 | * |
| 91 | * FUNCTION: acpi_ex_link_mutex |
| 92 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 93 | * PARAMETERS: obj_desc - The mutex to be linked |
| 94 | * Thread - Current executing thread object |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 96 | * RETURN: None |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | * |
| 98 | * DESCRIPTION: Add a mutex to the "acquired_mutex" list for this walk |
| 99 | * |
| 100 | ******************************************************************************/ |
| 101 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 102 | static void |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 103 | acpi_ex_link_mutex(union acpi_operand_object *obj_desc, |
| 104 | struct acpi_thread_state *thread) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 106 | union acpi_operand_object *list_head; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | |
| 108 | list_head = thread->acquired_mutex_list; |
| 109 | |
| 110 | /* This object will be the first object in the list */ |
| 111 | |
| 112 | obj_desc->mutex.prev = NULL; |
| 113 | obj_desc->mutex.next = list_head; |
| 114 | |
| 115 | /* Update old first object to point back to this object */ |
| 116 | |
| 117 | if (list_head) { |
| 118 | list_head->mutex.prev = obj_desc; |
| 119 | } |
| 120 | |
| 121 | /* Update list head */ |
| 122 | |
| 123 | thread->acquired_mutex_list = obj_desc; |
| 124 | } |
| 125 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | /******************************************************************************* |
| 127 | * |
| 128 | * FUNCTION: acpi_ex_acquire_mutex |
| 129 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 130 | * PARAMETERS: time_desc - Timeout integer |
| 131 | * obj_desc - Mutex object |
| 132 | * walk_state - Current method execution state |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | * |
| 134 | * RETURN: Status |
| 135 | * |
| 136 | * DESCRIPTION: Acquire an AML mutex |
| 137 | * |
| 138 | ******************************************************************************/ |
| 139 | |
| 140 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 141 | acpi_ex_acquire_mutex(union acpi_operand_object *time_desc, |
| 142 | union acpi_operand_object *obj_desc, |
| 143 | struct acpi_walk_state *walk_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 145 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 147 | ACPI_FUNCTION_TRACE_PTR("ex_acquire_mutex", obj_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | |
| 149 | if (!obj_desc) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 150 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | /* Sanity check -- we must have a valid thread ID */ |
| 154 | |
| 155 | if (!walk_state->thread) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 156 | ACPI_REPORT_ERROR(("Cannot acquire Mutex [%4.4s], null thread info\n", acpi_ut_get_node_name(obj_desc->mutex.node))); |
| 157 | return_ACPI_STATUS(AE_AML_INTERNAL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | } |
| 159 | |
| 160 | /* |
| 161 | * Current Sync must be less than or equal to the sync level of the |
| 162 | * mutex. This mechanism provides some deadlock prevention |
| 163 | */ |
| 164 | if (walk_state->thread->current_sync_level > obj_desc->mutex.sync_level) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 165 | ACPI_REPORT_ERROR(("Cannot acquire Mutex [%4.4s], incorrect sync_level\n", acpi_ut_get_node_name(obj_desc->mutex.node))); |
| 166 | return_ACPI_STATUS(AE_AML_MUTEX_ORDER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | } |
| 168 | |
| 169 | /* Support for multiple acquires by the owning thread */ |
| 170 | |
| 171 | if (obj_desc->mutex.owner_thread) { |
| 172 | /* Special case for Global Lock, allow all threads */ |
| 173 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 174 | if ((obj_desc->mutex.owner_thread->thread_id == |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 175 | walk_state->thread->thread_id) || |
| 176 | (obj_desc->mutex.semaphore == |
| 177 | acpi_gbl_global_lock_semaphore)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | /* |
| 179 | * The mutex is already owned by this thread, |
| 180 | * just increment the acquisition depth |
| 181 | */ |
| 182 | obj_desc->mutex.acquisition_depth++; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 183 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | } |
| 185 | } |
| 186 | |
| 187 | /* Acquire the mutex, wait if necessary */ |
| 188 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 189 | status = acpi_ex_system_acquire_mutex(time_desc, obj_desc); |
| 190 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 | /* Includes failure from a timeout on time_desc */ |
| 192 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 193 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | } |
| 195 | |
| 196 | /* Have the mutex: update mutex and walk info and save the sync_level */ |
| 197 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 198 | obj_desc->mutex.owner_thread = walk_state->thread; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | obj_desc->mutex.acquisition_depth = 1; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 200 | obj_desc->mutex.original_sync_level = |
| 201 | walk_state->thread->current_sync_level; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | |
| 203 | walk_state->thread->current_sync_level = obj_desc->mutex.sync_level; |
| 204 | |
| 205 | /* Link the mutex to the current thread for force-unlock at method exit */ |
| 206 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 207 | acpi_ex_link_mutex(obj_desc, walk_state->thread); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 209 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 | } |
| 211 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | /******************************************************************************* |
| 213 | * |
| 214 | * FUNCTION: acpi_ex_release_mutex |
| 215 | * |
| 216 | * PARAMETERS: obj_desc - The object descriptor for this op |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 217 | * walk_state - Current method execution state |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | * |
| 219 | * RETURN: Status |
| 220 | * |
| 221 | * DESCRIPTION: Release a previously acquired Mutex. |
| 222 | * |
| 223 | ******************************************************************************/ |
| 224 | |
| 225 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 226 | acpi_ex_release_mutex(union acpi_operand_object *obj_desc, |
| 227 | struct acpi_walk_state *walk_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 229 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 231 | ACPI_FUNCTION_TRACE("ex_release_mutex"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | |
| 233 | if (!obj_desc) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 234 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | } |
| 236 | |
| 237 | /* The mutex must have been previously acquired in order to release it */ |
| 238 | |
| 239 | if (!obj_desc->mutex.owner_thread) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 240 | ACPI_REPORT_ERROR(("Cannot release Mutex [%4.4s], not acquired\n", acpi_ut_get_node_name(obj_desc->mutex.node))); |
| 241 | return_ACPI_STATUS(AE_AML_MUTEX_NOT_ACQUIRED); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | /* Sanity check -- we must have a valid thread ID */ |
| 245 | |
| 246 | if (!walk_state->thread) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 247 | ACPI_REPORT_ERROR(("Cannot release Mutex [%4.4s], null thread info\n", acpi_ut_get_node_name(obj_desc->mutex.node))); |
| 248 | return_ACPI_STATUS(AE_AML_INTERNAL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | /* |
| 252 | * The Mutex is owned, but this thread must be the owner. |
| 253 | * Special case for Global Lock, any thread can release |
| 254 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 255 | if ((obj_desc->mutex.owner_thread->thread_id != |
| 256 | walk_state->thread->thread_id) |
| 257 | && (obj_desc->mutex.semaphore != acpi_gbl_global_lock_semaphore)) { |
| 258 | ACPI_REPORT_ERROR(("Thread %X cannot release Mutex [%4.4s] acquired by thread %X\n", walk_state->thread->thread_id, acpi_ut_get_node_name(obj_desc->mutex.node), obj_desc->mutex.owner_thread->thread_id)); |
| 259 | return_ACPI_STATUS(AE_AML_NOT_OWNER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | } |
| 261 | |
| 262 | /* |
| 263 | * The sync level of the mutex must be less than or |
| 264 | * equal to the current sync level |
| 265 | */ |
| 266 | if (obj_desc->mutex.sync_level > walk_state->thread->current_sync_level) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 267 | ACPI_REPORT_ERROR(("Cannot release Mutex [%4.4s], incorrect sync_level\n", acpi_ut_get_node_name(obj_desc->mutex.node))); |
| 268 | return_ACPI_STATUS(AE_AML_MUTEX_ORDER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | } |
| 270 | |
| 271 | /* Match multiple Acquires with multiple Releases */ |
| 272 | |
| 273 | obj_desc->mutex.acquisition_depth--; |
| 274 | if (obj_desc->mutex.acquisition_depth != 0) { |
| 275 | /* Just decrement the depth and return */ |
| 276 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 277 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | /* Unlink the mutex from the owner's list */ |
| 281 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 282 | acpi_ex_unlink_mutex(obj_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | |
| 284 | /* Release the mutex */ |
| 285 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 286 | status = acpi_ex_system_release_mutex(obj_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | |
| 288 | /* Update the mutex and walk state, restore sync_level before acquire */ |
| 289 | |
| 290 | obj_desc->mutex.owner_thread = NULL; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 291 | walk_state->thread->current_sync_level = |
| 292 | obj_desc->mutex.original_sync_level; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 293 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 294 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | } |
| 296 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | /******************************************************************************* |
| 298 | * |
| 299 | * FUNCTION: acpi_ex_release_all_mutexes |
| 300 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 301 | * PARAMETERS: Thread - Current executing thread object |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | * |
| 303 | * RETURN: Status |
| 304 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 305 | * DESCRIPTION: Release all mutexes held by this thread |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | * |
| 307 | ******************************************************************************/ |
| 308 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 309 | void acpi_ex_release_all_mutexes(struct acpi_thread_state *thread) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 311 | union acpi_operand_object *next = thread->acquired_mutex_list; |
| 312 | union acpi_operand_object *this; |
| 313 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 315 | ACPI_FUNCTION_ENTRY(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | |
| 317 | /* Traverse the list of owned mutexes, releasing each one */ |
| 318 | |
| 319 | while (next) { |
| 320 | this = next; |
| 321 | next = this->mutex.next; |
| 322 | |
| 323 | this->mutex.acquisition_depth = 1; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 324 | this->mutex.prev = NULL; |
| 325 | this->mutex.next = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 327 | /* Release the mutex */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 328 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 329 | status = acpi_ex_system_release_mutex(this); |
| 330 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | continue; |
| 332 | } |
| 333 | |
| 334 | /* Mark mutex unowned */ |
| 335 | |
| 336 | this->mutex.owner_thread = NULL; |
| 337 | |
| 338 | /* Update Thread sync_level (Last mutex is the important one) */ |
| 339 | |
| 340 | thread->current_sync_level = this->mutex.original_sync_level; |
| 341 | } |
| 342 | } |