Skip to content

Commit

Permalink
ACPICA: Eliminate control method 2-pass parse/execute.
Browse files Browse the repository at this point in the history
Completed an AML interpreter performance enhancement for control method
execution. Previously a 2-pass parse/execution, control methods are now
completely parsed and executed in single pass. This improves overall
interpreter performance by ~25%, reduces code size, and reduces CPU stack use.

Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Alexey Starikovskiy <alexey.y.starikovskiy@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
  • Loading branch information
Valery Podrezov authored and Len Brown committed Feb 3, 2007
1 parent 4d0b4af commit 9bc75cf
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 124 deletions.
50 changes: 4 additions & 46 deletions drivers/acpi/dispatcher/dsmethod.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ acpi_ds_call_control_method(struct acpi_thread_state *thread,
ACPI_FUNCTION_TRACE_PTR(ds_call_control_method, this_walk_state);

ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
"Execute method %p, currentstate=%p\n",
"Calling method %p, currentstate=%p\n",
this_walk_state->prev_op, this_walk_state));

/*
Expand All @@ -351,49 +351,7 @@ acpi_ds_call_control_method(struct acpi_thread_state *thread,
return_ACPI_STATUS(status);
}

/*
* 1) Parse the method. All "normal" methods are parsed for each execution.
* Internal methods (_OSI, etc.) do not require parsing.
*/
if (!(obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY)) {

/* Create a new walk state for the parse */

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

/* Create and init a parse tree root */

op = acpi_ps_create_scope_op();
if (!op) {
status = AE_NO_MEMORY;
goto cleanup;
}

status = acpi_ds_init_aml_walk(next_walk_state, op, method_node,
obj_desc->method.aml_start,
obj_desc->method.aml_length,
NULL, 1);
if (ACPI_FAILURE(status)) {
acpi_ps_delete_parse_tree(op);
goto cleanup;
}

/* Begin AML parse (deletes next_walk_state) */

status = acpi_ps_parse_aml(next_walk_state);
acpi_ps_delete_parse_tree(op);
if (ACPI_FAILURE(status)) {
goto cleanup;
}
}

/* 2) Begin method execution. Create a new walk state */
/* Begin method parse/execution. Create a new walk state */

next_walk_state = acpi_ds_create_walk_state(obj_desc->method.owner_id,
NULL, obj_desc, thread);
Expand Down Expand Up @@ -445,8 +403,8 @@ acpi_ds_call_control_method(struct acpi_thread_state *thread,
this_walk_state->num_operands = 0;

ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
"Starting nested execution, newstate=%p\n",
next_walk_state));
"**** Begin nested execution of [%4.4s] **** WalkState=%p\n",
method_node->name.ascii, next_walk_state));

/* Invoke an internal method if necessary */

Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/parser/psloop.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ acpi_ps_build_named_op(struct acpi_walk_state *walk_state,
return_ACPI_STATUS(status);
}

if (!op) {
if (!*op) {
return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE);
}

Expand Down
114 changes: 37 additions & 77 deletions drivers/acpi/parser/psxface.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ static void acpi_ps_start_trace(struct acpi_evaluate_info *info);

static void acpi_ps_stop_trace(struct acpi_evaluate_info *info);

static acpi_status acpi_ps_execute_pass(struct acpi_evaluate_info *info);

static void
acpi_ps_update_parameter_list(struct acpi_evaluate_info *info, u16 action);

Expand Down Expand Up @@ -215,6 +213,8 @@ static void acpi_ps_stop_trace(struct acpi_evaluate_info *info)
acpi_status acpi_ps_execute_method(struct acpi_evaluate_info *info)
{
acpi_status status;
union acpi_parse_object *op;
struct acpi_walk_state *walk_state;

ACPI_FUNCTION_TRACE(ps_execute_method);

Expand All @@ -234,8 +234,7 @@ acpi_status acpi_ps_execute_method(struct acpi_evaluate_info *info)
}

/*
* The caller "owns" the parameters, so give each one an extra
* reference
* The caller "owns" the parameters, so give each one an extra reference
*/
acpi_ps_update_parameter_list(info, REF_INCREMENT);

Expand All @@ -244,30 +243,50 @@ acpi_status acpi_ps_execute_method(struct acpi_evaluate_info *info)
acpi_ps_start_trace(info);

/*
* 1) Perform the first pass parse of the method to enter any
* named objects that it creates into the namespace
* Execute the method. Performs parse simultaneously
*/
ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
"**** Begin Method Parse **** Entry=%p obj=%p\n",
info->resolved_node, info->obj_desc));
"**** Begin Method Parse/Execute [%4.4s] **** Node=%p Obj=%p\n",
info->resolved_node->name.ascii, info->resolved_node,
info->obj_desc));

info->pass_number = 1;
status = acpi_ps_execute_pass(info);
if (ACPI_FAILURE(status)) {
/* Create and init a Root Node */

op = acpi_ps_create_scope_op();
if (!op) {
status = AE_NO_MEMORY;
goto cleanup;
}

/*
* 2) Execute the method. Performs second pass parse simultaneously
*/
ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
"**** Begin Method Execution **** Entry=%p obj=%p\n",
info->resolved_node, info->obj_desc));
/* Create and initialize a new walk state */

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

status = acpi_ds_init_aml_walk(walk_state, op, info->resolved_node,
info->obj_desc->method.aml_start,
info->obj_desc->method.aml_length, info,
info->pass_number);
if (ACPI_FAILURE(status)) {
acpi_ds_delete_walk_state(walk_state);
goto cleanup;
}

/* Parse the AML */

status = acpi_ps_parse_aml(walk_state);

/* walk_state was deleted by parse_aml */

cleanup:
acpi_ps_delete_parse_tree(op);

/* End optional tracing */

acpi_ps_stop_trace(info);
Expand Down Expand Up @@ -330,62 +349,3 @@ acpi_ps_update_parameter_list(struct acpi_evaluate_info *info, u16 action)
}
}
}

/*******************************************************************************
*
* FUNCTION: acpi_ps_execute_pass
*
* PARAMETERS: Info - See struct acpi_evaluate_info
* (Used: pass_number, Node, and obj_desc)
*
* RETURN: Status
*
* DESCRIPTION: Single AML pass: Parse or Execute a control method
*
******************************************************************************/

static acpi_status acpi_ps_execute_pass(struct acpi_evaluate_info *info)
{
acpi_status status;
union acpi_parse_object *op;
struct acpi_walk_state *walk_state;

ACPI_FUNCTION_TRACE(ps_execute_pass);

/* Create and init a Root Node */

op = acpi_ps_create_scope_op();
if (!op) {
return_ACPI_STATUS(AE_NO_MEMORY);
}

/* Create and initialize a new walk state */

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

status = acpi_ds_init_aml_walk(walk_state, op, info->resolved_node,
info->obj_desc->method.aml_start,
info->obj_desc->method.aml_length,
info->pass_number == 1 ? NULL : info,
info->pass_number);
if (ACPI_FAILURE(status)) {
acpi_ds_delete_walk_state(walk_state);
goto cleanup;
}

/* Parse the AML */

status = acpi_ps_parse_aml(walk_state);

/* Walk state was deleted by parse_aml */

cleanup:
acpi_ps_delete_parse_tree(op);
return_ACPI_STATUS(status);
}

0 comments on commit 9bc75cf

Please sign in to comment.