aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/dispatcher/dsmethod.c
diff options
context:
space:
mode:
authorRobert Moore <robert.moore@intel.com>2005-07-08 00:00:00 -0400
committerLen Brown <len.brown@intel.com>2005-07-14 00:42:23 -0400
commitf9f4601f331aa1226d7a798a01950efbb388f07f (patch)
tree62e079a9275749d16a4a0da56a427be201e15d27 /drivers/acpi/dispatcher/dsmethod.c
parent4c3ffbd79529b680b3c3ef2b6f42f0c89c694ec5 (diff)
ACPICA 20050708 from Bob Moore <robert.moore@intel.com>
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 <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/dispatcher/dsmethod.c')
-rw-r--r--drivers/acpi/dispatcher/dsmethod.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/drivers/acpi/dispatcher/dsmethod.c b/drivers/acpi/dispatcher/dsmethod.c
index c9d9a6c45ae3..1b90813cbde1 100644
--- a/drivers/acpi/dispatcher/dsmethod.c
+++ b/drivers/acpi/dispatcher/dsmethod.c
@@ -77,7 +77,6 @@ acpi_ds_parse_method (
77 union acpi_operand_object *obj_desc; 77 union acpi_operand_object *obj_desc;
78 union acpi_parse_object *op; 78 union acpi_parse_object *op;
79 struct acpi_namespace_node *node; 79 struct acpi_namespace_node *node;
80 acpi_owner_id owner_id;
81 struct acpi_walk_state *walk_state; 80 struct acpi_walk_state *walk_state;
82 81
83 82
@@ -132,15 +131,18 @@ acpi_ds_parse_method (
132 * objects (such as Operation Regions) can be created during the 131 * objects (such as Operation Regions) can be created during the
133 * first pass parse. 132 * first pass parse.
134 */ 133 */
135 owner_id = acpi_ut_allocate_owner_id (ACPI_OWNER_TYPE_METHOD); 134 status = acpi_ut_allocate_owner_id (&obj_desc->method.owner_id);
136 obj_desc->method.owning_id = owner_id; 135 if (ACPI_FAILURE (status)) {
136 goto cleanup;
137 }
137 138
138 /* Create and initialize a new walk state */ 139 /* Create and initialize a new walk state */
139 140
140 walk_state = acpi_ds_create_walk_state (owner_id, NULL, NULL, NULL); 141 walk_state = acpi_ds_create_walk_state (
142 obj_desc->method.owner_id, NULL, NULL, NULL);
141 if (!walk_state) { 143 if (!walk_state) {
142 status = AE_NO_MEMORY; 144 status = AE_NO_MEMORY;
143 goto cleanup; 145 goto cleanup2;
144 } 146 }
145 147
146 status = acpi_ds_init_aml_walk (walk_state, op, node, 148 status = acpi_ds_init_aml_walk (walk_state, op, node,
@@ -148,7 +150,7 @@ acpi_ds_parse_method (
148 obj_desc->method.aml_length, NULL, 1); 150 obj_desc->method.aml_length, NULL, 1);
149 if (ACPI_FAILURE (status)) { 151 if (ACPI_FAILURE (status)) {
150 acpi_ds_delete_walk_state (walk_state); 152 acpi_ds_delete_walk_state (walk_state);
151 goto cleanup; 153 goto cleanup2;
152 } 154 }
153 155
154 /* 156 /*
@@ -162,13 +164,16 @@ acpi_ds_parse_method (
162 */ 164 */
163 status = acpi_ps_parse_aml (walk_state); 165 status = acpi_ps_parse_aml (walk_state);
164 if (ACPI_FAILURE (status)) { 166 if (ACPI_FAILURE (status)) {
165 goto cleanup; 167 goto cleanup2;
166 } 168 }
167 169
168 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, 170 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
169 "**** [%4.4s] Parsed **** named_obj=%p Op=%p\n", 171 "**** [%4.4s] Parsed **** named_obj=%p Op=%p\n",
170 acpi_ut_get_node_name (obj_handle), obj_handle, op)); 172 acpi_ut_get_node_name (obj_handle), obj_handle, op));
171 173
174cleanup2:
175 (void) acpi_ut_release_owner_id (obj_desc->method.owner_id);
176
172cleanup: 177cleanup:
173 acpi_ps_delete_parse_tree (op); 178 acpi_ps_delete_parse_tree (op);
174 return_ACPI_STATUS (status); 179 return_ACPI_STATUS (status);
@@ -265,7 +270,7 @@ acpi_ds_call_control_method (
265{ 270{
266 acpi_status status; 271 acpi_status status;
267 struct acpi_namespace_node *method_node; 272 struct acpi_namespace_node *method_node;
268 struct acpi_walk_state *next_walk_state; 273 struct acpi_walk_state *next_walk_state = NULL;
269 union acpi_operand_object *obj_desc; 274 union acpi_operand_object *obj_desc;
270 struct acpi_parameter_info info; 275 struct acpi_parameter_info info;
271 u32 i; 276 u32 i;
@@ -289,20 +294,23 @@ acpi_ds_call_control_method (
289 return_ACPI_STATUS (AE_NULL_OBJECT); 294 return_ACPI_STATUS (AE_NULL_OBJECT);
290 } 295 }
291 296
292 obj_desc->method.owning_id = acpi_ut_allocate_owner_id (ACPI_OWNER_TYPE_METHOD); 297 status = acpi_ut_allocate_owner_id (&obj_desc->method.owner_id);
298 if (ACPI_FAILURE (status)) {
299 return_ACPI_STATUS (status);
300 }
293 301
294 /* Init for new method, wait on concurrency semaphore */ 302 /* Init for new method, wait on concurrency semaphore */
295 303
296 status = acpi_ds_begin_method_execution (method_node, obj_desc, 304 status = acpi_ds_begin_method_execution (method_node, obj_desc,
297 this_walk_state->method_node); 305 this_walk_state->method_node);
298 if (ACPI_FAILURE (status)) { 306 if (ACPI_FAILURE (status)) {
299 return_ACPI_STATUS (status); 307 goto cleanup;
300 } 308 }
301 309
302 if (!(obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY)) { 310 if (!(obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY)) {
303 /* 1) Parse: Create a new walk state for the preempting walk */ 311 /* 1) Parse: Create a new walk state for the preempting walk */
304 312
305 next_walk_state = acpi_ds_create_walk_state (obj_desc->method.owning_id, 313 next_walk_state = acpi_ds_create_walk_state (obj_desc->method.owner_id,
306 op, obj_desc, NULL); 314 op, obj_desc, NULL);
307 if (!next_walk_state) { 315 if (!next_walk_state) {
308 return_ACPI_STATUS (AE_NO_MEMORY); 316 return_ACPI_STATUS (AE_NO_MEMORY);
@@ -332,7 +340,7 @@ acpi_ds_call_control_method (
332 340
333 /* 2) Execute: Create a new state for the preempting walk */ 341 /* 2) Execute: Create a new state for the preempting walk */
334 342
335 next_walk_state = acpi_ds_create_walk_state (obj_desc->method.owning_id, 343 next_walk_state = acpi_ds_create_walk_state (obj_desc->method.owner_id,
336 NULL, obj_desc, thread); 344 NULL, obj_desc, thread);
337 if (!next_walk_state) { 345 if (!next_walk_state) {
338 status = AE_NO_MEMORY; 346 status = AE_NO_MEMORY;
@@ -383,6 +391,7 @@ acpi_ds_call_control_method (
383 /* On error, we must delete the new walk state */ 391 /* On error, we must delete the new walk state */
384 392
385cleanup: 393cleanup:
394 (void) acpi_ut_release_owner_id (obj_desc->method.owner_id);
386 if (next_walk_state && (next_walk_state->method_desc)) { 395 if (next_walk_state && (next_walk_state->method_desc)) {
387 /* Decrement the thread count on the method parse tree */ 396 /* Decrement the thread count on the method parse tree */
388 397
@@ -584,7 +593,7 @@ acpi_ds_terminate_control_method (
584 * Delete any namespace entries created anywhere else within 593 * Delete any namespace entries created anywhere else within
585 * the namespace 594 * the namespace
586 */ 595 */
587 acpi_ns_delete_namespace_by_owner (walk_state->method_desc->method.owning_id); 596 acpi_ns_delete_namespace_by_owner (walk_state->method_desc->method.owner_id);
588 status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 597 status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
589 if (ACPI_FAILURE (status)) { 598 if (ACPI_FAILURE (status)) {
590 return_ACPI_STATUS (status); 599 return_ACPI_STATUS (status);