Skip to content

Commit f6dd922

Browse files
acpiboblenb
authored andcommitted
ACPI: ACPICA 20060707
Added the ACPI_PACKED_POINTERS_NOT_SUPPORTED macro to support C compilers that do not allow the initialization of address pointers within packed structures - even though the hardware itself may support misaligned transfers. Some of the debug data structures are packed by default to minimize size. Added an error message for the case where acpi_os_get_thread_id() returns zero. A non-zero value is required by the core ACPICA code to ensure the proper operation of AML mutexes and recursive control methods. The DSDT is now the only ACPI table that determines whether the AML interpreter is in 32-bit or 64-bit mode. Not really a functional change, but the hooks for per-table 32/64 switching have been removed from the code. A clarification to the ACPI specification is forthcoming in ACPI 3.0B. Fixed a possible leak of an Owner ID in the error path of tbinstal.c acpi_tb_init_table_descriptor() and migrated all table OwnerID deletion to a single place in acpi_tb_uninstall_table() to correct possible leaks when using the acpi_tb_delete_tables_by_type() interface (with assistance from Lance Ortiz.) Fixed a problem with Serialized control methods where the semaphore associated with the method could be over-signaled after multiple method invocations. Fixed two issues with the locking of the internal namespace data structure. Both the Unload() operator and acpi_unload_table() interface now lock the namespace during the namespace deletion associated with the table unload (with assistance from Linn Crosetto.) Fixed problem reports (Valery Podrezov) integrated: - Eliminate unnecessary memory allocation for CreateXxxxField http://bugzilla.kernel.org/show_bug.cgi?id=5426 Fixed problem reports (Fiodor Suietov) integrated: - Incomplete cleanup branches in AcpiTbGetTableRsdt (BZ 369) - On Address Space handler deletion, needless deactivation call (BZ 374) - AcpiRemoveAddressSpaceHandler: validate Device handle parameter (BZ 375) - Possible memory leak, Notify sub-objects of Processor, Power, ThermalZone (BZ 376) - AcpiRemoveAddressSpaceHandler: validate Handler parameter (BZ 378) - Minimum Length of RSDT should be validated (BZ 379) - AcpiRemoveNotifyHandler: return AE_NOT_EXIST if Processor Obj has no Handler (BZ (380) - AcpiUnloadTable: return AE_NOT_EXIST if no table of specified type loaded (BZ 381) Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
1 parent 120bda2 commit f6dd922

21 files changed

Lines changed: 209 additions & 113 deletions

File tree

‎drivers/acpi/dispatcher/dsinit.c‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,6 @@ acpi_ds_init_one_object(acpi_handle obj_handle,
116116

117117
case ACPI_TYPE_METHOD:
118118

119-
/*
120-
* Set the execution data width (32 or 64) based upon the
121-
* revision number of the parent ACPI table.
122-
* TBD: This is really for possible future support of integer width
123-
* on a per-table basis. Currently, we just use a global for the width.
124-
*/
125-
if (info->table_desc->pointer->revision == 1) {
126-
node->flags |= ANOBJ_DATA_WIDTH_32;
127-
}
128-
129119
info->method_count++;
130120
break;
131121

‎drivers/acpi/dispatcher/dsmethod.c‎

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ acpi_ds_create_method_mutex(union acpi_operand_object *method_desc)
134134
union acpi_operand_object *mutex_desc;
135135
acpi_status status;
136136

137-
ACPI_FUNCTION_NAME(ds_create_method_mutex);
137+
ACPI_FUNCTION_TRACE(ds_create_method_mutex);
138138

139139
/* Create the new mutex object */
140140

@@ -493,7 +493,7 @@ acpi_ds_restart_control_method(struct acpi_walk_state *walk_state,
493493

494494
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
495495
"****Restart [%4.4s] Op %p ReturnValueFromCallee %p\n",
496-
(char *)&walk_state->method_node->name,
496+
acpi_ut_get_node_name(walk_state->method_node),
497497
walk_state->method_call_op, return_desc));
498498

499499
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
@@ -610,6 +610,7 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc,
610610

611611
acpi_os_release_mutex(method_desc->method.mutex->mutex.
612612
os_mutex);
613+
method_desc->method.mutex->mutex.owner_thread = NULL;
613614
}
614615
}
615616

