Skip to content

Commit

Permalink
Events: Fix an issue that _REG association can happen before namespac…
Browse files Browse the repository at this point in the history
…e is initialized

Current code flow cannot ensure _REG association can happen after the
namespace is initialized, so we move _REG association to where _REG was
about to run to fix this issue.

This issue is detected when AcpiEvInitializeRegion() is invoked during
the table loading. And this is one of the most important the root cause why
ACPICA table loading is split into 2 load passes. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
  • Loading branch information
Lv Zheng committed Mar 18, 2016
1 parent 16cd087 commit c508f85
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 60 deletions.
82 changes: 27 additions & 55 deletions source/components/events/evregion.c
Expand Up @@ -621,58 +621,6 @@ AcpiEvAttachRegion (
}


/*******************************************************************************
*
* FUNCTION: AcpiEvAssociateRegMethod
*
* PARAMETERS: RegionObj - Region object
*
* RETURN: Status
*
* DESCRIPTION: Find and associate _REG method to a region
*
******************************************************************************/

void
AcpiEvAssociateRegMethod (
ACPI_OPERAND_OBJECT *RegionObj)
{
const ACPI_NAME *RegNamePtr = ACPI_CAST_PTR (ACPI_NAME, METHOD_NAME__REG);
ACPI_NAMESPACE_NODE *MethodNode;
ACPI_NAMESPACE_NODE *Node;
ACPI_OPERAND_OBJECT *RegionObj2;
ACPI_STATUS Status;


ACPI_FUNCTION_TRACE (EvAssociateRegMethod);


RegionObj2 = AcpiNsGetSecondaryObject (RegionObj);
if (!RegionObj2)
{
return_VOID;
}

Node = RegionObj->Region.Node->Parent;

/* Find any "_REG" method associated with this region definition */

Status = AcpiNsSearchOneScope (
*RegNamePtr, Node, ACPI_TYPE_METHOD, &MethodNode);
if (ACPI_SUCCESS (Status))
{
/*
* The _REG method is optional and there can be only one per region
* definition. This will be executed when the handler is attached
* or removed
*/
RegionObj2->Extra.Method_REG = MethodNode;
}

return_VOID;
}


/*******************************************************************************
*
* FUNCTION: AcpiEvExecuteRegMethod
Expand All @@ -694,21 +642,45 @@ AcpiEvExecuteRegMethod (
ACPI_EVALUATE_INFO *Info;
ACPI_OPERAND_OBJECT *Args[3];
ACPI_OPERAND_OBJECT *RegionObj2;
const ACPI_NAME *RegNamePtr = ACPI_CAST_PTR (ACPI_NAME, METHOD_NAME__REG);
ACPI_NAMESPACE_NODE *MethodNode;
ACPI_NAMESPACE_NODE *Node;
ACPI_STATUS Status;


ACPI_FUNCTION_TRACE (EvExecuteRegMethod);


if (!AcpiGbl_NamespaceInitialized ||
RegionObj->Region.Handler == NULL)
{
return_ACPI_STATUS (AE_OK);
}

RegionObj2 = AcpiNsGetSecondaryObject (RegionObj);
if (!RegionObj2)
{
return_ACPI_STATUS (AE_NOT_EXIST);
}

if (RegionObj2->Extra.Method_REG == NULL ||
RegionObj->Region.Handler == NULL ||
!AcpiGbl_NamespaceInitialized)
/*
* Find any "_REG" method associated with this region definition.
* The method should always be updated as this function may be
* invoked after a namespace change.
*/
Node = RegionObj->Region.Node->Parent;
Status = AcpiNsSearchOneScope (
*RegNamePtr, Node, ACPI_TYPE_METHOD, &MethodNode);
if (ACPI_SUCCESS (Status))
{
/*
* The _REG method is optional and there can be only one per
* region definition. This will be executed when the handler is
* attached or removed.
*/
RegionObj2->Extra.Method_REG = MethodNode;
}
if (RegionObj2->Extra.Method_REG == NULL)
{
return_ACPI_STATUS (AE_OK);
}
Expand Down
1 change: 0 additions & 1 deletion source/components/events/evrgnini.c
Expand Up @@ -654,7 +654,6 @@ AcpiEvInitializeRegion (
return_ACPI_STATUS (AE_OK);
}

AcpiEvAssociateRegMethod (RegionObj);
RegionObj->Common.Flags |= AOPOBJ_OBJECT_INITIALIZED;

Node = RegionObj->Region.Node->Parent;
Expand Down
4 changes: 0 additions & 4 deletions source/include/acevents.h
Expand Up @@ -344,10 +344,6 @@ AcpiEvDetachRegion (
ACPI_OPERAND_OBJECT *RegionObj,
BOOLEAN AcpiNsIsLocked);

void
AcpiEvAssociateRegMethod (
ACPI_OPERAND_OBJECT *RegionObj);

void
AcpiEvExecuteRegMethods (
ACPI_NAMESPACE_NODE *Node,
Expand Down

0 comments on commit c508f85

Please sign in to comment.