From: "JackX Lin" <JackX.Lin@intel.com>
To: devel@edk2.groups.io
Cc: JackX Lin <jackx.lin@intel.com>, JackX Lin <JackX.Lin@intel.com>,
Chasel Chiu <chasel.chiu@intel.com>,
Dong Eric <eric.dong@intel.com>,
Jiewen Yao <jiewen.yao@intel.com>, Ray Ni <ray.ni@intel.com>,
Rangasai V Chaganty <rangasai.v.chaganty@intel.com>,
Donald Kuo <Donald.Kuo@intel.com>,
Chandana C Kumar <chandana.c.kumar@intel.com>,
Palakshareddy, Lavanya C <lavanya.c.palakshareddy@intel.com>
Subject: [edk2-platforms:PATCH] Modify processor _UID ordering by CPU default fused in MADT
Date: Thu, 28 Jul 2022 15:24:42 +0800 [thread overview]
Message-ID: <20220728072442.1439-1-jackx.lin@intel.com> (raw)
BIOS should not reordering cpu processor_uid
Signed-off-by: JackX Lin <JackX.Lin@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Dong Eric <eric.dong@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Rangasai V Chaganty <rangasai.v.chaganty@intel.com>
Cc: Donald Kuo <Donald.Kuo@intel.com>
Cc: Chandana C Kumar <chandana.c.kumar@intel.com>
Cc: Palakshareddy, Lavanya C <lavanya.c.palakshareddy@intel.com>
Cc: JackX Lin <JackX.Lin@intel.com>
---
Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c | 99 ++++-----------------------------------------------------------------------------------------------
1 file changed, 4 insertions(+), 95 deletions(-)
diff --git a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
index c7e87cbd7d..d0e8891918 100644
--- a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
+++ b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
@@ -62,33 +62,6 @@ EFI_CPU_ID_ORDER_MAP *mCpuApicIdOrderTable = NULL;
UINTN mNumberOfCpus = 0;
UINTN mNumberOfEnabledCPUs = 0;
-
-/**
- The function is called by PerformQuickSort to compare int values.
-
- @param[in] Left The pointer to first buffer.
- @param[in] Right The pointer to second buffer.
-
- @return -1 Buffer1 is less than Buffer2.
- @return 1 Buffer1 is greater than Buffer2.
-
-**/
-INTN
-EFIAPI
-ApicIdCompareFunction (
- IN CONST VOID *Left,
- IN CONST VOID *Right
- )
-{
- UINT32 LeftApicId;
- UINT32 RightApicId;
-
- LeftApicId = ((EFI_CPU_ID_ORDER_MAP *) Left)->ApicId;
- RightApicId = ((EFI_CPU_ID_ORDER_MAP *) Right)->ApicId;
-
- return (LeftApicId > RightApicId)? 1 : (-1);
-}
-
/**
Print Cpu Apic ID Table
@@ -168,21 +141,16 @@ SortCpuLocalApicInTable (
EFI_PROCESSOR_INFORMATION ProcessorInfoBuffer;
UINT32 Index;
UINT32 CurrProcessor;
- UINT32 BspApicId;
- EFI_CPU_ID_ORDER_MAP TempVal;
EFI_CPU_ID_ORDER_MAP *CpuIdMapPtr;
UINT32 CoreThreadMask;
- EFI_CPU_ID_ORDER_MAP *TempCpuApicIdOrderTable;
UINT32 Socket;
- Index = 0;
Status = EFI_SUCCESS;
if (mCpuOrderSorted) {
return Status;
}
- TempCpuApicIdOrderTable = AllocateZeroPool (mNumberOfCpus * sizeof (EFI_CPU_ID_ORDER_MAP));
CoreThreadMask = (UINT32) ((1 << mNumOfBitShift) - 1);
for (CurrProcessor = 0, Index = 0; CurrProcessor < mNumberOfCpus; CurrProcessor++, Index++) {
@@ -192,7 +160,7 @@ SortCpuLocalApicInTable (
&ProcessorInfoBuffer
);
- CpuIdMapPtr = (EFI_CPU_ID_ORDER_MAP *) &TempCpuApicIdOrderTable[Index];
+ CpuIdMapPtr = (EFI_CPU_ID_ORDER_MAP *) &mCpuApicIdOrderTable[Index];
if ((ProcessorInfoBuffer.StatusFlag & PROCESSOR_ENABLED_BIT) != 0) {
CpuIdMapPtr->ApicId = (UINT32)ProcessorInfoBuffer.ProcessorId;
CpuIdMapPtr->Thread = ProcessorInfoBuffer.Location.Thread;
@@ -214,74 +182,16 @@ SortCpuLocalApicInTable (
} //end if PROC ENABLE
} //end for CurrentProcessor
- //keep for debug purpose
DEBUG ((DEBUG_INFO, "::ACPI:: APIC ID Order Table Init. CoreThreadMask = %x, mNumOfBitShift = %x\n", CoreThreadMask, mNumOfBitShift));
- DebugDisplayReOrderTable (TempCpuApicIdOrderTable);
//
// Get Bsp Apic Id
//
- BspApicId = GetApicId ();
- DEBUG ((DEBUG_INFO, "BspApicId - 0x%x\n", BspApicId));
-
- //
- //check to see if 1st entry is BSP, if not swap it
- //
- if (TempCpuApicIdOrderTable[0].ApicId != BspApicId) {
- for (Index = 0; Index < mNumberOfCpus; Index++) {
- if ((TempCpuApicIdOrderTable[Index].Flags == 1) && (TempCpuApicIdOrderTable[Index].ApicId == BspApicId)) {
- CopyMem (&TempVal, &TempCpuApicIdOrderTable[Index], sizeof (EFI_CPU_ID_ORDER_MAP));
- CopyMem (&TempCpuApicIdOrderTable[Index], &TempCpuApicIdOrderTable[0], sizeof (EFI_CPU_ID_ORDER_MAP));
- CopyMem (&TempCpuApicIdOrderTable[0], &TempVal, sizeof (EFI_CPU_ID_ORDER_MAP));
- break;
- }
- }
-
- if (mNumberOfCpus <= Index) {
- DEBUG ((DEBUG_ERROR, "Asserting the SortCpuLocalApicInTable Index Bufferflow\n"));
- return EFI_INVALID_PARAMETER;
- }
- }
-
- //
- // 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.
- //
- PerformQuickSort ((TempCpuApicIdOrderTable + 1), (mNumberOfCpus - 1), sizeof (EFI_CPU_ID_ORDER_MAP), (SORT_COMPARE) ApicIdCompareFunction);
+ DEBUG ((DEBUG_INFO, "BspApicId - 0x%x\n", GetApicId ()));
- //
- // 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
- 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
- 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
- CopyMem (&mCpuApicIdOrderTable[CurrProcessor], &TempCpuApicIdOrderTable[Index], sizeof (EFI_CPU_ID_ORDER_MAP));
- CurrProcessor++;
- }
- }
-
- //
- // 5. Re-assign AcpiProcessorId for AcpiProcessorUid uses purpose.
+ // Fill in AcpiProcessorUid.
//
for (Socket = 0; Socket < FixedPcdGet32 (PcdMaxCpuSocketCount); Socket++) {
for (CurrProcessor = 0, Index = 0; CurrProcessor < mNumberOfCpus; CurrProcessor++) {
@@ -292,8 +202,7 @@ SortCpuLocalApicInTable (
}
}
- //keep for debug purpose
- DEBUG ((DEBUG_INFO, "APIC ID Order Table ReOrdered\n"));
+ DEBUG ((DEBUG_INFO, "::ACPI:: APIC ID Order Table Init. CoreThreadMask = %x, mNumOfBitShift = %x\n", CoreThreadMask, mNumOfBitShift));
DebugDisplayReOrderTable (mCpuApicIdOrderTable);
mCpuOrderSorted = TRUE;
--
2.32.0.windows.2
next reply other threads:[~2022-07-28 7:25 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-28 7:24 JackX Lin [this message]
2022-08-01 3:02 ` [edk2-platforms:PATCH] Modify processor _UID ordering by CPU default fused in MADT Donald Kuo
2022-08-02 16:37 ` Kumar, Chandana C
2022-08-05 6:42 ` Ni, Ray
2022-08-08 8:19 ` JackX Lin
-- strict thread matches above, loose matches on Subject: below --
2022-08-10 4:28 [edk2-platforms: PATCH] " JackX Lin
2022-08-10 5:06 ` Ni, Ray
2022-08-08 8:21 JackX Lin
2022-08-09 7:12 ` Ni, Ray
2022-08-09 7:52 ` Donald Kuo
2022-08-10 3:47 ` Ni, Ray
2022-08-10 3:51 ` JackX Lin
2022-08-10 3:52 ` Ni, Ray
2022-08-10 4:32 ` JackX Lin
2022-08-10 5:09 ` Ni, Ray
2022-07-27 6:11 JackX Lin
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=20220728072442.1439-1-jackx.lin@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