@@ -620,27 +621,11 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc,
620621
*/
621622
method_node = walk_state->method_node;
622623

623-
/* Lock namespace for possible update */
624-
625-
status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
626-
if (ACPI_FAILURE(status)) {
627-
return_VOID;
628-
}
629-
630-
/*
631-
* Delete any namespace entries created immediately underneath
632-
* the method
633-
*/
634-
if (method_node && method_node->child) {
635-
acpi_ns_delete_namespace_subtree(method_node);
636-
}
637-
638624
/*
639-
* Delete any namespace entries created anywhere else within
625+
* Delete any namespace objects created anywhere within
640626
* the namespace by the execution of this method
641627
*/
642628
acpi_ns_delete_namespace_by_owner(method_desc->method.owner_id);
643-
status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
644629
}
645630

646631
/* Decrement the thread count on the method */

‎drivers/acpi/dispatcher/dswexec.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,10 +313,10 @@ acpi_ds_exec_begin_op(struct acpi_walk_state *walk_state,
313313
case AML_CLASS_EXECUTE:
314314
case AML_CLASS_CREATE:
315315
/*
316-
* Most operators with arguments.
316+
* Most operators with arguments (except create_xxx_field operators)
317317
* Start a new result/operand state
318318
*/
319-
if (walk_state->opcode != AML_CREATE_FIELD_OP) {
319+
if (walk_state->op_info->object_type != ACPI_TYPE_BUFFER_FIELD) {
320320
status = acpi_ds_result_stack_push(walk_state);
321321
}
322322
break;

‎drivers/acpi/events/evregion.c‎

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -528,34 +528,40 @@ acpi_ev_detach_region(union acpi_operand_object *region_obj,
528528
}
529529
}
530530

531-
/* Call the setup handler with the deactivate notification */
531+
/*
532+
* If the region has been activated, call the setup handler
533+
* with the deactivate notification
534+
*/
535+
if (region_obj->region.flags & AOPOBJ_SETUP_COMPLETE) {
536+
region_setup = handler_obj->address_space.setup;
537+
status =
538+
region_setup(region_obj,
539+
ACPI_REGION_DEACTIVATE,
540+
handler_obj->address_space.
541+
context, region_context);
532542

533-
region_setup = handler_obj->address_space.setup;
534-
status =
535-
region_setup(region_obj, ACPI_REGION_DEACTIVATE,
536-
handler_obj->address_space.context,
537-
region_context);
543+
/* Init routine may fail, Just ignore errors */
538544

539-
/* Init routine may fail, Just ignore errors */
545+
if (ACPI_FAILURE(status)) {
546+
ACPI_EXCEPTION((AE_INFO, status,
547+
"from region handler - deactivate, [%s]",
548+
acpi_ut_get_region_name
549+
(region_obj->region.
550+
space_id)));
551+
}
540552

541-
if (ACPI_FAILURE(status)) {
542-
ACPI_EXCEPTION((AE_INFO, status,
543-
"from region init, [%s]",
544-
acpi_ut_get_region_name
545-
(region_obj->region.space_id)));
553+
region_obj->region.flags &=
554+
~(AOPOBJ_SETUP_COMPLETE);
546555
}
547556

548-
region_obj->region.flags &= ~(AOPOBJ_SETUP_COMPLETE);
549-
550557
/*
551558
* Remove handler reference in the region
552559
*
553-
* NOTE: this doesn't mean that the region goes away
554-
* The region is just inaccessible as indicated to
555-
* the _REG method
560+
* NOTE: this doesn't mean that the region goes away, the region
561+
* is just inaccessible as indicated to the _REG method
556562
*
557-
* If the region is on the handler's list
558-
* this better be the region's handler
563+
* If the region is on the handler's list, this must be the
564+
* region's handler
559565
*/
560566
region_obj->region.handler = NULL;
561567
acpi_ut_remove_reference(handler_obj);

‎drivers/acpi/events/evxface.c‎

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ acpi_remove_notify_handler(acpi_handle device,
428428
node = acpi_ns_map_handle_to_node(device);
429429
if (!node) {
430430
status = AE_BAD_PARAMETER;
431-
goto unlock;
431+
goto unlock_and_exit;
432432
}
433433

434434
/* Root Object */
@@ -442,7 +442,7 @@ acpi_remove_notify_handler(acpi_handle device,
442442
((handler_type & ACPI_DEVICE_NOTIFY) &&
443443
!acpi_gbl_device_notify.handler)) {
444444
status = AE_NOT_EXIST;
445-
goto unlock;
445+
goto unlock_and_exit;
446446
}
447447

448448
/* Make sure all deferred tasks are completed */
@@ -474,25 +474,29 @@ acpi_remove_notify_handler(acpi_handle device,
474474

475475
if (!acpi_ev_is_notify_object(node)) {
476476
status = AE_TYPE;
477-
goto unlock;
477+
goto unlock_and_exit;
478478
}
479479

480480
/* Check for an existing internal object */
481481

482482
obj_desc = acpi_ns_get_attached_object(node);
483483
if (!obj_desc) {
484484
status = AE_NOT_EXIST;
485-
goto unlock;
485+
goto unlock_and_exit;
486486
}
487487

488488
/* Object exists - make sure there's an existing handler */
489489

490490
if (handler_type & ACPI_SYSTEM_NOTIFY) {
491491
notify_obj = obj_desc->common_notify.system_notify;
492-
if ((!notify_obj) ||
493-
(notify_obj->notify.handler != handler)) {
492+
if (!notify_obj) {
493+
status = AE_NOT_EXIST;
494+
goto unlock_and_exit;
495+
}
496+
497+
if (notify_obj->notify.handler != handler) {
494498
status = AE_BAD_PARAMETER;
495-
goto unlock;
499+
goto unlock_and_exit;
496500
}
497501
/* Make sure all deferred tasks are completed */
498502

@@ -510,10 +514,14 @@ acpi_remove_notify_handler(acpi_handle device,
510514

511515
if (handler_type & ACPI_DEVICE_NOTIFY) {
512516
notify_obj = obj_desc->common_notify.device_notify;
513-
if ((!notify_obj) ||
514-
(notify_obj->notify.handler != handler)) {
517+
if (!notify_obj) {
518+
status = AE_NOT_EXIST;
519+
goto unlock_and_exit;
520+
}
521+
522+
if (notify_obj->notify.handler != handler) {
515523
status = AE_BAD_PARAMETER;
516-
goto unlock;
524+
goto unlock_and_exit;
517525
}
518526
/* Make sure all deferred tasks are completed */
519527

@@ -530,9 +538,9 @@ acpi_remove_notify_handler(acpi_handle device,
530538
}
531539
}
532540

533-
unlock:
541+
unlock_and_exit:
534542
(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
535-
exit:
543+
exit:
536544
if (ACPI_FAILURE(status))
537545
ACPI_EXCEPTION((AE_INFO, status, "Removing notify handler"));
538546
return_ACPI_STATUS(status);
@@ -586,23 +594,23 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
586594
gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
587595
if (!gpe_event_info) {
588596
status = AE_BAD_PARAMETER;
589-
goto unlock;
597+
goto unlock_and_exit;
590598
}
591599

592600
/* Make sure that there isn't a handler there already */
593601

594602
if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) ==
595603
ACPI_GPE_DISPATCH_HANDLER) {
596604
status = AE_ALREADY_EXISTS;
597-
goto unlock;
605+
goto unlock_and_exit;
598606
}
599607

600608
/* Allocate and init handler object */
601609

602610
handler = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_handler_info));
603611
if (!handler) {
604612
status = AE_NO_MEMORY;
605-
goto unlock;
613+
goto unlock_and_exit;
606614
}
607615

608616
handler->address = address;
@@ -613,7 +621,7 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
613621

614622
status = acpi_ev_disable_gpe(gpe_event_info);
615623
if (ACPI_FAILURE(status)) {
616-
goto unlock;
624+
goto unlock_and_exit;
617625
}
618626

619627
/* Install the handler */
@@ -628,9 +636,9 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
628636

629637
acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
630638

631-
unlock:
639+
unlock_and_exit:
632640
(void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
633-
exit:
641+
exit:
634642
if (ACPI_FAILURE(status))
635643
ACPI_EXCEPTION((AE_INFO, status,
636644
"Installing notify handler failed"));

‎drivers/acpi/events/evxfregn.c‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,11 @@ acpi_remove_address_space_handler(acpi_handle device,
155155
/* Convert and validate the device handle */
156156

157157
node = acpi_ns_map_handle_to_node(device);
158-
if (!node) {
158+
if (!node ||
159+
((node->type != ACPI_TYPE_DEVICE) &&
160+
(node->type != ACPI_TYPE_PROCESSOR) &&
161+
(node->type != ACPI_TYPE_THERMAL) &&
162+
(node != acpi_gbl_root_node))) {
159163
status = AE_BAD_PARAMETER;
160164
goto unlock_and_exit;
161165
}
@@ -178,6 +182,13 @@ acpi_remove_address_space_handler(acpi_handle device,
178182

179183
if (handler_obj->address_space.space_id == space_id) {
180184

185+
/* Handler must be the same as the installed handler */
186+
187+
if (handler_obj->address_space.handler != handler) {
188+
status = AE_BAD_PARAMETER;
189+
goto unlock_and_exit;
190+
}
191+
181192
/* Matched space_id, first dereference this in the Regions */
182193

183194
ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,

‎drivers/acpi/executer/exconfig.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,6 @@ acpi_status acpi_ex_unload_table(union acpi_operand_object *ddb_handle)
502502
* (Offset contains the table_id)
503503
*/
504504
acpi_ns_delete_namespace_by_owner(table_info->owner_id);
505-
acpi_ut_release_owner_id(&table_info->owner_id);
506505

507506
/* Delete the table itself */
508507

‎drivers/acpi/executer/exconvrt.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc,
170170
return_ACPI_STATUS(AE_NO_MEMORY);
171171
}
172172

173+
ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n",
174+
ACPI_FORMAT_UINT64(result)));
175+
173176
/* Save the Result */
174177

175178
return_desc->integer.value = result;

‎drivers/acpi/executer/exsystem.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ ACPI_MODULE_NAME("exsystem")
6060
*
6161
* DESCRIPTION: Implements a semaphore wait with a check to see if the
6262
* semaphore is available immediately. If it is not, the
63-
* interpreter is released.
63+
* interpreter is released before waiting.
6464
*
6565
******************************************************************************/
6666
acpi_status acpi_ex_system_wait_semaphore(acpi_semaphore semaphore, u16 timeout)
@@ -110,9 +110,9 @@ acpi_status acpi_ex_system_wait_semaphore(acpi_semaphore semaphore, u16 timeout)
110110
*
111111
* RETURN: Status
112112
*
113-
* DESCRIPTION: Implements a semaphore wait with a check to see if the
114-
* semaphore is available immediately. If it is not, the
115-
* interpreter is released.
113+
* DESCRIPTION: Implements a mutex wait with a check to see if the
114+
* mutex is available immediately. If it is not, the
115+
* interpreter is released before waiting.
116116
*
117117
******************************************************************************/
118118

‎drivers/acpi/namespace/nsalloc.c‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,21 +386,31 @@ void acpi_ns_delete_namespace_subtree(struct acpi_namespace_node *parent_node)
386386
* specific ID. Used to delete entire ACPI tables. All
387387
* reference counts are updated.
388388
*
389+
* MUTEX: Locks namespace during deletion walk.
390+
*
389391
******************************************************************************/
390392

391393
void acpi_ns_delete_namespace_by_owner(acpi_owner_id owner_id)
392394
{
393395
struct acpi_namespace_node *child_node;
394396
struct acpi_namespace_node *deletion_node;
395-
u32 level;
396397
struct acpi_namespace_node *parent_node;
398+
u32 level;
399+
acpi_status status;
397400

398401
ACPI_FUNCTION_TRACE_U32(ns_delete_namespace_by_owner, owner_id);
399402

400403
if (owner_id == 0) {
401404
return_VOID;
402405
}
403406

407+
/* Lock namespace for possible update */
408+
409+
status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
410+
if (ACPI_FAILURE(status)) {
411+
return_VOID;
412+
}
413+
404414
deletion_node = NULL;
405415
parent_node = acpi_gbl_root_node;
406416
child_node = NULL;
@@ -469,5 +479,6 @@ void acpi_ns_delete_namespace_by_owner(acpi_owner_id owner_id)
469479
}
470480
}
471481

482+
(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
472483
return_VOID;
473484
}

0 commit comments

Comments
 (0)