Skip to content

Commit

Permalink
ACPICA 20050708 from Bob Moore <[email protected]>
Browse files Browse the repository at this point in the history
The use of the CPU stack in the debug version of the
subsystem has been considerably reduced.  Previously, a
debug structure was declared in every function that used
the debug macros.  This structure has been removed in
favor of declaring the individual elements as parameters
to the debug functions.  This reduces the cumulative stack
use during nested execution of ACPI function calls at the
cost of a small increase in the code size of the debug
version of the subsystem.  With assistance from Alexey
Starikovskiy and Len Brown.

Added the ACPI_GET_FUNCTION_NAME macro to enable the
compiler-dependent headers to define a macro that will
return the current function name at runtime (such as
__FUNCTION__ or _func_, etc.) The function name is used
by the debug trace output.  If ACPI_GET_FUNCTION_NAME
is not defined in the compiler-dependent header, the
function name is saved on the CPU stack (one pointer per
function.) This mechanism is used because apparently there
exists no standard ANSI-C defined macro that that returns
the function name.

Alexey Starikovskiy redesigned and reimplemented the
"Owner ID" mechanism used to track namespace objects
created/deleted by ACPI tables and control method
execution.  A bitmap is now used to allocate and free the
IDs, thus solving the wraparound problem present in the
previous implementation.  The size of the namespace node
descriptor was reduced by 2 bytes as a result.

Removed the UINT32_BIT and UINT16_BIT types that were used
for the bitfield flag definitions within the headers for
the predefined ACPI tables.  These have been replaced by
UINT8_BIT in order to increase the code portability of
the subsystem.  If the use of UINT8 remains a problem,
we may be forced to eliminate bitfields entirely because
of a lack of portability.

Alexey Starikovksiy enhanced the performance of
acpi_ut_update_object_reference.  This is a frequently used
function and this improvement increases the performance
of the entire subsystem.

Alexey Starikovskiy fixed several possible memory leaks
and the inverse - premature object deletion.

Signed-off-by: Len Brown <[email protected]>
  • Loading branch information
acpibob authored and lenb committed Jul 14, 2005
1 parent 4c3ffbd commit f9f4601
Show file tree
Hide file tree
Showing 39 changed files with 664 additions and 540 deletions.
6 changes: 3 additions & 3 deletions drivers/acpi/dispatcher/dsinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ acpi_ds_init_one_object (
* was just loaded
*/
if (((struct acpi_namespace_node *) obj_handle)->owner_id !=
info->table_desc->table_id) {
info->table_desc->owner_id) {
return (AE_OK);
}

Expand Down Expand Up @@ -168,7 +168,7 @@ acpi_ds_init_one_object (
*/
acpi_ns_delete_namespace_subtree (obj_handle);
acpi_ns_delete_namespace_by_owner (
((struct acpi_namespace_node *) obj_handle)->object->method.owning_id);
((struct acpi_namespace_node *) obj_handle)->object->method.owner_id);
break;


Expand Down Expand Up @@ -237,7 +237,7 @@ acpi_ds_initialize_objects (

ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
"\nTable [%4.4s](id %4.4X) - %hd Objects with %hd Devices %hd Methods %hd Regions\n",
table_desc->pointer->signature, table_desc->table_id, info.object_count,
table_desc->pointer->signature, table_desc->owner_id, info.object_count,
info.device_count, info.method_count, info.op_region_count));

ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
Expand Down
35 changes: 22 additions & 13 deletions drivers/acpi/dispatcher/dsmethod.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ acpi_ds_parse_method (
union acpi_operand_object *obj_desc;
union acpi_parse_object *op;
struct acpi_namespace_node *node;
acpi_owner_id owner_id;
struct acpi_walk_state *walk_state;


Expand Down Expand Up @@ -132,23 +131,26 @@ acpi_ds_parse_method (
* objects (such as Operation Regions) can be created during the
* first pass parse.
*/
owner_id = acpi_ut_allocate_owner_id (ACPI_OWNER_TYPE_METHOD);
obj_desc->method.owning_id = owner_id;
status = acpi_ut_allocate_owner_id (&obj_desc->method.owner_id);
if (ACPI_FAILURE (status)) {
goto cleanup;
}

/* Create and initialize a new walk state */

walk_state = acpi_ds_create_walk_state (owner_id, NULL, NULL, NULL);
walk_state = acpi_ds_create_walk_state (
obj_desc->method.owner_id, NULL, NULL, NULL);
if (!walk_state) {
status = AE_NO_MEMORY;
goto cleanup;
goto cleanup2;
}

status = acpi_ds_init_aml_walk (walk_state, op, node,
obj_desc->method.aml_start,
obj_desc->method.aml_length, NULL, 1);
if (ACPI_FAILURE (status)) {
acpi_ds_delete_walk_state (walk_state);
goto cleanup;
goto cleanup2;
}

/*
Expand All @@ -162,13 +164,16 @@ acpi_ds_parse_method (
*/
status = acpi_ps_parse_aml (walk_state);
if (ACPI_FAILURE (status)) {
goto cleanup;
goto cleanup2;
}

ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
"**** [%4.4s] Parsed **** named_obj=%p Op=%p\n",
acpi_ut_get_node_name (obj_handle), obj_handle, op));

