DynamicTablesPkg: Fix nested processor containers

Current code will generate duplicate UID if there are nested processor
containers in the topology. For example if there is a
socket/cluster/core layout.

Change references to processor container from cluster to be more
accurate on what is being created.

Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
This commit is contained in:
Jeff Brasen 2022-08-18 10:47:55 -06:00 committed by mergify[bot]
parent 0a4079ad86
commit 7719bc3f71

View File

@ -587,10 +587,10 @@ CreateAmlCpuFromProcHierarchy (
return Status; return Status;
} }
/** Create a Cluster in the AML namespace. /** Create a Processor Container in the AML namespace.
Any CM_ARM_PROC_HIERARCHY_INFO object with the following flags is Any CM_ARM_PROC_HIERARCHY_INFO object with the following flags is
assumed to be a cluster: assumed to be a processor container:
- EFI_ACPI_6_3_PPTT_PACKAGE_NOT_PHYSICAL - EFI_ACPI_6_3_PPTT_PACKAGE_NOT_PHYSICAL
- EFI_ACPI_6_3_PPTT_PROCESSOR_ID_INVALID - EFI_ACPI_6_3_PPTT_PROCESSOR_ID_INVALID
- EFI_ACPI_6_3_PPTT_NODE_IS_NOT_LEAF - EFI_ACPI_6_3_PPTT_NODE_IS_NOT_LEAF
@ -605,13 +605,13 @@ CreateAmlCpuFromProcHierarchy (
@param [in] Generator The SSDT Cpu Topology generator. @param [in] Generator The SSDT Cpu Topology generator.
@param [in] CfgMgrProtocol Pointer to the Configuration Manager @param [in] CfgMgrProtocol Pointer to the Configuration Manager
Protocol Interface. Protocol Interface.
@param [in] ParentNode Parent node to attach the Cluster @param [in] ParentNode Parent node to attach the processor
node to. container node to.
@param [in] ProcHierarchyNodeInfo CM_ARM_PROC_HIERARCHY_INFO object used @param [in] ProcHierarchyNodeInfo CM_ARM_PROC_HIERARCHY_INFO object used
to create the node. to create the node.
@param [in] ClusterIndex Index used to generate the node name. @param [in] ProcContainerIndex Index used to generate the node name.
@param [out] ClusterNodePtr If success, contains the created Cluster @param [out] ProcContainerNodePtr If success, contains the created processor
node. container node.
@retval EFI_SUCCESS Success. @retval EFI_SUCCESS Success.
@retval EFI_INVALID_PARAMETER Invalid parameter. @retval EFI_INVALID_PARAMETER Invalid parameter.
@ -620,43 +620,43 @@ CreateAmlCpuFromProcHierarchy (
STATIC STATIC
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
CreateAmlCluster ( CreateAmlProcessorContainer (
IN ACPI_CPU_TOPOLOGY_GENERATOR *Generator, IN ACPI_CPU_TOPOLOGY_GENERATOR *Generator,
IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol,
IN AML_NODE_HANDLE ParentNode, IN AML_NODE_HANDLE ParentNode,
IN CM_ARM_PROC_HIERARCHY_INFO *ProcHierarchyNodeInfo, IN CM_ARM_PROC_HIERARCHY_INFO *ProcHierarchyNodeInfo,
IN UINT32 ClusterIndex, IN UINT32 ProcContainerIndex,
OUT AML_OBJECT_NODE_HANDLE *ClusterNodePtr OUT AML_OBJECT_NODE_HANDLE *ProcContainerNodePtr
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
AML_OBJECT_NODE_HANDLE ClusterNode; AML_OBJECT_NODE_HANDLE ProcContainerNode;
CHAR8 AslNameCluster[AML_NAME_SEG_SIZE + 1]; CHAR8 AslNameProcContainer[AML_NAME_SEG_SIZE + 1];
ASSERT (Generator != NULL); ASSERT (Generator != NULL);
ASSERT (CfgMgrProtocol != NULL); ASSERT (CfgMgrProtocol != NULL);
ASSERT (ParentNode != NULL); ASSERT (ParentNode != NULL);
ASSERT (ProcHierarchyNodeInfo != NULL); ASSERT (ProcHierarchyNodeInfo != NULL);
ASSERT (ClusterNodePtr != NULL); ASSERT (ProcContainerNodePtr != NULL);
Status = WriteAslName ('C', ClusterIndex, AslNameCluster); Status = WriteAslName ('C', ProcContainerIndex, AslNameProcContainer);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
ASSERT (0); ASSERT (0);
return Status; return Status;
} }
Status = AmlCodeGenDevice (AslNameCluster, ParentNode, &ClusterNode); Status = AmlCodeGenDevice (AslNameProcContainer, ParentNode, &ProcContainerNode);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
ASSERT (0); ASSERT (0);
return Status; return Status;
} }
// Use the ClusterIndex for the _UID value as there is no AcpiProcessorUid // Use the ProcContainerIndex for the _UID value as there is no AcpiProcessorUid
// and EFI_ACPI_6_3_PPTT_PROCESSOR_ID_INVALID is set for non-Cpus. // and EFI_ACPI_6_3_PPTT_PROCESSOR_ID_INVALID is set for non-Cpus.
Status = AmlCodeGenNameInteger ( Status = AmlCodeGenNameInteger (
"_UID", "_UID",
ClusterIndex, ProcContainerIndex,
ClusterNode, ProcContainerNode,
NULL NULL
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
@ -667,7 +667,7 @@ CreateAmlCluster (
Status = AmlCodeGenNameString ( Status = AmlCodeGenNameString (
"_HID", "_HID",
ACPI_HID_PROCESSOR_CONTAINER_DEVICE, ACPI_HID_PROCESSOR_CONTAINER_DEVICE,
ClusterNode, ProcContainerNode,
NULL NULL
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
@ -681,7 +681,7 @@ CreateAmlCluster (
Status = CreateAmlLpiMethod ( Status = CreateAmlLpiMethod (
Generator, Generator,
ProcHierarchyNodeInfo, ProcHierarchyNodeInfo,
ClusterNode ProcContainerNode
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
ASSERT (0); ASSERT (0);
@ -689,23 +689,25 @@ CreateAmlCluster (
} }
} }
*ClusterNodePtr = ClusterNode; *ProcContainerNodePtr = ProcContainerNode;
return Status; return Status;
} }
/** Create an AML representation of the Cpu topology. /** Create an AML representation of the Cpu topology.
A cluster is by extension any non-leave device in the cpu topology. A processor container is by extension any non-leave device in the cpu topology.
@param [in] Generator The SSDT Cpu Topology generator. @param [in] Generator The SSDT Cpu Topology generator.
@param [in] CfgMgrProtocol Pointer to the Configuration Manager @param [in] CfgMgrProtocol Pointer to the Configuration Manager
Protocol Interface. Protocol Interface.
@param [in] NodeToken Token of the CM_ARM_PROC_HIERARCHY_INFO @param [in] NodeToken Token of the CM_ARM_PROC_HIERARCHY_INFO
currently handled. currently handled.
Cannot be CM_NULL_TOKEN. Cannot be CM_NULL_TOKEN.
@param [in] ParentNode Parent node to attach the created @param [in] ParentNode Parent node to attach the created
node to. node to.
@param [in,out] ProcContainerIndex Pointer to the current processor container
index to be used as UID.
@retval EFI_SUCCESS Success. @retval EFI_SUCCESS Success.
@retval EFI_INVALID_PARAMETER Invalid parameter. @retval EFI_INVALID_PARAMETER Invalid parameter.
@ -718,14 +720,14 @@ CreateAmlCpuTopologyTree (
IN ACPI_CPU_TOPOLOGY_GENERATOR *Generator, IN ACPI_CPU_TOPOLOGY_GENERATOR *Generator,
IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol,
IN CM_OBJECT_TOKEN NodeToken, IN CM_OBJECT_TOKEN NodeToken,
IN AML_NODE_HANDLE ParentNode IN AML_NODE_HANDLE ParentNode,
IN OUT UINT32 *ProcContainerIndex
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
UINT32 Index; UINT32 Index;
UINT32 CpuIndex; UINT32 CpuIndex;
UINT32 ClusterIndex; AML_OBJECT_NODE_HANDLE ProcContainerNode;
AML_OBJECT_NODE_HANDLE ClusterNode;
ASSERT (Generator != NULL); ASSERT (Generator != NULL);
ASSERT (Generator->ProcNodeList != NULL); ASSERT (Generator->ProcNodeList != NULL);
@ -733,9 +735,9 @@ CreateAmlCpuTopologyTree (
ASSERT (CfgMgrProtocol != NULL); ASSERT (CfgMgrProtocol != NULL);
ASSERT (NodeToken != CM_NULL_TOKEN); ASSERT (NodeToken != CM_NULL_TOKEN);
ASSERT (ParentNode != NULL); ASSERT (ParentNode != NULL);
ASSERT (ProcContainerIndex != NULL);
CpuIndex = 0; CpuIndex = 0;
ClusterIndex = 0;
for (Index = 0; Index < Generator->ProcNodeCount; Index++) { for (Index = 0; Index < Generator->ProcNodeCount; Index++) {
// Find the children of the CM_ARM_PROC_HIERARCHY_INFO // Find the children of the CM_ARM_PROC_HIERARCHY_INFO
@ -770,7 +772,7 @@ CreateAmlCpuTopologyTree (
CpuIndex++; CpuIndex++;
} else { } else {
// If this is not a Cpu, then this is a cluster. // If this is not a Cpu, then this is a processor container.
// Acpi processor Id for clusters is not handled. // Acpi processor Id for clusters is not handled.
if ((Generator->ProcNodeList[Index].Flags & PPTT_PROCESSOR_MASK) != if ((Generator->ProcNodeList[Index].Flags & PPTT_PROCESSOR_MASK) !=
@ -785,13 +787,13 @@ CreateAmlCpuTopologyTree (
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
Status = CreateAmlCluster ( Status = CreateAmlProcessorContainer (
Generator, Generator,
CfgMgrProtocol, CfgMgrProtocol,
ParentNode, ParentNode,
&Generator->ProcNodeList[Index], &Generator->ProcNodeList[Index],
ClusterIndex, *ProcContainerIndex,
&ClusterNode &ProcContainerNode
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
ASSERT (0); ASSERT (0);
@ -799,8 +801,8 @@ CreateAmlCpuTopologyTree (
} }
// Nodes must have a unique name in the ASL namespace. // Nodes must have a unique name in the ASL namespace.
// Reset the Cpu index whenever we create a new Cluster. // Reset the Cpu index whenever we create a new processor container.
ClusterIndex++; (*ProcContainerIndex)++;
CpuIndex = 0; CpuIndex = 0;
// Recursively continue creating an AML tree. // Recursively continue creating an AML tree.
@ -808,7 +810,8 @@ CreateAmlCpuTopologyTree (
Generator, Generator,
CfgMgrProtocol, CfgMgrProtocol,
Generator->ProcNodeList[Index].Token, Generator->ProcNodeList[Index].Token,
ClusterNode ProcContainerNode,
ProcContainerIndex
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
ASSERT (0); ASSERT (0);
@ -845,6 +848,7 @@ CreateTopologyFromProcHierarchy (
EFI_STATUS Status; EFI_STATUS Status;
UINT32 Index; UINT32 Index;
UINT32 TopLevelProcNodeIndex; UINT32 TopLevelProcNodeIndex;
UINT32 ProcContainerIndex;
ASSERT (Generator != NULL); ASSERT (Generator != NULL);
ASSERT (Generator->ProcNodeCount != 0); ASSERT (Generator->ProcNodeCount != 0);
@ -853,6 +857,7 @@ CreateTopologyFromProcHierarchy (
ASSERT (ScopeNode != NULL); ASSERT (ScopeNode != NULL);
TopLevelProcNodeIndex = MAX_UINT32; TopLevelProcNodeIndex = MAX_UINT32;
ProcContainerIndex = 0;
Status = TokenTableInitialize (Generator, Generator->ProcNodeCount); Status = TokenTableInitialize (Generator, Generator->ProcNodeCount);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
@ -887,7 +892,8 @@ CreateTopologyFromProcHierarchy (
Generator, Generator,
CfgMgrProtocol, CfgMgrProtocol,
Generator->ProcNodeList[TopLevelProcNodeIndex].Token, Generator->ProcNodeList[TopLevelProcNodeIndex].Token,
ScopeNode ScopeNode,
&ProcContainerIndex
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
ASSERT (0); ASSERT (0);
@ -908,7 +914,7 @@ exit_handler:
/** Create the processor hierarchy AML tree from CM_ARM_GICC_INFO /** Create the processor hierarchy AML tree from CM_ARM_GICC_INFO
CM objects. CM objects.
A cluster is by extension any non-leave device in the cpu topology. A processor container is by extension any non-leave device in the cpu topology.
@param [in] Generator The SSDT Cpu Topology generator. @param [in] Generator The SSDT Cpu Topology generator.
@param [in] CfgMgrProtocol Pointer to the Configuration Manager @param [in] CfgMgrProtocol Pointer to the Configuration Manager