public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Nhi Pham" <nhi@os.amperecomputing.com>
To: devel@edk2.groups.io
Cc: patches@amperecomputing.com, quic_llindhol@quicinc.com,
	ardb+tianocore@kernel.org,
	Tinh Nguyen <tinhnguyen@os.amperecomputing.com>,
	Nhi Pham <nhi@os.amperecomputing.com>
Subject: [edk2-platforms][PATCH 1/1] AmpereAltraPkg: Update ArmPlatformLib to work with changed ARM_CORE_INFO
Date: Fri, 13 Jan 2023 11:21:26 +0700	[thread overview]
Message-ID: <20230113042126.3107135-1-nhi@os.amperecomputing.com> (raw)

From: Tinh Nguyen <tinhnguyen@os.amperecomputing.com>

Since the commit 103fa647d159e3d76be2634d2653c2d215dd0d46 instead
("ArmPkg: Replace CoreId and ClusterId with Mpidr in ARM_CORE_INFO
struct") has updated the ARM_CORE_INFO structure so the MPIDR is now a
single field instead of separate cluster/core fields. This patch
updates the ArmPlatformLib to work with the changed ARM_CORE_INFO.

Signed-off-by: Nhi Pham <nhi@os.amperecomputing.com>
---
 .../Ampere/AmpereAltraPkg/Include/Platform/Ac01.h  | 11 ++++++++++-
 .../JadePkg/Drivers/AcpiPlatformDxe/AcpiMadt.c     |  5 ++---
 .../JadePkg/Drivers/AcpiPlatformDxe/AcpiSrat.c     | 14 ++++++++------
 .../Library/ArmPlatformLib/ArmPlatformLib.c        |  8 +++++---
 4 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/Silicon/Ampere/AmpereAltraPkg/Include/Platform/Ac01.h b/Silicon/Ampere/AmpereAltraPkg/Include/Platform/Ac01.h
index d45688f88401..563dd5ef242d 100644
--- a/Silicon/Ampere/AmpereAltraPkg/Include/Platform/Ac01.h
+++ b/Silicon/Ampere/AmpereAltraPkg/Include/Platform/Ac01.h
@@ -1,6 +1,6 @@
 /** @file
 
-  Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved.<BR>
+  Copyright (c) 2020 - 2023, Ampere Computing LLC. All rights reserved.<BR>
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -229,6 +229,15 @@
 //
 #define PLATFORM_CPM_UID_BIT_OFFSET              8
 
+//
+// MPIDR manipulation
+//
+#define AC01_GET_MPIDR(SocketId, ClusterId, CoreId) \
+          (((SocketId) << 32) | ((ClusterId) << 16) | ((CoreId) << 8))
+#define AC01_GET_SOCKET_ID(Mpidr)  (((Mpidr) & ARM_CORE_AFF3) >> 32)
+#define AC01_GET_CLUSTER_ID(Mpidr) (((Mpidr) & ARM_CORE_AFF2) >> 16)
+#define AC01_GET_CORE_ID(Mpidr)    (((Mpidr) & ARM_CORE_AFF1) >> 8)
+
 //
 // Max number for AC01 PCIE Root Complexes
 //
diff --git a/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiMadt.c b/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiMadt.c
index 419ce578e452..4db1f9a383a9 100644
--- a/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiMadt.c
+++ b/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiMadt.c
@@ -1,6 +1,6 @@
 /** @file
 
-  Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved.<BR>
+  Copyright (c) 2020 - 2023, Ampere Computing LLC. All rights reserved.<BR>
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -160,8 +160,7 @@ AcpiInstallMadtProcessorNode (
     (ClusterId << 8) + (CpuId  % PLATFORM_CPU_NUM_CORES_PER_CPM);
   MadtProcessorEntryPointer->Flags = 1;
   MadtProcessorEntryPointer->MPIDR =
-    (((ClusterId << 8) + (CpuId  % PLATFORM_CPU_NUM_CORES_PER_CPM)) << 8);
-  MadtProcessorEntryPointer->MPIDR += (((UINT64)SocketId) << 32);
+    AC01_GET_MPIDR ((UINT64)SocketId, ClusterId, CpuId  % PLATFORM_CPU_NUM_CORES_PER_CPM);
 
   return Size;
 }
diff --git a/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiSrat.c b/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiSrat.c
index f4df60bc2593..3a89014f41f1 100644
--- a/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiSrat.c
+++ b/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiSrat.c
@@ -1,6 +1,6 @@
 /** @file
 
-  Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved.<BR>
+  Copyright (c) 2020 - 2023, Ampere Computing LLC. All rights reserved.<BR>
   Copyright (c) 2022, ARM Ltd. All rights reserved.<BR>
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -122,7 +122,6 @@ SratAddGiccAffinity (
   UINTN               Count, NumNode, Idx;
   UINT32              AcpiProcessorUid;
   UINT8               Socket;
-  UINT8               Core;
   UINT8               Cpm;
 
   Hob = GetFirstGuidHob (&gArmMpCoreInfoGuid);
@@ -141,14 +140,17 @@ SratAddGiccAffinity (
   NumNode = 0;
   while (Count != NumberOfEntries) {
     for (Idx = 0; Idx < NumberOfEntries; Idx++ ) {
-      Socket = GET_MPIDR_AFF1 (ArmCoreInfoTable[Idx].Mpidr);
-      Core   = GET_MPIDR_AFF0 (ArmCoreInfoTable[Idx].Mpidr);
-      Cpm = Core >> PLATFORM_CPM_UID_BIT_OFFSET;
+      Socket  = AC01_GET_SOCKET_ID (ArmCoreInfoTable[Idx].Mpidr);
+      Cpm     = AC01_GET_CLUSTER_ID (ArmCoreInfoTable[Idx].Mpidr);
       if (CpuGetSubNumNode (Socket, Cpm) != NumNode) {
         /* We add nodes based on ProximityDomain order */
         continue;
       }
