···125125 if (info->table_desc->pointer->revision == 1) {126126 node->flags |= ANOBJ_DATA_WIDTH_32;127127 }128128-#ifdef ACPI_INIT_PARSE_METHODS129129- /*130130- * Note 11/2005: Removed this code to parse all methods during table131131- * load because it causes problems if there are any errors during the132132- * parse. Also, it seems like overkill and we probably don't want to133133- * abort a table load because of an issue with a single method.134134- */135128136136- /*137137- * Print a dot for each method unless we are going to print138138- * the entire pathname139139- */140140- if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) {141141- ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "."));142142- }143143-144144- /*145145- * Always parse methods to detect errors, we will delete146146- * the parse tree below147147- */148148- status = acpi_ds_parse_method(obj_handle);149149- if (ACPI_FAILURE(status)) {150150- ACPI_ERROR((AE_INFO,151151- "Method %p [%4.4s] - parse failure, %s",152152- obj_handle,153153- acpi_ut_get_node_name(obj_handle),154154- acpi_format_exception(status)));155155-156156- /* This parse failed, but we will continue parsing more methods */157157- }158158-#endif159129 info->method_count++;160130 break;161131
+138-192
drivers/acpi/dispatcher/dsmethod.c
···5252#define _COMPONENT ACPI_DISPATCHER5353ACPI_MODULE_NAME("dsmethod")54545555+/* Local prototypes */5656+static acpi_status5757+acpi_ds_create_method_mutex(union acpi_operand_object *method_desc);5858+5559/*******************************************************************************5660 *5761 * FUNCTION: acpi_ds_method_error···7167 * Note: Allows the exception handler to change the status code7268 *7369 ******************************************************************************/7070+7471acpi_status7572acpi_ds_method_error(acpi_status status, struct acpi_walk_state *walk_state)7673{···118113119114/*******************************************************************************120115 *116116+ * FUNCTION: acpi_ds_create_method_mutex117117+ *118118+ * PARAMETERS: obj_desc - The method object119119+ *120120+ * RETURN: Status121121+ *122122+ * DESCRIPTION: Create a mutex object for a serialized control method123123+ *124124+ ******************************************************************************/125125+126126+static acpi_status127127+acpi_ds_create_method_mutex(union acpi_operand_object *method_desc)128128+{129129+ union acpi_operand_object *mutex_desc;130130+ acpi_status status;131131+132132+ ACPI_FUNCTION_NAME(ds_create_method_mutex);133133+134134+ /* Create the new mutex object */135135+136136+ mutex_desc = acpi_ut_create_internal_object(ACPI_TYPE_MUTEX);137137+ if (!mutex_desc) {138138+ return_ACPI_STATUS(AE_NO_MEMORY);139139+ }140140+141141+ /* Create the actual OS Mutex */142142+143143+ status = acpi_os_create_mutex(&mutex_desc->mutex.os_mutex);144144+ if (ACPI_FAILURE(status)) {145145+ return_ACPI_STATUS(status);146146+ }147147+148148+ mutex_desc->mutex.sync_level = method_desc->method.sync_level;149149+ method_desc->method.mutex = mutex_desc;150150+ return_ACPI_STATUS(AE_OK);151151+}152152+153153+/*******************************************************************************154154+ *121155 * FUNCTION: acpi_ds_begin_method_execution122156 *123157 * PARAMETERS: method_node - Node of the method124158 * obj_desc - The method object125125- * calling_method_node - Caller of this method (if non-null)159159+ * walk_state - current state, NULL if not yet executing160160+ * a method.126161 *127162 * RETURN: Status128163 *···173128 ******************************************************************************/174129175130acpi_status176176-acpi_ds_begin_method_execution(struct acpi_namespace_node * method_node,177177- union acpi_operand_object * obj_desc,178178- struct acpi_namespace_node * calling_method_node)131131+acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node,132132+ union acpi_operand_object *obj_desc,133133+ struct acpi_walk_state *walk_state)179134{180135 acpi_status status = AE_OK;181136···194149 }195150196151 /*197197- * If there is a concurrency limit on this method, we need to198198- * obtain a unit from the method semaphore.152152+ * If this method is serialized, we need to acquire the method mutex.199153 */200200- if (obj_desc->method.semaphore) {154154+ if (obj_desc->method.method_flags & AML_METHOD_SERIALIZED) {201155 /*202202- * Allow recursive method calls, up to the reentrancy/concurrency203203- * limit imposed by the SERIALIZED rule and the sync_level method204204- * parameter.205205- *206206- * The point of this code is to avoid permanently blocking a207207- * thread that is making recursive method calls.156156+ * Create a mutex for the method if it is defined to be Serialized157157+ * and a mutex has not already been created. We defer the mutex creation158158+ * until a method is actually executed, to minimize the object count208159 */209209- if (method_node == calling_method_node) {210210- if (obj_desc->method.thread_count >=211211- obj_desc->method.concurrency) {212212- return_ACPI_STATUS(AE_AML_METHOD_LIMIT);160160+ if (!obj_desc->method.mutex) {161161+ status = acpi_ds_create_method_mutex(obj_desc);162162+ if (ACPI_FAILURE(status)) {163163+ return_ACPI_STATUS(status);213164 }214165 }215166216167 /*217217- * Get a unit from the method semaphore. This releases the218218- * interpreter if we block (then reacquires it)168168+ * The current_sync_level (per-thread) must be less than or equal to169169+ * the sync level of the method. This mechanism provides some170170+ * deadlock prevention171171+ *172172+ * Top-level method invocation has no walk state at this point219173 */220220- status =221221- acpi_ex_system_wait_semaphore(obj_desc->method.semaphore,222222- ACPI_WAIT_FOREVER);223223- if (ACPI_FAILURE(status)) {224224- return_ACPI_STATUS(status);174174+ if (walk_state &&175175+ (walk_state->thread->current_sync_level >176176+ obj_desc->method.mutex->mutex.sync_level)) {177177+ ACPI_ERROR((AE_INFO,178178+ "Cannot acquire Mutex for method [%4.4s], current SyncLevel is too large (%d)",179179+ acpi_ut_get_node_name(method_node),180180+ walk_state->thread->current_sync_level));181181+182182+ return_ACPI_STATUS(AE_AML_MUTEX_ORDER);225183 }184184+185185+ /*186186+ * Obtain the method mutex if necessary. Do not acquire mutex for a187187+ * recursive call.188188+ */189189+ if (!walk_state ||190190+ !obj_desc->method.mutex->mutex.owner_thread ||191191+ (walk_state->thread !=192192+ obj_desc->method.mutex->mutex.owner_thread)) {193193+ /*194194+ * Acquire the method mutex. This releases the interpreter if we195195+ * block (and reacquires it before it returns)196196+ */197197+ status =198198+ acpi_ex_system_wait_mutex(obj_desc->method.mutex->199199+ mutex.os_mutex,200200+ ACPI_WAIT_FOREVER);201201+ if (ACPI_FAILURE(status)) {202202+ return_ACPI_STATUS(status);203203+ }204204+205205+ /* Update the mutex and walk info and save the original sync_level */206206+207207+ if (walk_state) {208208+ obj_desc->method.mutex->mutex.209209+ original_sync_level =210210+ walk_state->thread->current_sync_level;211211+212212+ obj_desc->method.mutex->mutex.owner_thread =213213+ walk_state->thread;214214+ walk_state->thread->current_sync_level =215215+ obj_desc->method.sync_level;216216+ } else {217217+ obj_desc->method.mutex->mutex.218218+ original_sync_level =219219+ obj_desc->method.mutex->mutex.sync_level;220220+ }221221+ }222222+223223+ /* Always increase acquisition depth */224224+225225+ obj_desc->method.mutex->mutex.acquisition_depth++;226226 }227227228228 /*···290200 return_ACPI_STATUS(status);291201292202 cleanup:293293- /* On error, must signal the method semaphore if present */203203+ /* On error, must release the method mutex (if present) */294204295295- if (obj_desc->method.semaphore) {296296- (void)acpi_os_signal_semaphore(obj_desc->method.semaphore, 1);205205+ if (obj_desc->method.mutex) {206206+ acpi_os_release_mutex(obj_desc->method.mutex->mutex.os_mutex);297207 }298208 return_ACPI_STATUS(status);299209}···343253 return_ACPI_STATUS(AE_NULL_OBJECT);344254 }345255346346- /* Init for new method, possibly wait on concurrency semaphore */256256+ /* Init for new method, possibly wait on method mutex */347257348258 status = acpi_ds_begin_method_execution(method_node, obj_desc,349349- this_walk_state->method_node);259259+ this_walk_state);350260 if (ACPI_FAILURE(status)) {351261 return_ACPI_STATUS(status);352262 }···568478 * created, delete all locals and arguments, and delete the parse569479 * tree if requested.570480 *481481+ * MUTEX: Interpreter is locked482482+ *571483 ******************************************************************************/572484573485void···595503 }596504597505 /*598598- * Lock the parser while we terminate this method.599599- * If this is the last thread executing the method,600600- * we have additional cleanup to perform506506+ * If method is serialized, release the mutex and restore the507507+ * current sync level for this thread601508 */602602- status = acpi_ut_acquire_mutex(ACPI_MTX_CONTROL_METHOD);603603- if (ACPI_FAILURE(status)) {604604- return_VOID;605605- }509509+ if (method_desc->method.mutex) {606510607607- /* Signal completion of the execution of this method if necessary */511511+ /* Acquisition Depth handles recursive calls */608512609609- if (method_desc->method.semaphore) {610610- status =611611- acpi_os_signal_semaphore(method_desc->method.semaphore, 1);612612- if (ACPI_FAILURE(status)) {513513+ method_desc->method.mutex->mutex.acquisition_depth--;514514+ if (!method_desc->method.mutex->mutex.acquisition_depth) {515515+ walk_state->thread->current_sync_level =516516+ method_desc->method.mutex->mutex.517517+ original_sync_level;613518614614- /* Ignore error and continue */615615-616616- ACPI_EXCEPTION((AE_INFO, status,617617- "Could not signal method semaphore"));519519+ acpi_os_release_mutex(method_desc->method.mutex->mutex.520520+ os_mutex);618521 }619522 }620523···624537625538 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);626539 if (ACPI_FAILURE(status)) {627627- goto exit;540540+ return_VOID;628541 }629542630543 /*···667580 /*668581 * Support to dynamically change a method from not_serialized to669582 * Serialized if it appears that the method is incorrectly written and670670- * does not support multiple thread execution. The best example of this671671- * is if such a method creates namespace objects and blocks. A second583583+ * does not support multiple thread execution. The best example of this584584+ * is if such a method creates namespace objects and blocks. A second672585 * thread will fail with an AE_ALREADY_EXISTS exception673586 *674587 * This code is here because we must wait until the last thread exits675588 * before creating the synchronization semaphore.676589 */677677- if ((method_desc->method.concurrency == 1) &&678678- (!method_desc->method.semaphore)) {679679- status = acpi_os_create_semaphore(1, 1,680680- &method_desc->method.681681- semaphore);590590+ if ((method_desc->method.method_flags & AML_METHOD_SERIALIZED)591591+ && (!method_desc->method.mutex)) {592592+ status = acpi_ds_create_method_mutex(method_desc);682593 }683594684595 /* No more threads, we can free the owner_id */···684599 acpi_ut_release_owner_id(&method_desc->method.owner_id);685600 }686601687687- exit:688688- (void)acpi_ut_release_mutex(ACPI_MTX_CONTROL_METHOD);689602 return_VOID;690603}691691-692692-#ifdef ACPI_INIT_PARSE_METHODS693693- /*694694- * Note 11/2005: Removed this code to parse all methods during table695695- * load because it causes problems if there are any errors during the696696- * parse. Also, it seems like overkill and we probably don't want to697697- * abort a table load because of an issue with a single method.698698- */699699-700700-/*******************************************************************************701701- *702702- * FUNCTION: acpi_ds_parse_method703703- *704704- * PARAMETERS: Node - Method node705705- *706706- * RETURN: Status707707- *708708- * DESCRIPTION: Parse the AML that is associated with the method.709709- *710710- * MUTEX: Assumes parser is locked711711- *712712- ******************************************************************************/713713-714714-acpi_status acpi_ds_parse_method(struct acpi_namespace_node *node)715715-{716716- acpi_status status;717717- union acpi_operand_object *obj_desc;718718- union acpi_parse_object *op;719719- struct acpi_walk_state *walk_state;720720-721721- ACPI_FUNCTION_TRACE_PTR(ds_parse_method, node);722722-723723- /* Parameter Validation */724724-725725- if (!node) {726726- return_ACPI_STATUS(AE_NULL_ENTRY);727727- }728728-729729- ACPI_DEBUG_PRINT((ACPI_DB_PARSE,730730- "**** Parsing [%4.4s] **** NamedObj=%p\n",731731- acpi_ut_get_node_name(node), node));732732-733733- /* Extract the method object from the method Node */734734-735735- obj_desc = acpi_ns_get_attached_object(node);736736- if (!obj_desc) {737737- return_ACPI_STATUS(AE_NULL_OBJECT);738738- }739739-740740- /* Create a mutex for the method if there is a concurrency limit */741741-742742- if ((obj_desc->method.concurrency != ACPI_INFINITE_CONCURRENCY) &&743743- (!obj_desc->method.semaphore)) {744744- status = acpi_os_create_semaphore(obj_desc->method.concurrency,745745- obj_desc->method.concurrency,746746- &obj_desc->method.semaphore);747747- if (ACPI_FAILURE(status)) {748748- return_ACPI_STATUS(status);749749- }750750- }751751-752752- /*753753- * Allocate a new parser op to be the root of the parsed754754- * method tree755755- */756756- op = acpi_ps_alloc_op(AML_METHOD_OP);757757- if (!op) {758758- return_ACPI_STATUS(AE_NO_MEMORY);759759- }760760-761761- /* Init new op with the method name and pointer back to the Node */762762-763763- acpi_ps_set_name(op, node->name.integer);764764- op->common.node = node;765765-766766- /*767767- * Get a new owner_id for objects created by this method. Namespace768768- * objects (such as Operation Regions) can be created during the769769- * first pass parse.770770- */771771- status = acpi_ut_allocate_owner_id(&obj_desc->method.owner_id);772772- if (ACPI_FAILURE(status)) {773773- goto cleanup;774774- }775775-776776- /* Create and initialize a new walk state */777777-778778- walk_state =779779- acpi_ds_create_walk_state(obj_desc->method.owner_id, NULL, NULL,780780- NULL);781781- if (!walk_state) {782782- status = AE_NO_MEMORY;783783- goto cleanup2;784784- }785785-786786- status = acpi_ds_init_aml_walk(walk_state, op, node,787787- obj_desc->method.aml_start,788788- obj_desc->method.aml_length, NULL, 1);789789- if (ACPI_FAILURE(status)) {790790- acpi_ds_delete_walk_state(walk_state);791791- goto cleanup2;792792- }793793-794794- /*795795- * Parse the method, first pass796796- *797797- * The first pass load is where newly declared named objects are added into798798- * the namespace. Actual evaluation of the named objects (what would be799799- * called a "second pass") happens during the actual execution of the800800- * method so that operands to the named objects can take on dynamic801801- * run-time values.802802- */803803- status = acpi_ps_parse_aml(walk_state);804804- if (ACPI_FAILURE(status)) {805805- goto cleanup2;806806- }807807-808808- ACPI_DEBUG_PRINT((ACPI_DB_PARSE,809809- "**** [%4.4s] Parsed **** NamedObj=%p Op=%p\n",810810- acpi_ut_get_node_name(node), node, op));811811-812812- /*813813- * Delete the parse tree. We simply re-parse the method for every814814- * execution since there isn't much overhead (compared to keeping lots815815- * of parse trees around)816816- */817817- acpi_ns_delete_namespace_subtree(node);818818- acpi_ns_delete_namespace_by_owner(obj_desc->method.owner_id);819819-820820- cleanup2:821821- acpi_ut_release_owner_id(&obj_desc->method.owner_id);822822-823823- cleanup:824824- acpi_ps_delete_parse_tree(op);825825- return_ACPI_STATUS(status);826826-}827827-#endif
+1-3
drivers/acpi/dispatcher/dswexec.c
···472472 acpi_ds_result_push(walk_state->result_obj,473473 walk_state);474474 }475475-476475 break;477476478477 default:···509510 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,510511 "Method Reference in a Package, Op=%p\n",511512 op));513513+512514 op->common.node =513515 (struct acpi_namespace_node *)op->asl.value.514516 arg->asl.node->object;···670670671671 status = acpi_ds_result_stack_pop(walk_state);672672 }673673-674673 break;675674676675 case AML_TYPE_UNDEFINED:···707708 * Check if we just completed the evaluation of a708709 * conditional predicate709710 */710710-711711 if ((ACPI_SUCCESS(status)) &&712712 (walk_state->control_state) &&713713 (walk_state->control_state->common.state ==
+23-26
drivers/acpi/dispatcher/dswload.c
···175175 if (status == AE_NOT_FOUND) {176176 /*177177 * Table disassembly:178178- * Target of Scope() not found. Generate an External for it, and178178+ * Target of Scope() not found. Generate an External for it, and179179 * insert the name into the namespace.180180 */181181 acpi_dm_add_to_external_list(path, ACPI_TYPE_DEVICE, 0);···210210 case ACPI_TYPE_BUFFER:211211212212 /*213213- * These types we will allow, but we will change the type. This213213+ * These types we will allow, but we will change the type. This214214 * enables some existing code of the form:215215 *216216 * Name (DEB, 0)217217 * Scope (DEB) { ... }218218 *219219- * Note: silently change the type here. On the second pass, we will report219219+ * Note: silently change the type here. On the second pass, we will report220220 * a warning221221 */222222-223222 ACPI_DEBUG_PRINT((ACPI_DB_INFO,224223 "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n",225224 path,···241242 break;242243243244 default:244244-245245 /*246246 * For all other named opcodes, we will enter the name into247247 * the namespace.···257259 * buffer_field, or Package), the name of the object is already258260 * in the namespace.259261 */260260-261262 if (walk_state->deferred_node) {262263263264 /* This name is already in the namespace, get the node */···290293 }291294292295 /*293293- * Enter the named type into the internal namespace. We enter the name294294- * as we go downward in the parse tree. Any necessary subobjects that296296+ * Enter the named type into the internal namespace. We enter the name297297+ * as we go downward in the parse tree. Any necessary subobjects that295298 * involve arguments to the opcode must be created as we go back up the296299 * parse tree later.297300 */···324327 (status);325328 }326329 }330330+327331 status = AE_OK;328332 }329333 }330334331335 if (ACPI_FAILURE(status)) {332332-333336 ACPI_ERROR_NAMESPACE(path, status);334337 return_ACPI_STATUS(status);335338 }···431434 status =432435 acpi_ex_create_region(op->named.data,433436 op->named.length,434434- (acpi_adr_space_type)435435- ((op->common.value.arg)->436436- common.value.integer),437437+ (acpi_adr_space_type) ((op->438438+ common.439439+ value.440440+ arg)->441441+ common.442442+ value.443443+ integer),437444 walk_state);438445 if (ACPI_FAILURE(status)) {439446 return_ACPI_STATUS(status);···475474 * method_op pkg_length name_string method_flags term_list476475 *477476 * Note: We must create the method node/object pair as soon as we478478- * see the method declaration. This allows later pass1 parsing477477+ * see the method declaration. This allows later pass1 parsing479478 * of invocations of the method (need to know the number of480479 * arguments.)481480 */···500499 length,501500 walk_state);502501 }502502+503503 walk_state->operands[0] = NULL;504504 walk_state->num_operands = 0;505505···572570#ifdef ACPI_ENABLE_MODULE_LEVEL_CODE573571 if ((walk_state->op_info->class == AML_CLASS_EXECUTE) ||574572 (walk_state->op_info->class == AML_CLASS_CONTROL)) {575575-576573 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,577574 "Begin/EXEC: %s (fl %8.8X)\n",578575 walk_state->op_info->name,···603602 } else {604603 /* Get name from the op */605604606606- buffer_ptr = (char *)&op->named.name;605605+ buffer_ptr = ACPI_CAST_PTR(char, &op->named.name);607606 }608607 } else {609608 /* Get the namestring from the raw AML */···630629 break;631630632631 case AML_INT_NAMEPATH_OP:633633-634632 /*635633 * The name_path is an object reference to an existing object.636634 * Don't enter the name into the namespace, but look it up···642642 break;643643644644 case AML_SCOPE_OP:645645-646645 /*647646 * The Path is an object reference to an existing object.648647 * Don't enter the name into the namespace, but look it up···663664#endif664665 return_ACPI_STATUS(status);665666 }667667+666668 /*667669 * We must check to make sure that the target is668670 * one of the opcodes that actually opens a scope···683683 case ACPI_TYPE_BUFFER:684684685685 /*686686- * These types we will allow, but we will change the type. This686686+ * These types we will allow, but we will change the type. This687687 * enables some existing code of the form:688688 *689689 * Name (DEB, 0)690690 * Scope (DEB) { ... }691691 */692692-693692 ACPI_WARNING((AE_INFO,694693 "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)",695694 buffer_ptr,···728729 if (ACPI_FAILURE(status)) {729730 return_ACPI_STATUS(status);730731 }731731-732732 }733733+733734 return_ACPI_STATUS(AE_OK);734735 }735736736737 /*737737- * Enter the named type into the internal namespace. We enter the name738738- * as we go downward in the parse tree. Any necessary subobjects that738738+ * Enter the named type into the internal namespace. We enter the name739739+ * as we go downward in the parse tree. Any necessary subobjects that739740 * involve arguments to the opcode must be created as we go back up the740741 * parse tree later.741742 *···786787 * can get it again quickly when this scope is closed787788 */788789 op->common.node = node;789789-790790 return_ACPI_STATUS(status);791791}792792···920922#ifndef ACPI_NO_METHOD_EXECUTION921923922924 case AML_TYPE_CREATE_FIELD:923923-924925 /*925926 * Create the field object, but the field buffer and index must926927 * be evaluated later during the execution phase···928931 break;929932930933 case AML_TYPE_NAMED_FIELD:931931-932934 /*933935 * If we are executing a method, initialize the field934936 */···10471051 * argument is the space_id. (We must save the address of the10481052 * AML of the address and length operands)10491053 */10541054+10501055 /*10511056 * If we have a valid region, initialize it10521057 * Namespace is NOT locked at this point.···10771080 * method_op pkg_length name_string method_flags term_list10781081 *10791082 * Note: We must create the method node/object pair as soon as we10801080- * see the method declaration. This allows later pass1 parsing10831083+ * see the method declaration. This allows later pass1 parsing10811084 * of invocations of the method (need to know the number of10821085 * arguments.)10831086 */
+5-9
drivers/acpi/events/evgpe.c
···382382 u32 status_reg;383383 u32 enable_reg;384384 acpi_cpu_flags flags;385385- acpi_cpu_flags hw_flags;386385 acpi_native_uint i;387386 acpi_native_uint j;388387···393394 return (int_status);394395 }395396396396- /* We need to hold the GPE lock now, hardware lock in the loop */397397-397397+ /*398398+ * We need to obtain the GPE lock for both the data structs and registers399399+ * Note: Not necessary to obtain the hardware lock, since the GPE registers400400+ * are owned by the gpe_lock.401401+ */398402 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);399403400404 /* Examine all GPE blocks attached to this interrupt level */···415413416414 gpe_register_info = &gpe_block->register_info[i];417415418418- hw_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock);419419-420416 /* Read the Status Register */421417422418 status =···423423 &gpe_register_info->424424 status_address);425425 if (ACPI_FAILURE(status)) {426426- acpi_os_release_lock(acpi_gbl_hardware_lock,427427- hw_flags);428426 goto unlock_and_exit;429427 }430428···433435 &enable_reg,434436 &gpe_register_info->435437 enable_address);436436- acpi_os_release_lock(acpi_gbl_hardware_lock, hw_flags);437437-438438 if (ACPI_FAILURE(status)) {439439 goto unlock_and_exit;440440 }
···177177 * that the event is created in an unsignalled state178178 */179179 status = acpi_os_create_semaphore(ACPI_NO_UNIT_LIMIT, 0,180180- &obj_desc->event.semaphore);180180+ &obj_desc->event.os_semaphore);181181 if (ACPI_FAILURE(status)) {182182 goto cleanup;183183 }···226226 goto cleanup;227227 }228228229229- /*230230- * Create the actual OS semaphore.231231- * One unit max to make it a mutex, with one initial unit to allow232232- * the mutex to be acquired.233233- */234234- status = acpi_os_create_semaphore(1, 1, &obj_desc->mutex.semaphore);229229+ /* Create the actual OS Mutex */230230+231231+ status = acpi_os_create_mutex(&obj_desc->mutex.os_mutex);235232 if (ACPI_FAILURE(status)) {236233 goto cleanup;237234 }···562565 obj_desc->method.aml_length = aml_length;563566564567 /*565565- * Disassemble the method flags. Split off the Arg Count568568+ * Disassemble the method flags. Split off the Arg Count566569 * for efficiency567570 */568571 method_flags = (u8) operand[1]->integer.value;···573576 (u8) (method_flags & AML_METHOD_ARG_COUNT);574577575578 /*576576- * Get the concurrency count. If required, a semaphore will be579579+ * Get the sync_level. If method is serialized, a mutex will be577580 * created for this method when it is parsed.578581 */579582 if (acpi_gbl_all_methods_serialized) {580580- obj_desc->method.concurrency = 1;583583+ obj_desc->method.sync_level = 0;581584 obj_desc->method.method_flags |= AML_METHOD_SERIALIZED;582585 } else if (method_flags & AML_METHOD_SERIALIZED) {583586 /*584584- * ACPI 1.0: Concurrency = 1585585- * ACPI 2.0: Concurrency = (sync_level (in method declaration) + 1)587587+ * ACPI 1.0: sync_level = 0588588+ * ACPI 2.0: sync_level = sync_level in method declaration586589 */587587- obj_desc->method.concurrency = (u8)588588- (((method_flags & AML_METHOD_SYNCH_LEVEL) >> 4) + 1);589589- } else {590590- obj_desc->method.concurrency = ACPI_INFINITE_CONCURRENCY;590590+ obj_desc->method.sync_level = (u8)591591+ ((method_flags & AML_METHOD_SYNCH_LEVEL) >> 4);591592 }592593593594 /* Attach the new object to the method Node */
···727727 return_ACPI_STATUS(status);728728 }729729730730- /* Merge with previous datum if necessary */731731-732732- merged_datum |= raw_datum <<733733- (obj_desc->common_field.access_bit_width -734734- obj_desc->common_field.start_field_bit_offset);730730+ /*731731+ * Merge with previous datum if necessary.732732+ *733733+ * Note: Before the shift, check if the shift value will be larger than734734+ * the integer size. If so, there is no need to perform the operation.735735+ * This avoids the differences in behavior between different compilers736736+ * concerning shift values larger than the target data width.737737+ */738738+ if ((obj_desc->common_field.access_bit_width -739739+ obj_desc->common_field.start_field_bit_offset) <740740+ ACPI_INTEGER_BIT_SIZE) {741741+ merged_datum |=742742+ raw_datum << (obj_desc->common_field.743743+ access_bit_width -744744+ obj_desc->common_field.745745+ start_field_bit_offset);746746+ }735747736748 if (i == datum_count) {737749 break;···820808 return_ACPI_STATUS(AE_BUFFER_OVERFLOW);821809 }822810823823- /* Compute the number of datums (access width data items) */811811+ /*812812+ * Create the bitmasks used for bit insertion.813813+ * Note: This if/else is used to bypass compiler differences with the814814+ * shift operator815815+ */816816+ if (obj_desc->common_field.access_bit_width == ACPI_INTEGER_BIT_SIZE) {817817+ width_mask = ACPI_INTEGER_MAX;818818+ } else {819819+ width_mask =820820+ ACPI_MASK_BITS_ABOVE(obj_desc->common_field.821821+ access_bit_width);822822+ }824823825825- width_mask =826826- ACPI_MASK_BITS_ABOVE(obj_desc->common_field.access_bit_width);827827- mask =828828- width_mask & ACPI_MASK_BITS_BELOW(obj_desc->common_field.829829- start_field_bit_offset);824824+ mask = width_mask &825825+ ACPI_MASK_BITS_BELOW(obj_desc->common_field.start_field_bit_offset);826826+827827+ /* Compute the number of datums (access width data items) */830828831829 datum_count = ACPI_ROUND_UP_TO(obj_desc->common_field.bit_length,832830 obj_desc->common_field.access_bit_width);···870848 return_ACPI_STATUS(status);871849 }872850873873- /* Start new output datum by merging with previous input datum */874874-875851 field_offset += obj_desc->common_field.access_byte_width;876876- merged_datum = raw_datum >>877877- (obj_desc->common_field.access_bit_width -878878- obj_desc->common_field.start_field_bit_offset);852852+853853+ /*854854+ * Start new output datum by merging with previous input datum855855+ * if necessary.856856+ *857857+ * Note: Before the shift, check if the shift value will be larger than858858+ * the integer size. If so, there is no need to perform the operation.859859+ * This avoids the differences in behavior between different compilers860860+ * concerning shift values larger than the target data width.861861+ */862862+ if ((obj_desc->common_field.access_bit_width -863863+ obj_desc->common_field.start_field_bit_offset) <864864+ ACPI_INTEGER_BIT_SIZE) {865865+ merged_datum =866866+ raw_datum >> (obj_desc->common_field.867867+ access_bit_width -868868+ obj_desc->common_field.869869+ start_field_bit_offset);870870+ } else {871871+ merged_datum = 0;872872+ }873873+879874 mask = width_mask;880875881876 if (i == datum_count) {
+6-6
drivers/acpi/executer/exmutex.c
···161161162162 /*163163 * Current Sync must be less than or equal to the sync level of the164164- * mutex. This mechanism provides some deadlock prevention164164+ * mutex. This mechanism provides some deadlock prevention165165 */166166 if (walk_state->thread->current_sync_level > obj_desc->mutex.sync_level) {167167 ACPI_ERROR((AE_INFO,168168- "Cannot acquire Mutex [%4.4s], incorrect SyncLevel",169169- acpi_ut_get_node_name(obj_desc->mutex.node)));168168+ "Cannot acquire Mutex [%4.4s], current SyncLevel is too large (%d)",169169+ acpi_ut_get_node_name(obj_desc->mutex.node),170170+ walk_state->thread->current_sync_level));170171 return_ACPI_STATUS(AE_AML_MUTEX_ORDER);171172 }172173···179178180179 if ((obj_desc->mutex.owner_thread->thread_id ==181180 walk_state->thread->thread_id) ||182182- (obj_desc->mutex.semaphore ==183183- acpi_gbl_global_lock_semaphore)) {181181+ (obj_desc->mutex.os_mutex == ACPI_GLOBAL_LOCK)) {184182 /*185183 * The mutex is already owned by this thread,186184 * just increment the acquisition depth···264264 */265265 if ((obj_desc->mutex.owner_thread->thread_id !=266266 walk_state->thread->thread_id)267267- && (obj_desc->mutex.semaphore != acpi_gbl_global_lock_semaphore)) {267267+ && (obj_desc->mutex.os_mutex != ACPI_GLOBAL_LOCK)) {268268 ACPI_ERROR((AE_INFO,269269 "Thread %X cannot release Mutex [%4.4s] acquired by thread %X",270270 walk_state->thread->thread_id,
+68-14
drivers/acpi/executer/exsystem.c
···6363 * interpreter is released.6464 *6565 ******************************************************************************/6666-acpi_status acpi_ex_system_wait_semaphore(acpi_handle semaphore, u16 timeout)6666+acpi_status acpi_ex_system_wait_semaphore(acpi_semaphore semaphore, u16 timeout)6767{6868 acpi_status status;6969 acpi_status status2;70707171 ACPI_FUNCTION_TRACE(ex_system_wait_semaphore);72727373- status = acpi_os_wait_semaphore(semaphore, 1, 0);7373+ status = acpi_os_wait_semaphore(semaphore, 1, ACPI_DO_NOT_WAIT);7474 if (ACPI_SUCCESS(status)) {7575 return_ACPI_STATUS(status);7676 }···8282 acpi_ex_exit_interpreter();83838484 status = acpi_os_wait_semaphore(semaphore, 1, timeout);8585+8686+ ACPI_DEBUG_PRINT((ACPI_DB_EXEC,8787+ "*** Thread awake after blocking, %s\n",8888+ acpi_format_exception(status)));8989+9090+ /* Reacquire the interpreter */9191+9292+ status2 = acpi_ex_enter_interpreter();9393+ if (ACPI_FAILURE(status2)) {9494+9595+ /* Report fatal error, could not acquire interpreter */9696+9797+ return_ACPI_STATUS(status2);9898+ }9999+ }100100+101101+ return_ACPI_STATUS(status);102102+}103103+104104+/*******************************************************************************105105+ *106106+ * FUNCTION: acpi_ex_system_wait_mutex107107+ *108108+ * PARAMETERS: Mutex - Mutex to wait on109109+ * Timeout - Max time to wait110110+ *111111+ * RETURN: Status112112+ *113113+ * DESCRIPTION: Implements a semaphore wait with a check to see if the114114+ * semaphore is available immediately. If it is not, the115115+ * interpreter is released.116116+ *117117+ ******************************************************************************/118118+119119+acpi_status acpi_ex_system_wait_mutex(acpi_mutex mutex, u16 timeout)120120+{121121+ acpi_status status;122122+ acpi_status status2;123123+124124+ ACPI_FUNCTION_TRACE(ex_system_wait_mutex);125125+126126+ status = acpi_os_acquire_mutex(mutex, ACPI_DO_NOT_WAIT);127127+ if (ACPI_SUCCESS(status)) {128128+ return_ACPI_STATUS(status);129129+ }130130+131131+ if (status == AE_TIME) {132132+133133+ /* We must wait, so unlock the interpreter */134134+135135+ acpi_ex_exit_interpreter();136136+137137+ status = acpi_os_acquire_mutex(mutex, timeout);8513886139 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,87140 "*** Thread awake after blocking, %s\n",···229176 *230177 * FUNCTION: acpi_ex_system_acquire_mutex231178 *232232- * PARAMETERS: time_desc - The 'time to delay' object descriptor179179+ * PARAMETERS: time_desc - Maximum time to wait for the mutex233180 * obj_desc - The object descriptor for this op234181 *235182 * RETURN: Status···254201255202 /* Support for the _GL_ Mutex object -- go get the global lock */256203257257- if (obj_desc->mutex.semaphore == acpi_gbl_global_lock_semaphore) {204204+ if (obj_desc->mutex.os_mutex == ACPI_GLOBAL_LOCK) {258205 status =259206 acpi_ev_acquire_global_lock((u16) time_desc->integer.value);260207 return_ACPI_STATUS(status);261208 }262209263263- status = acpi_ex_system_wait_semaphore(obj_desc->mutex.semaphore,264264- (u16) time_desc->integer.value);210210+ status = acpi_ex_system_wait_mutex(obj_desc->mutex.os_mutex,211211+ (u16) time_desc->integer.value);265212 return_ACPI_STATUS(status);266213}267214···292239293240 /* Support for the _GL_ Mutex object -- release the global lock */294241295295- if (obj_desc->mutex.semaphore == acpi_gbl_global_lock_semaphore) {242242+ if (obj_desc->mutex.os_mutex == ACPI_GLOBAL_LOCK) {296243 status = acpi_ev_release_global_lock();297244 return_ACPI_STATUS(status);298245 }299246300300- status = acpi_os_signal_semaphore(obj_desc->mutex.semaphore, 1);301301- return_ACPI_STATUS(status);247247+ acpi_os_release_mutex(obj_desc->mutex.os_mutex);248248+ return_ACPI_STATUS(AE_OK);302249}303250304251/*******************************************************************************···321268 ACPI_FUNCTION_TRACE(ex_system_signal_event);322269323270 if (obj_desc) {324324- status = acpi_os_signal_semaphore(obj_desc->event.semaphore, 1);271271+ status =272272+ acpi_os_signal_semaphore(obj_desc->event.os_semaphore, 1);325273 }326274327275 return_ACPI_STATUS(status);···353299354300 if (obj_desc) {355301 status =356356- acpi_ex_system_wait_semaphore(obj_desc->event.semaphore,302302+ acpi_ex_system_wait_semaphore(obj_desc->event.os_semaphore,357303 (u16) time_desc->integer.358304 value);359305 }···376322acpi_status acpi_ex_system_reset_event(union acpi_operand_object *obj_desc)377323{378324 acpi_status status = AE_OK;379379- void *temp_semaphore;325325+ acpi_semaphore temp_semaphore;380326381327 ACPI_FUNCTION_ENTRY();382328···387333 status =388334 acpi_os_create_semaphore(ACPI_NO_UNIT_LIMIT, 0, &temp_semaphore);389335 if (ACPI_SUCCESS(status)) {390390- (void)acpi_os_delete_semaphore(obj_desc->event.semaphore);391391- obj_desc->event.semaphore = temp_semaphore;336336+ (void)acpi_os_delete_semaphore(obj_desc->event.os_semaphore);337337+ obj_desc->event.os_semaphore = temp_semaphore;392338 }393339394340 return (status);
+62-15
drivers/acpi/hardware/hwregs.c
···172172 }173173174174 /*175175- * The package must have at least two elements. NOTE (March 2005): This175175+ * The package must have at least two elements. NOTE (March 2005): This176176 * goes against the current ACPI spec which defines this object as a177177- * package with one encoded DWORD element. However, existing practice177177+ * package with one encoded DWORD element. However, existing practice178178 * by BIOS vendors seems to be to have 2 or more elements, at least179179 * one per sleep type (A/B).180180 */···255255 * return_value - Value that was read from the register256256 * Flags - Lock the hardware or not257257 *258258- * RETURN: Status and the value read from specified Register. Value258258+ * RETURN: Status and the value read from specified Register. Value259259 * returned is normalized to bit0 (is shifted all the way right)260260 *261261 * DESCRIPTION: ACPI bit_register read function.···361361 case ACPI_REGISTER_PM1_STATUS:362362363363 /*364364- * Status Registers are different from the rest. Clear by365365- * writing 1, and writing 0 has no effect. So, the only relevant364364+ * Status Registers are different from the rest. Clear by365365+ * writing 1, and writing 0 has no effect. So, the only relevant366366 * information is the single bit we're interested in, all others should367367 * be written as 0 so they will be left unchanged.368368 */···467467 *468468 * FUNCTION: acpi_hw_register_read469469 *470470- * PARAMETERS: use_lock - Mutex hw access471471- * register_id - register_iD + Offset470470+ * PARAMETERS: use_lock - Lock hardware? True/False471471+ * register_id - ACPI Register ID472472 * return_value - Where the register value is returned473473 *474474 * RETURN: Status and the value read.475475 *476476- * DESCRIPTION: Acpi register read function. Registers are read at the477477- * given offset.476476+ * DESCRIPTION: Read from the specified ACPI register478477 *479478 ******************************************************************************/480479acpi_status···579580 *580581 * FUNCTION: acpi_hw_register_write581582 *582582- * PARAMETERS: use_lock - Mutex hw access583583- * register_id - register_iD + Offset583583+ * PARAMETERS: use_lock - Lock hardware? True/False584584+ * register_id - ACPI Register ID584585 * Value - The value to write585586 *586587 * RETURN: Status587588 *588588- * DESCRIPTION: Acpi register Write function. Registers are written at the589589- * given offset.589589+ * DESCRIPTION: Write to the specified ACPI register590590+ *591591+ * NOTE: In accordance with the ACPI specification, this function automatically592592+ * preserves the value of the following bits, meaning that these bits cannot be593593+ * changed via this interface:594594+ *595595+ * PM1_CONTROL[0] = SCI_EN596596+ * PM1_CONTROL[9]597597+ * PM1_STATUS[11]598598+ *599599+ * ACPI References:600600+ * 1) Hardware Ignored Bits: When software writes to a register with ignored601601+ * bit fields, it preserves the ignored bit fields602602+ * 2) SCI_EN: OSPM always preserves this bit position590603 *591604 ******************************************************************************/592605···606595{607596 acpi_status status;608597 acpi_cpu_flags lock_flags = 0;598598+ u32 read_value;609599610600 ACPI_FUNCTION_TRACE(hw_register_write);611601···616604617605 switch (register_id) {618606 case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */607607+608608+ /* Perform a read first to preserve certain bits (per ACPI spec) */609609+610610+ status = acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK,611611+ ACPI_REGISTER_PM1_STATUS,612612+ &read_value);613613+ if (ACPI_FAILURE(status)) {614614+ goto unlock_and_exit;615615+ }616616+617617+ /* Insert the bits to be preserved */618618+619619+ ACPI_INSERT_BITS(value, ACPI_PM1_STATUS_PRESERVED_BITS,620620+ read_value);621621+622622+ /* Now we can write the data */619623620624 status =621625 acpi_hw_low_level_write(16, value,···662634 break;663635664636 case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */637637+638638+ /*639639+ * Perform a read first to preserve certain bits (per ACPI spec)640640+ *641641+ * Note: This includes SCI_EN, we never want to change this bit642642+ */643643+ status = acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK,644644+ ACPI_REGISTER_PM1_CONTROL,645645+ &read_value);646646+ if (ACPI_FAILURE(status)) {647647+ goto unlock_and_exit;648648+ }649649+650650+ /* Insert the bits to be preserved */651651+652652+ ACPI_INSERT_BITS(value, ACPI_PM1_CONTROL_PRESERVED_BITS,653653+ read_value);654654+655655+ /* Now we can write the data */665656666657 status =667658 acpi_hw_low_level_write(16, value,···773726 return (AE_OK);774727 }775728776776- /* Get a local copy of the address. Handles possible alignment issues */729729+ /* Get a local copy of the address. Handles possible alignment issues */777730778731 ACPI_MOVE_64_TO_64(&address, ®->address);779732 if (!address) {···845798 return (AE_OK);846799 }847800848848- /* Get a local copy of the address. Handles possible alignment issues */801801+ /* Get a local copy of the address. Handles possible alignment issues */849802850803 ACPI_MOVE_64_TO_64(&address, ®->address);851804 if (!address) {
+12-15
drivers/acpi/namespace/nsaccess.c
···196196 (u8) (ACPI_TO_INTEGER(val) - 1);197197198198 if (ACPI_STRCMP(init_val->name, "_GL_") == 0) {199199- /*200200- * Create a counting semaphore for the201201- * global lock202202- */199199+200200+ /* Create a counting semaphore for the global lock */201201+203202 status =204203 acpi_os_create_semaphore205204 (ACPI_NO_UNIT_LIMIT, 1,206206- &obj_desc->mutex.semaphore);205205+ &acpi_gbl_global_lock_semaphore);207206 if (ACPI_FAILURE(status)) {208207 acpi_ut_remove_reference209208 (obj_desc);210209 goto unlock_and_exit;211210 }212211213213- /*214214- * We just created the mutex for the215215- * global lock, save it216216- */217217- acpi_gbl_global_lock_semaphore =218218- obj_desc->mutex.semaphore;212212+ /* Mark this mutex as very special */213213+214214+ obj_desc->mutex.os_mutex =215215+ ACPI_GLOBAL_LOCK;219216 } else {220217 /* Create a mutex */221218222222- status = acpi_os_create_semaphore(1, 1,223223- &obj_desc->224224- mutex.225225- semaphore);219219+ status =220220+ acpi_os_create_mutex(&obj_desc->221221+ mutex.222222+ os_mutex);226223 if (ACPI_FAILURE(status)) {227224 acpi_ut_remove_reference228225 (obj_desc);
+7-21
drivers/acpi/osl.c
···688688/*689689 * Allocate the memory for a spinlock and initialize it.690690 */691691-acpi_status acpi_os_create_lock(acpi_handle * out_handle)691691+acpi_status acpi_os_create_lock(acpi_spinlock * handle)692692{693693- spinlock_t *lock_ptr;694694-695695-696696- lock_ptr = acpi_os_allocate(sizeof(spinlock_t));697697-698698- spin_lock_init(lock_ptr);699699-700700- ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Creating spinlock[%p].\n", lock_ptr));701701-702702- *out_handle = lock_ptr;693693+ spin_lock_init(*handle);703694704695 return AE_OK;705696}···698707/*699708 * Deallocate the memory for a spinlock.700709 */701701-void acpi_os_delete_lock(acpi_handle handle)710710+void acpi_os_delete_lock(acpi_spinlock handle)702711{703703-704704- ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Deleting spinlock[%p].\n", handle));705705-706706- acpi_os_free(handle);707707-708712 return;709713}710714···10231037 * handle is a pointer to the spinlock_t.10241038 */1025103910261026-acpi_cpu_flags acpi_os_acquire_lock(acpi_handle handle)10401040+acpi_cpu_flags acpi_os_acquire_lock(acpi_spinlock lockp)10271041{10281042 acpi_cpu_flags flags;10291029- spin_lock_irqsave((spinlock_t *) handle, flags);10431043+ spin_lock_irqsave(lockp, flags);10301044 return flags;10311045}10321046···10341048 * Release a spinlock. See above.10351049 */1036105010371037-void acpi_os_release_lock(acpi_handle handle, acpi_cpu_flags flags)10511051+void acpi_os_release_lock(acpi_spinlock lockp, acpi_cpu_flags flags)10381052{10391039- spin_unlock_irqrestore((spinlock_t *) handle, flags);10531053+ spin_unlock_irqrestore(lockp, flags);10401054}1041105510421056#ifndef ACPI_USE_LOCAL_CACHE
+16-2
drivers/acpi/parser/psparse.c
···469469 }470470471471 walk_state->thread = thread;472472+473473+ /*474474+ * If executing a method, the starting sync_level is this method's475475+ * sync_level476476+ */477477+ if (walk_state->method_desc) {478478+ walk_state->thread->current_sync_level =479479+ walk_state->method_desc->method.sync_level;480480+ }481481+472482 acpi_ds_push_walk_state(walk_state, thread);473483474484 /*···515505 status =516506 acpi_ds_call_control_method(thread, walk_state,517507 NULL);508508+ if (ACPI_FAILURE(status)) {509509+ status =510510+ acpi_ds_method_error(status, walk_state);511511+ }518512519513 /*520514 * If the transfer to the new method method call worked, a new walk···539525 /* Check for possible multi-thread reentrancy problem */540526541527 if ((status == AE_ALREADY_EXISTS) &&542542- (!walk_state->method_desc->method.semaphore)) {528528+ (!walk_state->method_desc->method.mutex)) {543529 /*544530 * Method tried to create an object twice. The probable cause is545531 * that the method cannot handle reentrancy.···551537 */552538 walk_state->method_desc->method.method_flags |=553539 AML_METHOD_SERIALIZED;554554- walk_state->method_desc->method.concurrency = 1;540540+ walk_state->method_desc->method.sync_level = 0;555541 }556542 }557543
+23-13
drivers/acpi/utilities/utdelete.c
···155155 case ACPI_TYPE_MUTEX:156156157157 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,158158- "***** Mutex %p, Semaphore %p\n",159159- object, object->mutex.semaphore));158158+ "***** Mutex %p, OS Mutex %p\n",159159+ object, object->mutex.os_mutex));160160161161- acpi_ex_unlink_mutex(object);162162- (void)acpi_os_delete_semaphore(object->mutex.semaphore);161161+ if (object->mutex.os_mutex != ACPI_GLOBAL_LOCK) {162162+ acpi_ex_unlink_mutex(object);163163+ acpi_os_delete_mutex(object->mutex.os_mutex);164164+ } else {165165+ /* Global Lock "mutex" is actually a counting semaphore */166166+167167+ (void)168168+ acpi_os_delete_semaphore169169+ (acpi_gbl_global_lock_semaphore);170170+ acpi_gbl_global_lock_semaphore = NULL;171171+ }163172 break;164173165174 case ACPI_TYPE_EVENT:166175167176 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,168168- "***** Event %p, Semaphore %p\n",169169- object, object->event.semaphore));177177+ "***** Event %p, OS Semaphore %p\n",178178+ object, object->event.os_semaphore));170179171171- (void)acpi_os_delete_semaphore(object->event.semaphore);172172- object->event.semaphore = NULL;180180+ (void)acpi_os_delete_semaphore(object->event.os_semaphore);181181+ object->event.os_semaphore = NULL;173182 break;174183175184 case ACPI_TYPE_METHOD:···186177 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,187178 "***** Method %p\n", object));188179189189- /* Delete the method semaphore if it exists */180180+ /* Delete the method mutex if it exists */190181191191- if (object->method.semaphore) {192192- (void)acpi_os_delete_semaphore(object->method.193193- semaphore);194194- object->method.semaphore = NULL;182182+ if (object->method.mutex) {183183+ acpi_os_delete_mutex(object->method.mutex->mutex.184184+ os_mutex);185185+ acpi_ut_delete_object_desc(object->method.mutex);186186+ object->method.mutex = NULL;195187 }196188 break;197189
+1
drivers/acpi/utilities/utglobal.c
···794794795795 /* Global Lock support */796796797797+ acpi_gbl_global_lock_semaphore = NULL;797798 acpi_gbl_global_lock_acquired = FALSE;798799 acpi_gbl_global_lock_thread_count = 0;799800 acpi_gbl_global_lock_handle = 0;
+10-29
drivers/acpi/utilities/utmutex.c
···82828383 /* Create the spinlocks for use at interrupt level */84848585- status = acpi_os_create_lock(&acpi_gbl_gpe_lock);8686- if (ACPI_FAILURE(status)) {8787- return_ACPI_STATUS(status);8888- }8585+ spin_lock_init(acpi_gbl_gpe_lock);8686+ spin_lock_init(acpi_gbl_hardware_lock);89879090- status = acpi_os_create_lock(&acpi_gbl_hardware_lock);9188 return_ACPI_STATUS(status);9289}9390···143146 }144147145148 if (!acpi_gbl_mutex_info[mutex_id].mutex) {146146- status = acpi_os_create_semaphore(1, 1,147147- &acpi_gbl_mutex_info148148- [mutex_id].mutex);149149+ status =150150+ acpi_os_create_mutex(&acpi_gbl_mutex_info[mutex_id].mutex);149151 acpi_gbl_mutex_info[mutex_id].thread_id =150152 ACPI_MUTEX_NOT_ACQUIRED;151153 acpi_gbl_mutex_info[mutex_id].use_count = 0;···167171168172static acpi_status acpi_ut_delete_mutex(acpi_mutex_handle mutex_id)169173{170170- acpi_status status;171174172175 ACPI_FUNCTION_TRACE_U32(ut_delete_mutex, mutex_id);173176···174179 return_ACPI_STATUS(AE_BAD_PARAMETER);175180 }176181177177- status = acpi_os_delete_semaphore(acpi_gbl_mutex_info[mutex_id].mutex);182182+ acpi_os_delete_mutex(acpi_gbl_mutex_info[mutex_id].mutex);178183179184 acpi_gbl_mutex_info[mutex_id].mutex = NULL;180185 acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED;181186182182- return_ACPI_STATUS(status);187187+ return_ACPI_STATUS(AE_OK);183188}184189185190/*******************************************************************************···246251 "Thread %X attempting to acquire Mutex [%s]\n",247252 this_thread_id, acpi_ut_get_mutex_name(mutex_id)));248253249249- status = acpi_os_wait_semaphore(acpi_gbl_mutex_info[mutex_id].mutex,250250- 1, ACPI_WAIT_FOREVER);254254+ status = acpi_os_acquire_mutex(acpi_gbl_mutex_info[mutex_id].mutex,255255+ ACPI_WAIT_FOREVER);251256 if (ACPI_SUCCESS(status)) {252257 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,253258 "Thread %X acquired Mutex [%s]\n",···279284280285acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id)281286{282282- acpi_status status;283287 acpi_thread_id this_thread_id;284288285289 ACPI_FUNCTION_NAME(ut_release_mutex);···334340335341 acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED;336342337337- status =338338- acpi_os_signal_semaphore(acpi_gbl_mutex_info[mutex_id].mutex, 1);339339-340340- if (ACPI_FAILURE(status)) {341341- ACPI_EXCEPTION((AE_INFO, status,342342- "Thread %X could not release Mutex [%X]",343343- this_thread_id, mutex_id));344344- } else {345345- ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,346346- "Thread %X released Mutex [%s]\n",347347- this_thread_id,348348- acpi_ut_get_mutex_name(mutex_id)));349349- }350350-351351- return (status);343343+ acpi_os_release_mutex(acpi_gbl_mutex_info[mutex_id].mutex);344344+ return (AE_OK);352345}
+1-1
include/acpi/acconfig.h
···63636464/* Current ACPICA subsystem version in YYYYMMDD format */65656666-#define ACPI_CA_VERSION 0x200606086666+#define ACPI_CA_VERSION 0x2006062367676868/*6969 * OS name, used for the _OS object. The _OS object is essentially obsolete,
···181181extern struct acpi_table_list acpi_gbl_table_lists[ACPI_TABLE_ID_MAX + 1];182182extern struct acpi_table_support acpi_gbl_table_data[ACPI_TABLE_ID_MAX + 1];183183184184+/*****************************************************************************185185+ *186186+ * Mutual exlusion within ACPICA subsystem187187+ *188188+ ****************************************************************************/189189+184190/*185191 * Predefined mutex objects. This array contains the186192 * actual OS mutex handles, indexed by the local ACPI_MUTEX_HANDLEs.187193 * (The table maps local handles to the real OS handles)188194 */189195ACPI_EXTERN struct acpi_mutex_info acpi_gbl_mutex_info[ACPI_NUM_MUTEX];196196+197197+/*198198+ * Global lock semaphore works in conjunction with the actual HW global lock199199+ */200200+ACPI_EXTERN acpi_semaphore acpi_gbl_global_lock_semaphore;201201+202202+/*203203+ * Spinlocks are used for interfaces that can be possibly called at204204+ * interrupt level205205+ */206206+ACPI_EXTERN spinlock_t _acpi_gbl_gpe_lock; /* For GPE data structs and registers */207207+ACPI_EXTERN spinlock_t _acpi_gbl_hardware_lock; /* For ACPI H/W except GPE registers */208208+#define acpi_gbl_gpe_lock &_acpi_gbl_gpe_lock209209+#define acpi_gbl_hardware_lock &_acpi_gbl_hardware_lock190210191211/*****************************************************************************192212 *···237217ACPI_EXTERN acpi_exception_handler acpi_gbl_exception_handler;238218ACPI_EXTERN acpi_init_handler acpi_gbl_init_handler;239219ACPI_EXTERN struct acpi_walk_state *acpi_gbl_breakpoint_walk;240240-ACPI_EXTERN acpi_handle acpi_gbl_global_lock_semaphore;241220242221/* Misc */243222···333314ACPI_EXTERN struct acpi_gpe_xrupt_info *acpi_gbl_gpe_xrupt_list_head;334315ACPI_EXTERN struct acpi_gpe_block_info335316 *acpi_gbl_gpe_fadt_blocks[ACPI_MAX_GPE_BLOCKS];336336-337337-/* Spinlocks */338338-339339-ACPI_EXTERN acpi_handle acpi_gbl_gpe_lock;340340-ACPI_EXTERN acpi_handle acpi_gbl_hardware_lock;341317342318/*****************************************************************************343319 *
···241241242242/*******************************************************************************243243 *244244- * OS- or compiler-dependent types244244+ * OS-dependent and compiler-dependent types245245 *246246 * If the defaults below are not appropriate for the host system, they can247247 * be defined in the compiler-specific or OS-specific header, and this will···249249 *250250 ******************************************************************************/251251252252-/* Use C99 uintptr_t for pointer casting if available, "void *" otherwise */252252+/* Value returned by acpi_os_get_thread_id */253253254254-#ifndef acpi_uintptr_t255255-#define acpi_uintptr_t void *254254+#ifndef acpi_thread_id255255+#define acpi_thread_id acpi_native_uint256256#endif257257258258-/*259259- * If acpi_cache_t was not defined in the OS-dependent header,260260- * define it now. This is typically the case where the local cache261261- * manager implementation is to be used (ACPI_USE_LOCAL_CACHE)262262- */258258+/* Object returned from acpi_os_create_lock */259259+260260+#ifndef acpi_spinlock261261+#define acpi_spinlock void *262262+#endif263263+264264+/* Flags for acpi_os_acquire_lock/acpi_os_release_lock */265265+266266+#ifndef acpi_cpu_flags267267+#define acpi_cpu_flags acpi_native_uint268268+#endif269269+270270+/* Object returned from acpi_os_create_cache */271271+263272#ifndef acpi_cache_t264273#define acpi_cache_t struct acpi_memory_list265274#endif266275267267-/*268268- * Allow the CPU flags word to be defined per-OS to simplify the use of the269269- * lock and unlock OSL interfaces.270270- */271271-#ifndef acpi_cpu_flags272272-#define acpi_cpu_flags acpi_native_uint276276+/* Use C99 uintptr_t for pointer casting if available, "void *" otherwise */277277+278278+#ifndef acpi_uintptr_t279279+#define acpi_uintptr_t void *273280#endif274281275282/*···303296 */304297#ifndef ACPI_EXPORT_SYMBOL305298#define ACPI_EXPORT_SYMBOL(symbol)306306-#endif307307-308308-/*309309- * thread_id is returned by acpi_os_get_thread_id.310310- */311311-#ifndef acpi_thread_id312312-#define acpi_thread_id acpi_native_uint313299#endif314300315301/*******************************************************************************···379379 u32 lo;380380 u32 hi;381381};382382+383383+/* Synchronization objects */384384+385385+#define acpi_mutex void *386386+#define acpi_semaphore void *382387383388/*384389 * Acpi integer width. In ACPI version 1, integers are