public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Jeff Brasen" <jbrasen@nvidia.com>
To: <devel@edk2.groups.io>
Cc: <quic_llindhol@quicinc.com>, <ardb+tianocore@kernel.org>,
	<Sami.Mujawar@arm.com>, <Alexei.Fedorov@arm.com>,
	Jeff Brasen <jbrasen@nvidia.com>
Subject: [PATCH] DynamicTablesPkg: Correct cluster index
Date: Tue, 16 Aug 2022 14:45:57 -0600	[thread overview]
Message-ID: <81913483228a6d636f164831d41424717d46fbb4.1660682661.git.jbrasen@nvidia.com> (raw)

Current code will generate duplicate UID if there are nested clusters
in the topology.

Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
---
 .../SsdtCpuTopologyGenerator.c                | 22 ++++++++++++-------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c
index 3266d8dd98..9295117f1f 100644
--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c
@@ -706,6 +706,8 @@ CreateAmlCluster (
                                  Cannot be CM_NULL_TOKEN.
   @param [in] ParentNode         Parent node to attach the created
                                  node to.
+  @param [in,out] ClusterIndex   Pointer to the current cluster index
+                                 to be used as UID.
 
   @retval EFI_SUCCESS             Success.
   @retval EFI_INVALID_PARAMETER   Invalid parameter.
@@ -718,13 +720,13 @@ CreateAmlCpuTopologyTree (
   IN        ACPI_CPU_TOPOLOGY_GENERATOR                   *Generator,
   IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,
   IN        CM_OBJECT_TOKEN                               NodeToken,
-  IN        AML_NODE_HANDLE                               ParentNode
+  IN        AML_NODE_HANDLE                               ParentNode,
+  IN OUT    UINT32                                        *ClusterIndex
   )
 {
   EFI_STATUS              Status;
   UINT32                  Index;
   UINT32                  CpuIndex;
-  UINT32                  ClusterIndex;
   AML_OBJECT_NODE_HANDLE  ClusterNode;
 
   ASSERT (Generator != NULL);
@@ -733,9 +735,9 @@ CreateAmlCpuTopologyTree (
   ASSERT (CfgMgrProtocol != NULL);
   ASSERT (NodeToken != CM_NULL_TOKEN);
   ASSERT (ParentNode != NULL);
+  ASSERT (ClusterIndex != NULL);
 
-  CpuIndex     = 0;
-  ClusterIndex = 0;
+  CpuIndex = 0;
 
   for (Index = 0; Index < Generator->ProcNodeCount; Index++) {
     // Find the children of the CM_ARM_PROC_HIERARCHY_INFO
@@ -790,7 +792,7 @@ CreateAmlCpuTopologyTree (
                    CfgMgrProtocol,
                    ParentNode,
                    &Generator->ProcNodeList[Index],
-                   ClusterIndex,
+                   *ClusterIndex,
                    &ClusterNode
                    );
         if (EFI_ERROR (Status)) {
@@ -800,7 +802,7 @@ CreateAmlCpuTopologyTree (
 
         // Nodes must have a unique name in the ASL namespace.
         // Reset the Cpu index whenever we create a new Cluster.
-        ClusterIndex++;
+        (*ClusterIndex)++;
         CpuIndex = 0;
 
         // Recursively continue creating an AML tree.
@@ -808,7 +810,8 @@ CreateAmlCpuTopologyTree (
                    Generator,
                    CfgMgrProtocol,
                    Generator->ProcNodeList[Index].Token,
-                   ClusterNode
+                   ClusterNode,
+                   ClusterIndex
                    );
         if (EFI_ERROR (Status)) {
           ASSERT (0);
@@ -845,6 +848,7 @@ CreateTopologyFromProcHierarchy (
   EFI_STATUS  Status;
   UINT32      Index;
   UINT32      TopLevelProcNodeIndex;
+  UINT32      ClusterIndex;
 
   ASSERT (Generator != NULL);
   ASSERT (Generator->ProcNodeCount != 0);
@@ -853,6 +857,7 @@ CreateTopologyFromProcHierarchy (
   ASSERT (ScopeNode != NULL);
 
   TopLevelProcNodeIndex = MAX_UINT32;
+  ClusterIndex          = 0;
 
   Status = TokenTableInitialize (Generator, Generator->ProcNodeCount);
   if (EFI_ERROR (Status)) {
@@ -887,7 +892,8 @@ CreateTopologyFromProcHierarchy (
              Generator,
              CfgMgrProtocol,
              Generator->ProcNodeList[TopLevelProcNodeIndex].Token,
-             ScopeNode
+             ScopeNode,
+             &ClusterIndex
              );
   if (EFI_ERROR (Status)) {
     ASSERT (0);
-- 
2.25.1


             reply	other threads:[~2022-08-16 20:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-16 20:45 Jeff Brasen [this message]
2022-08-17  7:01 ` [PATCH] DynamicTablesPkg: Correct cluster index Ard Biesheuvel
2022-08-17 16:14   ` Jeff Brasen
2022-08-18 10:22     ` Ard Biesheuvel
2022-08-18 15:28       ` Sami Mujawar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=81913483228a6d636f164831d41424717d46fbb4.1660682661.git.jbrasen@nvidia.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox