aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/utilities/utdelete.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/utilities/utdelete.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/utilities/utdelete.c')
-rw-r--r--drivers/acpi/utilities/utdelete.c98
1 files changed, 31 insertions, 67 deletions
diff --git a/drivers/acpi/utilities/utdelete.c b/drivers/acpi/utilities/utdelete.c
index be97ada23c3d..eeafb324c504 100644
--- a/drivers/acpi/utilities/utdelete.c
+++ b/drivers/acpi/utilities/utdelete.c
@@ -435,35 +435,24 @@ acpi_ut_update_object_reference (
435 union acpi_operand_object *object, 435 union acpi_operand_object *object,
436 u16 action) 436 u16 action)
437{ 437{
438 acpi_status status; 438 acpi_status status = AE_OK;
439 u32 i; 439 union acpi_generic_state *state_list = NULL;
440 union acpi_generic_state *state_list = NULL; 440 union acpi_operand_object *next_object = NULL;
441 union acpi_generic_state *state; 441 union acpi_generic_state *state;
442 acpi_native_uint i;
442 443
443 444
444 ACPI_FUNCTION_TRACE_PTR ("ut_update_object_reference", object); 445 ACPI_FUNCTION_TRACE_PTR ("ut_update_object_reference", object);
445 446
446 447
447 /* Ignore a null object ptr */ 448 while (object) {
449 /* Make sure that this isn't a namespace handle */
448 450
449 if (!object) { 451 if (ACPI_GET_DESCRIPTOR_TYPE (object) == ACPI_DESC_TYPE_NAMED) {
450 return_ACPI_STATUS (AE_OK); 452 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
451 } 453 "Object %p is NS handle\n", object));
452 454 return_ACPI_STATUS (AE_OK);
453 /* Make sure that this isn't a namespace handle */ 455 }
454
455 if (ACPI_GET_DESCRIPTOR_TYPE (object) == ACPI_DESC_TYPE_NAMED) {
456 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
457 "Object %p is NS handle\n", object));
458 return_ACPI_STATUS (AE_OK);
459 }
460
461 state = acpi_ut_create_update_state (object, action);
462
463 while (state) {
464 object = state->update.object;
465 action = state->update.value;
466 acpi_ut_delete_generic_state (state);
467 456
468 /* 457 /*
469 * All sub-objects must have their reference count incremented also. 458 * All sub-objects must have their reference count incremented also.
@@ -476,12 +465,10 @@ acpi_ut_update_object_reference (
476 acpi_ut_update_ref_count (object->device.device_notify, action); 465 acpi_ut_update_ref_count (object->device.device_notify, action);
477 break; 466 break;
478 467
479
480 case ACPI_TYPE_PACKAGE: 468 case ACPI_TYPE_PACKAGE:
481
482 /* 469 /*
483 * We must update all the sub-objects of the package 470 * We must update all the sub-objects of the package,
484 * (Each of whom may have their own sub-objects, etc. 471 * each of whom may have their own sub-objects.
485 */ 472 */
486 for (i = 0; i < object->package.count; i++) { 473 for (i = 0; i < object->package.count; i++) {
487 /* 474 /*
@@ -497,35 +484,19 @@ acpi_ut_update_object_reference (
497 } 484 }
498 break; 485 break;
499 486
500
501 case ACPI_TYPE_BUFFER_FIELD: 487 case ACPI_TYPE_BUFFER_FIELD:
502 488
503 status = acpi_ut_create_update_state_and_push ( 489 next_object = object->buffer_field.buffer_obj;
504 object->buffer_field.buffer_obj, action, &state_list);
505 if (ACPI_FAILURE (status)) {
506 goto error_exit;
507 }
508 break; 490 break;
509 491
510
511 case ACPI_TYPE_LOCAL_REGION_FIELD: 492 case ACPI_TYPE_LOCAL_REGION_FIELD:
512 493
513 status = acpi_ut_create_update_state_and_push ( 494 next_object = object->field.region_obj;
514 object->field.region_obj, action, &state_list); 495 break;
515 if (ACPI_FAILURE (status)) {
516 goto error_exit;
517 }
518 break;
519
520 496
521 case ACPI_TYPE_LOCAL_BANK_FIELD: 497 case ACPI_TYPE_LOCAL_BANK_FIELD:
522 498
523 status = acpi_ut_create_update_state_and_push ( 499 next_object = object->bank_field.bank_obj;
524 object->bank_field.bank_obj, action, &state_list);
525 if (ACPI_FAILURE (status)) {
526 goto error_exit;
527 }
528
529 status = acpi_ut_create_update_state_and_push ( 500 status = acpi_ut_create_update_state_and_push (
530 object->bank_field.region_obj, action, &state_list); 501 object->bank_field.region_obj, action, &state_list);
531 if (ACPI_FAILURE (status)) { 502 if (ACPI_FAILURE (status)) {
@@ -533,15 +504,9 @@ acpi_ut_update_object_reference (
533 } 504 }
534 break; 505 break;
535 506
536
537 case ACPI_TYPE_LOCAL_INDEX_FIELD: 507 case ACPI_TYPE_LOCAL_INDEX_FIELD:
538 508
539 status = acpi_ut_create_update_state_and_push ( 509 next_object = object->index_field.index_obj;
540 object->index_field.index_obj, action, &state_list);
541 if (ACPI_FAILURE (status)) {
542 goto error_exit;
543 }
544
545 status = acpi_ut_create_update_state_and_push ( 510 status = acpi_ut_create_update_state_and_push (
546 object->index_field.data_obj, action, &state_list); 511 object->index_field.data_obj, action, &state_list);
547 if (ACPI_FAILURE (status)) { 512 if (ACPI_FAILURE (status)) {
@@ -549,28 +514,19 @@ acpi_ut_update_object_reference (
549 } 514 }
550 break; 515 break;
551 516
552
553 case ACPI_TYPE_LOCAL_REFERENCE: 517 case ACPI_TYPE_LOCAL_REFERENCE:
554
555 /* 518 /*
556 * The target of an Index (a package, string, or buffer) must track 519 * The target of an Index (a package, string, or buffer) must track
557 * changes to the ref count of the index. 520 * changes to the ref count of the index.
558 */ 521 */
559 if (object->reference.opcode == AML_INDEX_OP) { 522 if (object->reference.opcode == AML_INDEX_OP) {
560 status = acpi_ut_create_update_state_and_push ( 523 next_object = object->reference.object;
561 object->reference.object, action, &state_list);
562 if (ACPI_FAILURE (status)) {
563 goto error_exit;
564 }
565 } 524 }
566 break; 525 break;
567 526
568
569 case ACPI_TYPE_REGION: 527 case ACPI_TYPE_REGION:
570 default: 528 default:
571 529 break;/* No subobjects */
572 /* No subobjects */
573 break;
574 } 530 }
575 531
576 /* 532 /*
@@ -579,15 +535,23 @@ acpi_ut_update_object_reference (
579 * main object to be deleted. 535 * main object to be deleted.
580 */ 536 */
581 acpi_ut_update_ref_count (object, action); 537 acpi_ut_update_ref_count (object, action);
538 object = NULL;
582 539
583 /* Move on to the next object to be updated */ 540 /* Move on to the next object to be updated */
584 541
585 state = acpi_ut_pop_generic_state (&state_list); 542 if (next_object) {
543 object = next_object;
544 next_object = NULL;
545 }
546 else if (state_list) {
547 state = acpi_ut_pop_generic_state (&state_list);
548 object = state->update.object;
549 acpi_ut_delete_generic_state (state);
550 }
586 } 551 }
587 552
588 return_ACPI_STATUS (AE_OK); 553 return_ACPI_STATUS (AE_OK);
589 554
590
591error_exit: 555error_exit:
592 556
593 ACPI_REPORT_ERROR (("Could not update object reference count, %s\n", 557 ACPI_REPORT_ERROR (("Could not update object reference count, %s\n",