-      AcpiProcessorUid = (Socket << PLATFORM_SOCKET_UID_BIT_OFFSET) + Core;
+
+      AcpiProcessorUid =
+        (AC01_GET_SOCKET_ID (ArmCoreInfoTable[Idx].Mpidr) << PLATFORM_SOCKET_UID_BIT_OFFSET)
+        + (AC01_GET_CLUSTER_ID (ArmCoreInfoTable[Idx].Mpidr) << PLATFORM_CPM_UID_BIT_OFFSET)
+        +  AC01_GET_CORE_ID (ArmCoreInfoTable[Idx].Mpidr);
       ZeroMem ((VOID *)&SratGiccAffinity[Count], sizeof (SratGiccAffinity[Count]));
       SratGiccAffinity[Count].AcpiProcessorUid = AcpiProcessorUid;
       SratGiccAffinity[Count].Flags = 1;
diff --git a/Silicon/Ampere/AmpereAltraPkg/Library/ArmPlatformLib/ArmPlatformLib.c b/Silicon/Ampere/AmpereAltraPkg/Library/ArmPlatformLib/ArmPlatformLib.c
index f2ec923d6f8d..18023df92880 100644
--- a/Silicon/Ampere/AmpereAltraPkg/Library/ArmPlatformLib/ArmPlatformLib.c
+++ b/Silicon/Ampere/AmpereAltraPkg/Library/ArmPlatformLib/ArmPlatformLib.c
@@ -1,6 +1,6 @@
 /** @file
 
-  Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved.<BR>
+  Copyright (c) 2020 - 2023, Ampere Computing LLC. All rights reserved.<BR>
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -108,8 +108,10 @@ PrePeiCoreGetMpCoreInfo (
     }
     SocketId = SOCKET_ID (Index);
     ClusterId = CLUSTER_ID (Index);
-    mArmPlatformMpCoreInfoTable[mArmPlatformCoreCount].Mpidr = GET_MPID (
-      SocketId, (ClusterId << 8) | (Index % PLATFORM_CPU_NUM_CORES_PER_CPM));
+
+    mArmPlatformMpCoreInfoTable[mArmPlatformCoreCount].Mpidr =
+      AC01_GET_MPIDR ((UINT64)SocketId, ClusterId, (Index % PLATFORM_CPU_NUM_CORES_PER_CPM));
+
     mArmPlatformMpCoreInfoTable[mArmPlatformCoreCount].MailboxClearAddress = 0;
     mArmPlatformMpCoreInfoTable[mArmPlatformCoreCount].MailboxClearValue = 0;
     mArmPlatformMpCoreInfoTable[mArmPlatformCoreCount].MailboxGetAddress = 0;
-- 
2.25.1


             reply	other threads:[~2023-01-13  4:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-13  4:21 Nhi Pham [this message]
2023-01-13 14:40 ` [edk2-devel] [edk2-platforms][PATCH 1/1] AmpereAltraPkg: Update ArmPlatformLib to work with changed ARM_CORE_INFO Rebecca Cran
2023-01-17  9:53   ` Nhi Pham
2023-01-17 12:55     ` Rebecca Cran
2023-01-17 16:40       ` Ard Biesheuvel
2023-01-17 18:21         ` Rebecca Cran
2023-01-31  6:35           ` Nhi Pham
2023-02-15 11:28             ` Leif Lindholm

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=20230113042126.3107135-1-nhi@os.amperecomputing.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