cleanup2:
(void) acpi_ut_release_owner_id (obj_desc->method.owner_id);

cleanup:
acpi_ps_delete_parse_tree (op);
return_ACPI_STATUS (status);
Expand Down Expand Up @@ -265,7 +270,7 @@ acpi_ds_call_control_method (
{
acpi_status status;
struct acpi_namespace_node *method_node;
struct acpi_walk_state *next_walk_state;
struct acpi_walk_state *next_walk_state = NULL;
union acpi_operand_object *obj_desc;
struct acpi_parameter_info info;
u32 i;
Expand All @@ -289,20 +294,23 @@ acpi_ds_call_control_method (
return_ACPI_STATUS (AE_NULL_OBJECT);
}

obj_desc->method.owning_id = acpi_ut_allocate_owner_id (ACPI_OWNER_TYPE_METHOD);
status = acpi_ut_allocate_owner_id (&obj_desc->method.owner_id);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}

/* Init for new method, wait on concurrency semaphore */

status = acpi_ds_begin_method_execution (method_node, obj_desc,
this_walk_state->method_node);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
goto cleanup;
}

if (!(obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY)) {
/* 1) Parse: Create a new walk state for the preempting walk */

next_walk_state = acpi_ds_create_walk_state (obj_desc->method.owning_id,
next_walk_state = acpi_ds_create_walk_state (obj_desc->method.owner_id,
op, obj_desc, NULL);
if (!next_walk_state) {
return_ACPI_STATUS (AE_NO_MEMORY);
Expand Down Expand Up @@ -332,7 +340,7 @@ acpi_ds_call_control_method (

/* 2) Execute: Create a new state for the preempting walk */

next_walk_state = acpi_ds_create_walk_state (obj_desc->method.owning_id,
next_walk_state = acpi_ds_create_walk_state (obj_desc->method.owner_id,
NULL, obj_desc, thread);
if (!next_walk_state) {
status = AE_NO_MEMORY;
Expand Down Expand Up @@ -383,6 +391,7 @@ acpi_ds_call_control_method (
/* On error, we must delete the new walk state */

cleanup:
(void) acpi_ut_release_owner_id (obj_desc->method.owner_id);
if (next_walk_state && (next_walk_state->method_desc)) {
/* Decrement the thread count on the method parse tree */

Expand Down Expand Up @@ -584,7 +593,7 @@ acpi_ds_terminate_control_method (
* Delete any namespace entries created anywhere else within
* the namespace
*/
acpi_ns_delete_namespace_by_owner (walk_state->method_desc->method.owning_id);
acpi_ns_delete_namespace_by_owner (walk_state->method_desc->method.owner_id);
status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/executer/exconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ acpi_ex_unload_table (
* Delete the entire namespace under this table Node
* (Offset contains the table_id)
*/
acpi_ns_delete_namespace_by_owner (table_info->table_id);
acpi_ns_delete_namespace_by_owner (table_info->owner_id);

/* Delete the table itself */

Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/executer/exdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ acpi_ex_dump_object_descriptor (
acpi_ex_out_integer ("param_count", obj_desc->method.param_count);
acpi_ex_out_integer ("Concurrency", obj_desc->method.concurrency);
acpi_ex_out_pointer ("Semaphore", obj_desc->method.semaphore);
acpi_ex_out_integer ("owning_id", obj_desc->method.owning_id);
acpi_ex_out_integer ("owner_id", obj_desc->method.owner_id);
acpi_ex_out_integer ("aml_length", obj_desc->method.aml_length);
acpi_ex_out_pointer ("aml_start", obj_desc->method.aml_start);
break;
Expand Down
15 changes: 3 additions & 12 deletions drivers/acpi/executer/exoparg1.c
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,7 @@ acpi_ex_opcode_1A_0T_1R (
*/
return_desc = acpi_ns_get_attached_object (
(struct acpi_namespace_node *) operand[0]);
acpi_ut_add_reference (return_desc);
}
else {
/*
Expand Down Expand Up @@ -953,20 +954,10 @@ acpi_ex_opcode_1A_0T_1R (
* add another reference to the referenced object, however.
*/
return_desc = *(operand[0]->reference.where);
if (!return_desc) {
/*
* We can't return a NULL dereferenced value. This is
* an uninitialized package element and is thus a
* severe error.
*/
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"NULL package element obj %p\n",
operand[0]));
status = AE_AML_UNINITIALIZED_ELEMENT;
goto cleanup;
if (return_desc) {
acpi_ut_add_reference (return_desc);
}

acpi_ut_add_reference (return_desc);
break;


Expand Down
16 changes: 16 additions & 0 deletions drivers/acpi/executer/exresop.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,10 @@ acpi_ex_resolve_operands (

return_ACPI_STATUS (status);
}

if (obj_desc != *stack_ptr) {
acpi_ut_remove_reference (obj_desc);
}
goto next_operand;


Expand All @@ -448,6 +452,10 @@ acpi_ex_resolve_operands (

return_ACPI_STATUS (status);
}

if (obj_desc != *stack_ptr) {
acpi_ut_remove_reference (obj_desc);
}
goto next_operand;


Expand All @@ -471,6 +479,10 @@ acpi_ex_resolve_operands (

return_ACPI_STATUS (status);
}

if (obj_desc != *stack_ptr) {
acpi_ut_remove_reference (obj_desc);
}
goto next_operand;


Expand Down Expand Up @@ -515,6 +527,10 @@ acpi_ex_resolve_operands (
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}

if (obj_desc != *stack_ptr) {
acpi_ut_remove_reference (obj_desc);
}
break;

default:
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/namespace/nsaccess.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ acpi_ns_root_initialize (

/*
* i_aSL Compiler cheats by putting parameter count
* in the owner_iD
* in the owner_iD (param_count max is 7)
*/
new_node->owner_id = obj_desc->method.param_count;
#else
Expand Down
5 changes: 3 additions & 2 deletions drivers/acpi/namespace/nsalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ acpi_ns_install_node (
struct acpi_namespace_node *node, /* New Child*/
acpi_object_type type)
{
u16 owner_id = 0;
acpi_owner_id owner_id = 0;
struct acpi_namespace_node *child_node;
#ifdef ACPI_ALPHABETIC_NAMESPACE

Expand Down Expand Up @@ -559,7 +559,7 @@ acpi_ns_remove_reference (

void
acpi_ns_delete_namespace_by_owner (
u16 owner_id)
acpi_owner_id owner_id)
{
struct acpi_namespace_node *child_node;
struct acpi_namespace_node *deletion_node;
Expand Down Expand Up @@ -635,6 +635,7 @@ acpi_ns_delete_namespace_by_owner (
}
}

(void) acpi_ut_release_owner_id (owner_id);
return_VOID;
}

Expand Down
8 changes: 4 additions & 4 deletions drivers/acpi/namespace/nsdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ acpi_ns_dump_one_object (

/* Check if the owner matches */

if ((info->owner_id != ACPI_UINT32_MAX) &&
if ((info->owner_id != ACPI_OWNER_ID_MAX) &&
(info->owner_id != this_node->owner_id)) {
return (AE_OK);
}
Expand Down Expand Up @@ -598,7 +598,7 @@ acpi_ns_dump_objects (
acpi_object_type type,
u8 display_type,
u32 max_depth,
u32 owner_id,
acpi_owner_id owner_id,
acpi_handle start_handle)
{
struct acpi_walk_info info;
Expand Down Expand Up @@ -643,7 +643,7 @@ acpi_ns_dump_entry (


info.debug_level = debug_level;
info.owner_id = ACPI_UINT32_MAX;
info.owner_id = ACPI_OWNER_ID_MAX;
info.display_type = ACPI_DISPLAY_SUMMARY;

(void) acpi_ns_dump_one_object (handle, 1, &info, NULL);
Expand Down Expand Up @@ -694,7 +694,7 @@ acpi_ns_dump_tables (
}

acpi_ns_dump_objects (ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, max_depth,
ACPI_UINT32_MAX, search_handle);
ACPI_OWNER_ID_MAX, search_handle);
return_VOID;
}
#endif /* _ACPI_ASL_COMPILER */
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/namespace/nsparse.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ acpi_ns_one_complete_parse (

/* Create and initialize a new walk state */

walk_state = acpi_ds_create_walk_state (table_desc->table_id,
walk_state = acpi_ds_create_walk_state (table_desc->owner_id,
NULL, NULL, NULL);
if (!walk_state) {
acpi_ps_free_op (parse_root);
Expand Down
9 changes: 7 additions & 2 deletions drivers/acpi/parser/psloop.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,14 @@ acpi_ps_parse_loop (
INCREMENT_ARG_LIST (walk_state->arg_types);
}


/* Special processing for certain opcodes */

if ((walk_state->pass_number <= ACPI_IMODE_LOAD_PASS1) &&
/* TBD (remove): Temporary mechanism to disable this code if needed */

#ifndef ACPI_NO_MODULE_LEVEL_CODE

if ((walk_state->pass_number <= ACPI_IMODE_LOAD_PASS1) &&
((walk_state->parse_flags & ACPI_PARSE_DISASSEMBLE) == 0)) {
/*
* We want to skip If/Else/While constructs during Pass1
Expand All @@ -434,7 +439,7 @@ acpi_ps_parse_loop (
break;
}
}

#endif
switch (op->common.aml_opcode) {
case AML_METHOD_OP:

Expand Down
7 changes: 5 additions & 2 deletions drivers/acpi/parser/psxface.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,14 @@ acpi_psx_execute (
* objects (such as Operation Regions) can be created during the
* first pass parse.
*/
obj_desc->method.owning_id = acpi_ut_allocate_owner_id (ACPI_OWNER_TYPE_METHOD);
status = acpi_ut_allocate_owner_id (&obj_desc->method.owner_id);
if (ACPI_FAILURE (status)) {
goto cleanup2;
}

/* Create and initialize a new walk state */

walk_state = acpi_ds_create_walk_state (obj_desc->method.owning_id,
walk_state = acpi_ds_create_walk_state (obj_desc->method.owner_id,
NULL, NULL, NULL);
if (!walk_state) {
status = AE_NO_MEMORY;
Expand Down
Loading

0 comments on commit f9f4601

Please sign in to comment.