Print this page
acpica-unix2-20130823
PANKOVs restructure
*** 3,13 ****
* Module Name: utdelete - object deletion and reference count utilities
*
******************************************************************************/
/*
! * Copyright (C) 2000 - 2011, Intel Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
--- 3,13 ----
* Module Name: utdelete - object deletion and reference count utilities
*
******************************************************************************/
/*
! * Copyright (C) 2000 - 2013, Intel Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*** 116,126 ****
ObjPointer = Object->String.Pointer;
}
break;
-
case ACPI_TYPE_BUFFER:
ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "**** Buffer %p, ptr %p\n",
Object, Object->Buffer.Pointer));
--- 116,125 ----
*** 132,142 ****
ObjPointer = Object->Buffer.Pointer;
}
break;
-
case ACPI_TYPE_PACKAGE:
ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, " **** Package of count %X\n",
Object->Package.Count));
--- 131,140 ----
*** 148,158 ****
/* Free the (variable length) element pointer array */
ObjPointer = Object->Package.Elements;
break;
-
/*
* These objects have a possible list of notify handlers.
* Device object also may have a GPE block.
*/
case ACPI_TYPE_DEVICE:
--- 146,155 ----
*** 165,175 ****
/*lint -fallthrough */
case ACPI_TYPE_PROCESSOR:
case ACPI_TYPE_THERMAL:
! /* Walk the notify handler list for this object */
HandlerDesc = Object->CommonNotify.Handler;
while (HandlerDesc)
{
NextDesc = HandlerDesc->AddressSpace.Next;
--- 162,172 ----
/*lint -fallthrough */
case ACPI_TYPE_PROCESSOR:
case ACPI_TYPE_THERMAL:
! /* Walk the address handler list for this object */
HandlerDesc = Object->CommonNotify.Handler;
while (HandlerDesc)
{
NextDesc = HandlerDesc->AddressSpace.Next;
*** 176,186 ****
AcpiUtRemoveReference (HandlerDesc);
HandlerDesc = NextDesc;
}
break;
-
case ACPI_TYPE_MUTEX:
ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
"***** Mutex %p, OS Mutex %p\n",
Object, Object->Mutex.OsMutex));
--- 173,182 ----
*** 200,210 ****
AcpiExUnlinkMutex (Object);
AcpiOsDeleteMutex (Object->Mutex.OsMutex);
}
break;
-
case ACPI_TYPE_EVENT:
ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
"***** Event %p, OS Semaphore %p\n",
Object, Object->Event.OsSemaphore));
--- 196,205 ----
*** 211,221 ****
(void) AcpiOsDeleteSemaphore (Object->Event.OsSemaphore);
Object->Event.OsSemaphore = NULL;
break;
-
case ACPI_TYPE_METHOD:
ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
"***** Method %p\n", Object));
--- 206,215 ----
*** 227,242 ****
AcpiUtDeleteObjectDesc (Object->Method.Mutex);
Object->Method.Mutex = NULL;
}
break;
-
case ACPI_TYPE_REGION:
ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
"***** Region %p\n", Object));
SecondDesc = AcpiNsGetSecondaryObject (Object);
if (SecondDesc)
{
/*
* Free the RegionContext if and only if the handler is one of the
--- 221,245 ----
AcpiUtDeleteObjectDesc (Object->Method.Mutex);
Object->Method.Mutex = NULL;
}
break;
case ACPI_TYPE_REGION:
ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
"***** Region %p\n", Object));
+ /*
+ * Update AddressRange list. However, only permanent regions
+ * are installed in this list. (Not created within a method)
+ */
+ if (!(Object->Region.Node->Flags & ANOBJ_TEMPORARY))
+ {
+ AcpiUtRemoveAddressRange (Object->Region.SpaceId,
+ Object->Region.Node);
+ }
+
SecondDesc = AcpiNsGetSecondaryObject (Object);
if (SecondDesc)
{
/*
* Free the RegionContext if and only if the handler is one of the
*** 286,296 ****
AcpiUtDeleteObjectDesc (SecondDesc);
}
break;
-
case ACPI_TYPE_BUFFER_FIELD:
ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
"***** Buffer Field %p\n", Object));
--- 289,298 ----
*** 299,309 ****
{
AcpiUtDeleteObjectDesc (SecondDesc);
}
break;
-
case ACPI_TYPE_LOCAL_BANK_FIELD:
ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
"***** Bank Field %p\n", Object));
--- 301,310 ----
*** 312,323 ****
{
AcpiUtDeleteObjectDesc (SecondDesc);
}
break;
-
default:
break;
}
/* Free any allocated memory (pointer within the object) found above */
--- 313,324 ----
{
AcpiUtDeleteObjectDesc (SecondDesc);
}
break;
default:
+
break;
}
/* Free any allocated memory (pointer within the object) found above */
*** 356,366 ****
ACPI_OPERAND_OBJECT **ObjList)
{
ACPI_OPERAND_OBJECT **InternalObj;
! ACPI_FUNCTION_TRACE (UtDeleteInternalObjectList);
/* Walk the null-terminated internal list */
for (InternalObj = ObjList; *InternalObj; InternalObj++)
--- 357,367 ----
ACPI_OPERAND_OBJECT **ObjList)
{
ACPI_OPERAND_OBJECT **InternalObj;
! ACPI_FUNCTION_ENTRY ();
/* Walk the null-terminated internal list */
for (InternalObj = ObjList; *InternalObj; InternalObj++)
*** 369,402 ****
}
/* Free the combined parameter pointer list and object array */
ACPI_FREE (ObjList);
! return_VOID;
}
/*******************************************************************************
*
* FUNCTION: AcpiUtUpdateRefCount
*
* PARAMETERS: Object - Object whose ref count is to be updated
! * Action - What to do
*
! * RETURN: New ref count
*
! * DESCRIPTION: Modify the ref count and return it.
*
******************************************************************************/
static void
AcpiUtUpdateRefCount (
ACPI_OPERAND_OBJECT *Object,
UINT32 Action)
{
! UINT16 Count;
! UINT16 NewCount;
ACPI_FUNCTION_NAME (UtUpdateRefCount);
--- 370,404 ----
}
/* Free the combined parameter pointer list and object array */
ACPI_FREE (ObjList);
! return;
}
/*******************************************************************************
*
* FUNCTION: AcpiUtUpdateRefCount
*
* PARAMETERS: Object - Object whose ref count is to be updated
! * Action - What to do (REF_INCREMENT or REF_DECREMENT)
*
! * RETURN: None. Sets new reference count within the object
*
! * DESCRIPTION: Modify the reference count for an internal acpi object
*
******************************************************************************/
static void
AcpiUtUpdateRefCount (
ACPI_OPERAND_OBJECT *Object,
UINT32 Action)
{
! UINT16 OriginalCount;
! UINT16 NewCount = 0;
! ACPI_CPU_FLAGS LockFlags;
ACPI_FUNCTION_NAME (UtUpdateRefCount);
*** 403,486 ****
if (!Object)
{
return;
}
- Count = Object->Common.ReferenceCount;
- NewCount = Count;
-
/*
! * Perform the reference count action (increment, decrement, force delete)
*/
switch (Action)
{
case REF_INCREMENT:
! NewCount++;
Object->Common.ReferenceCount = NewCount;
ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
! "Obj %p Refs=%X, [Incremented]\n",
! Object, NewCount));
break;
case REF_DECREMENT:
! if (Count < 1)
! {
! ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
! "Obj %p Refs=%X, can't decrement! (Set to 0)\n",
! Object, NewCount));
! NewCount = 0;
! }
! else
{
! NewCount--;
!
! ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
! "Obj %p Refs=%X, [Decremented]\n",
! Object, NewCount));
}
! if (Object->Common.Type == ACPI_TYPE_METHOD)
{
! ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
! "Method Obj %p Refs=%X, [Decremented]\n", Object, NewCount));
}
! Object->Common.ReferenceCount = NewCount;
if (NewCount == 0)
{
AcpiUtDeleteInternalObj (Object);
}
break;
- case REF_FORCE_DELETE:
-
- ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
- "Obj %p Refs=%X, Force delete! (Set to 0)\n", Object, Count));
-
- NewCount = 0;
- Object->Common.ReferenceCount = NewCount;
- AcpiUtDeleteInternalObj (Object);
- break;
-
default:
! ACPI_ERROR ((AE_INFO, "Unknown action (0x%X)", Action));
! break;
}
/*
* Sanity check the reference count, for debug purposes only.
* (A deleted object will have a huge reference count)
*/
! if (Count > ACPI_MAX_REFERENCE_COUNT)
{
ACPI_WARNING ((AE_INFO,
! "Large Reference Count (0x%X) in object %p", Count, Object));
}
}
/*******************************************************************************
--- 405,493 ----
if (!Object)
{
return;
}
/*
! * Always get the reference count lock. Note: Interpreter and/or
! * Namespace is not always locked when this function is called.
*/
+ LockFlags = AcpiOsAcquireLock (AcpiGbl_ReferenceCountLock);
+ OriginalCount = Object->Common.ReferenceCount;
+
+ /* Perform the reference count action (increment, decrement) */
+
switch (Action)
{
case REF_INCREMENT:
! NewCount = OriginalCount + 1;
Object->Common.ReferenceCount = NewCount;
+ AcpiOsReleaseLock (AcpiGbl_ReferenceCountLock, LockFlags);
+ /* The current reference count should never be zero here */
+
+ if (!OriginalCount)
+ {
+ ACPI_WARNING ((AE_INFO,
+ "Obj %p, Reference Count was zero before increment\n",
+ Object));
+ }
+
ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
! "Obj %p Type %.2X Refs %.2X [Incremented]\n",
! Object, Object->Common.Type, NewCount));
break;
case REF_DECREMENT:
! /* The current reference count must be non-zero */
! if (OriginalCount)
{
! NewCount = OriginalCount - 1;
! Object->Common.ReferenceCount = NewCount;
}
! AcpiOsReleaseLock (AcpiGbl_ReferenceCountLock, LockFlags);
!
! if (!OriginalCount)
{
! ACPI_WARNING ((AE_INFO,
! "Obj %p, Reference Count is already zero, cannot decrement\n",
! Object));
}
! ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
! "Obj %p Type %.2X Refs %.2X [Decremented]\n",
! Object, Object->Common.Type, NewCount));
!
! /* Actually delete the object on a reference count of zero */
!
if (NewCount == 0)
{
AcpiUtDeleteInternalObj (Object);
}
break;
default:
! AcpiOsReleaseLock (AcpiGbl_ReferenceCountLock, LockFlags);
! ACPI_ERROR ((AE_INFO, "Unknown Reference Count action (0x%X)",
! Action));
! return;
}
/*
* Sanity check the reference count, for debug purposes only.
* (A deleted object will have a huge reference count)
*/
! if (NewCount > ACPI_MAX_REFERENCE_COUNT)
{
ACPI_WARNING ((AE_INFO,
! "Large Reference Count (0x%X) in object %p, Type=0x%.2X",
! NewCount, Object, Object->Common.Type));
}
}
/*******************************************************************************
*** 487,498 ****
*
* FUNCTION: AcpiUtUpdateObjectReference
*
* PARAMETERS: Object - Increment ref count for this object
* and all sub-objects
! * Action - Either REF_INCREMENT or REF_DECREMENT or
! * REF_FORCE_DELETE
*
* RETURN: Status
*
* DESCRIPTION: Increment the object reference count
*
--- 494,504 ----
*
* FUNCTION: AcpiUtUpdateObjectReference
*
* PARAMETERS: Object - Increment ref count for this object
* and all sub-objects
! * Action - Either REF_INCREMENT or REF_DECREMENT
*
* RETURN: Status
*
* DESCRIPTION: Increment the object reference count
*
*** 511,525 ****
UINT16 Action)
{
ACPI_STATUS Status = AE_OK;
ACPI_GENERIC_STATE *StateList = NULL;
ACPI_OPERAND_OBJECT *NextObject = NULL;
ACPI_GENERIC_STATE *State;
UINT32 i;
! ACPI_FUNCTION_TRACE_PTR (UtUpdateObjectReference, Object);
while (Object)
{
/* Make sure that this isn't a namespace handle */
--- 517,532 ----
UINT16 Action)
{
ACPI_STATUS Status = AE_OK;
ACPI_GENERIC_STATE *StateList = NULL;
ACPI_OPERAND_OBJECT *NextObject = NULL;
+ ACPI_OPERAND_OBJECT *PrevObject;
ACPI_GENERIC_STATE *State;
UINT32 i;
! ACPI_FUNCTION_NAME (UtUpdateObjectReference);
while (Object)
{
/* Make sure that this isn't a namespace handle */
*** 526,536 ****
if (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED)
{
ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
"Object %p is NS handle\n", Object));
! return_ACPI_STATUS (AE_OK);
}
/*
* All sub-objects must have their reference count incremented also.
* Different object types have different subobjects.
--- 533,543 ----
if (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED)
{
ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
"Object %p is NS handle\n", Object));
! return (AE_OK);
}
/*
* All sub-objects must have their reference count incremented also.
* Different object types have different subobjects.
*** 539,553 ****
{
case ACPI_TYPE_DEVICE:
case ACPI_TYPE_PROCESSOR:
case ACPI_TYPE_POWER:
case ACPI_TYPE_THERMAL:
!
! /* Update the notify objects for these types (if present) */
!
! AcpiUtUpdateRefCount (Object->CommonNotify.SystemNotify, Action);
! AcpiUtUpdateRefCount (Object->CommonNotify.DeviceNotify, Action);
break;
case ACPI_TYPE_PACKAGE:
/*
* We must update all the sub-objects of the package,
--- 546,569 ----
{
case ACPI_TYPE_DEVICE:
case ACPI_TYPE_PROCESSOR:
case ACPI_TYPE_POWER:
case ACPI_TYPE_THERMAL:
! /*
! * Update the notify objects for these types (if present)
! * Two lists, system and device notify handlers.
! */
! for (i = 0; i < ACPI_NUM_NOTIFY_TYPES; i++)
! {
! PrevObject = Object->CommonNotify.NotifyList[i];
! while (PrevObject)
! {
! NextObject = PrevObject->Notify.Next[i];
! AcpiUtUpdateRefCount (PrevObject, Action);
! PrevObject = NextObject;
! }
! }
break;
case ACPI_TYPE_PACKAGE:
/*
* We must update all the sub-objects of the package,
*** 554,574 ****
* each of whom may have their own sub-objects.
*/
for (i = 0; i < Object->Package.Count; i++)
{
/*
! * Push each element onto the stack for later processing.
! * Note: There can be null elements within the package,
! * these are simply ignored
*/
Status = AcpiUtCreateUpdateStateAndPush (
! Object->Package.Elements[i], Action, &StateList);
if (ACPI_FAILURE (Status))
{
goto ErrorExit;
}
}
break;
case ACPI_TYPE_BUFFER_FIELD:
NextObject = Object->BufferField.BufferObj;
--- 570,616 ----
* each of whom may have their own sub-objects.
*/
for (i = 0; i < Object->Package.Count; i++)
{
/*
! * Null package elements are legal and can be simply
! * ignored.
*/
+ NextObject = Object->Package.Elements[i];
+ if (!NextObject)
+ {
+ continue;
+ }
+
+ switch (NextObject->Common.Type)
+ {
+ case ACPI_TYPE_INTEGER:
+ case ACPI_TYPE_STRING:
+ case ACPI_TYPE_BUFFER:
+ /*
+ * For these very simple sub-objects, we can just
+ * update the reference count here and continue.
+ * Greatly increases performance of this operation.
+ */
+ AcpiUtUpdateRefCount (NextObject, Action);
+ break;
+
+ default:
+ /*
+ * For complex sub-objects, push them onto the stack
+ * for later processing (this eliminates recursion.)
+ */
Status = AcpiUtCreateUpdateStateAndPush (
! NextObject, Action, &StateList);
if (ACPI_FAILURE (Status))
{
goto ErrorExit;
}
+ break;
}
+ }
+ NextObject = NULL;
break;
case ACPI_TYPE_BUFFER_FIELD:
NextObject = Object->BufferField.BufferObj;
*** 614,623 ****
--- 656,666 ----
}
break;
case ACPI_TYPE_REGION:
default:
+
break; /* No subobjects for all other types */
}
/*
* Now we can update the count in the main object. This can only
*** 640,650 ****
Object = State->Update.Object;
AcpiUtDeleteGenericState (State);
}
}
! return_ACPI_STATUS (AE_OK);
ErrorExit:
ACPI_EXCEPTION ((AE_INFO, Status,
--- 683,693 ----
Object = State->Update.Object;
AcpiUtDeleteGenericState (State);
}
}
! return (AE_OK);
ErrorExit:
ACPI_EXCEPTION ((AE_INFO, Status,
*** 656,666 ****
{
State = AcpiUtPopGenericState (&StateList);
AcpiUtDeleteGenericState (State);
}
! return_ACPI_STATUS (Status);
}
/*******************************************************************************
*
--- 699,709 ----
{
State = AcpiUtPopGenericState (&StateList);
AcpiUtDeleteGenericState (State);
}
! return (Status);
}
/*******************************************************************************
*
*** 678,705 ****
void
AcpiUtAddReference (
ACPI_OPERAND_OBJECT *Object)
{
! ACPI_FUNCTION_TRACE_PTR (UtAddReference, Object);
/* Ensure that we have a valid object */
if (!AcpiUtValidInternalObject (Object))
{
! return_VOID;
}
ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
"Obj %p Current Refs=%X [To Be Incremented]\n",
Object, Object->Common.ReferenceCount));
/* Increment the reference count */
(void) AcpiUtUpdateObjectReference (Object, REF_INCREMENT);
! return_VOID;
}
/*******************************************************************************
*
--- 721,748 ----
void
AcpiUtAddReference (
ACPI_OPERAND_OBJECT *Object)
{
! ACPI_FUNCTION_NAME (UtAddReference);
/* Ensure that we have a valid object */
if (!AcpiUtValidInternalObject (Object))
{
! return;
}
ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
"Obj %p Current Refs=%X [To Be Incremented]\n",
Object, Object->Common.ReferenceCount));
/* Increment the reference count */
(void) AcpiUtUpdateObjectReference (Object, REF_INCREMENT);
! return;
}
/*******************************************************************************
*
*** 716,745 ****
void
AcpiUtRemoveReference (
ACPI_OPERAND_OBJECT *Object)
{
! ACPI_FUNCTION_TRACE_PTR (UtRemoveReference, Object);
/*
* Allow a NULL pointer to be passed in, just ignore it. This saves
* each caller from having to check. Also, ignore NS nodes.
- *
*/
if (!Object ||
(ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED))
{
! return_VOID;
}
/* Ensure that we have a valid object */
if (!AcpiUtValidInternalObject (Object))
{
! return_VOID;
}
ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
"Obj %p Current Refs=%X [To Be Decremented]\n",
Object, Object->Common.ReferenceCount));
--- 759,787 ----
void
AcpiUtRemoveReference (
ACPI_OPERAND_OBJECT *Object)
{
! ACPI_FUNCTION_NAME (UtRemoveReference);
/*
* Allow a NULL pointer to be passed in, just ignore it. This saves
* each caller from having to check. Also, ignore NS nodes.
*/
if (!Object ||
(ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED))
{
! return;
}
/* Ensure that we have a valid object */
if (!AcpiUtValidInternalObject (Object))
{
! return;
}
ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
"Obj %p Current Refs=%X [To Be Decremented]\n",
Object, Object->Common.ReferenceCount));
*** 748,756 ****
* Decrement the reference count, and only actually delete the object
* if the reference count becomes 0. (Must also decrement the ref count
* of all subobjects!)
*/
(void) AcpiUtUpdateObjectReference (Object, REF_DECREMENT);
! return_VOID;
}
-
-
--- 790,796 ----
* Decrement the reference count, and only actually delete the object
* if the reference count becomes 0. (Must also decrement the ref count
* of all subobjects!)
*/
(void) AcpiUtUpdateObjectReference (Object, REF_DECREMENT);
! return;
}