public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Sinha, Ankit" <ankit.sinha@intel.com>
To: devel@edk2.groups.io
Cc: Isaac Oram <isaac.w.oram@intel.com>,
	Nate DeSimone <nathaniel.l.desimone@intel.com>,
	Eric Dong <eric.dong@intel.com>
Subject: [edk2-devel][edk2-platforms][PATCH V3 1/1] MinPlatformPkg/AcpiTables: Add additional thread mapping in MADT
Date: Mon,  8 Aug 2022 14:05:11 -0700	[thread overview]
Message-ID: <20220808210511.466-1-ankit.sinha@intel.com> (raw)

Add mapping for all enabled and disabled threads in MADT

Cc: Isaac Oram <isaac.w.oram@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Signed-off-by: Ankit Sinha <ankit.sinha@intel.com>
---
 Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c | 49 +++++++++++---------
 1 file changed, 28 insertions(+), 21 deletions(-)

diff --git a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
index e68b6070607f..5a282e7c18f2 100644
--- a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
+++ b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
@@ -243,46 +243,54 @@ SortCpuLocalApicInTable (
     }
   }
 
-  //
-  // 1. Sort TempCpuApicIdOrderTable,
-  //    sort it by using ApicId from minimum to maximum (Socket0 to SocketN), and the BSP must in the fist location of the table.
-  //    So, start sorting the table from the second element and total elements are mNumberOfCpus-1.
-  //
+  /*
+      1. Sort TempCpuApicIdOrderTable,
+        Sort it by using ApicId from minimum to maximum (Socket0 to SocketN), and the BSP must be in the fist location of the table.
+
+      2. Sort and map all the enabled threads after BSP in CpuApicIdOrderTable
+
+      3. Threads that are not enabled are placed in the bottom of CpuApicIdOrderTable
+
+      4. Re-assign AcpiProcessorId for AcpiProcessorUid uses purpose.
+  */
+
   PerformQuickSort ((TempCpuApicIdOrderTable + 1), (mNumberOfCpus - 1), sizeof (EFI_CPU_ID_ORDER_MAP), (SORT_COMPARE) ApicIdCompareFunction);
 
-  //
-  // 2. Sort and map the primary threads to the front of the CpuApicIdOrderTable
-  //
   for (CurrProcessor = 0, Index = 0; Index < mNumberOfCpus; Index++) {
-    if ((TempCpuApicIdOrderTable[Index].Thread) == 0) { // primary thread
+    if ((TempCpuApicIdOrderTable[Index].Thread) == 0) {
       CopyMem (&mCpuApicIdOrderTable[CurrProcessor], &TempCpuApicIdOrderTable[Index], sizeof (EFI_CPU_ID_ORDER_MAP));
       CurrProcessor++;
     }
   }
 
-  //
-  // 3. Sort and map the second threads to the middle of the CpuApicIdOrderTable
-  //
   for (Index = 0; Index < mNumberOfCpus; Index++) {
-    if ((TempCpuApicIdOrderTable[Index].Thread) == 1) { //second thread
+    if ((TempCpuApicIdOrderTable[Index].Thread) == 1) {
       CopyMem (&mCpuApicIdOrderTable[CurrProcessor], &TempCpuApicIdOrderTable[Index], sizeof (EFI_CPU_ID_ORDER_MAP));
       CurrProcessor++;
     }
   }
 
-  //
-  // 4. Sort and map the not enabled threads to the bottom of the CpuApicIdOrderTable
-  //
   for (Index = 0; Index < mNumberOfCpus; Index++) {
-    if (TempCpuApicIdOrderTable[Index].Flags == 0) { // not enabled
+    if ((TempCpuApicIdOrderTable[Index].Thread) == 2) {
+      CopyMem (&mCpuApicIdOrderTable[CurrProcessor], &TempCpuApicIdOrderTable[Index], sizeof (EFI_CPU_ID_ORDER_MAP));
+      CurrProcessor++;
+    }
+  }
+
+  for (Index = 0; Index < mNumberOfCpus; Index++) {
+    if ((TempCpuApicIdOrderTable[Index].Thread) == 3) {
+      CopyMem (&mCpuApicIdOrderTable[CurrProcessor], &TempCpuApicIdOrderTable[Index], sizeof (EFI_CPU_ID_ORDER_MAP));
+      CurrProcessor++;
+    }
+  }
+
+  for (Index = 0; Index < mNumberOfCpus; Index++) {
+    if (TempCpuApicIdOrderTable[Index].Flags == 0) {
       CopyMem (&mCpuApicIdOrderTable[CurrProcessor], &TempCpuApicIdOrderTable[Index], sizeof (EFI_CPU_ID_ORDER_MAP));
       CurrProcessor++;
     }
   }
 
-  //
-  // 5. Re-assign AcpiProcessorId for AcpiProcessorUid uses purpose.
-  //
   for (Socket = 0; Socket < FixedPcdGet32 (PcdMaxCpuSocketCount); Socket++) {
     for (CurrProcessor = 0, Index = 0; CurrProcessor < mNumberOfCpus; CurrProcessor++) {
       if (mCpuApicIdOrderTable[CurrProcessor].Flags && (mCpuApicIdOrderTable[CurrProcessor].SocketNum == Socket)) {
@@ -292,7 +300,6 @@ SortCpuLocalApicInTable (
     }
   }
 
-  //keep for debug purpose
   DEBUG ((DEBUG_INFO, "APIC ID Order Table ReOrdered\n"));
   DebugDisplayReOrderTable (mCpuApicIdOrderTable);
 
-- 
2.27.0.windows.1


             reply	other threads:[~2022-08-08 21:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-08 21:05 Sinha, Ankit [this message]
2022-08-08 22:40 ` [edk2-devel][edk2-platforms][PATCH V3 1/1] MinPlatformPkg/AcpiTables: Add additional thread mapping in MADT Oram, Isaac W
     [not found] ` <17097FCA6B608DF0.19746@groups.io>
2022-08-08 22:43   ` Oram, Isaac W

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=20220808210511.466-1-ankit.sinha@intel.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