mirror of https://github.com/acidanthera/audk.git
UefiCpuPkg/Feature: Support different thread count per core
Today's code assumes every core contains the same number of threads. It's not always TRUE for certain model. Such assumption causes system hang when thread count per core is different and there is core or package dependency between CPU features (using CPU_FEATURE_CORE_BEFORE/AFTER, CPU_FEATURE_PACKAGE_BEFORE/AFTER). The change removes such assumption by calculating the actual thread count per package and per core. Signed-off-by: Ray Ni <ray.ni@intel.com> Reviewed-by: Eric Dong <eric.dong@intel.com> Cc: Yun Lou <yun.lou@intel.com> Acked-by: Laszlo Ersek <lersek@redhat.com>
This commit is contained in:
parent
126115a9fb
commit
6af76adbbf
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
Definitions for CPU S3 data.
|
Definitions for CPU S3 data.
|
||||||
|
|
||||||
Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2013 - 2020, Intel Corporation. All rights reserved.<BR>
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
@ -60,14 +60,24 @@ typedef struct {
|
||||||
UINT32 MaxThreadCount;
|
UINT32 MaxThreadCount;
|
||||||
//
|
//
|
||||||
// This field points to an array.
|
// This field points to an array.
|
||||||
// This array saves valid core count (type UINT32) of each package.
|
// This array saves thread count (type UINT32) of each package.
|
||||||
// The array has PackageCount elements.
|
// The array has PackageCount elements.
|
||||||
//
|
//
|
||||||
// If the platform does not support MSR setting at S3 resume, and
|
// If the platform does not support MSR setting at S3 resume, and
|
||||||
// therefore it doesn't need the dependency semaphores, it should set
|
// therefore it doesn't need the dependency semaphores, it should set
|
||||||
// this field to 0.
|
// this field to 0.
|
||||||
//
|
//
|
||||||
EFI_PHYSICAL_ADDRESS ValidCoreCountPerPackage;
|
EFI_PHYSICAL_ADDRESS ThreadCountPerPackage;
|
||||||
|
//
|
||||||
|
// This field points to an array.
|
||||||
|
// This array saves thread count (type UINT8) of each core.
|
||||||
|
// The array has PackageCount * MaxCoreCount elements.
|
||||||
|
//
|
||||||
|
// If the platform does not support MSR setting at S3 resume, and
|
||||||
|
// therefore it doesn't need the dependency semaphores, it should set
|
||||||
|
// this field to 0.
|
||||||
|
//
|
||||||
|
EFI_PHYSICAL_ADDRESS ThreadCountPerCore;
|
||||||
} CPU_STATUS_INFORMATION;
|
} CPU_STATUS_INFORMATION;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -103,14 +103,13 @@ CpuInitDataInitialize (
|
||||||
UINT32 Package;
|
UINT32 Package;
|
||||||
UINT32 Thread;
|
UINT32 Thread;
|
||||||
EFI_CPU_PHYSICAL_LOCATION *Location;
|
EFI_CPU_PHYSICAL_LOCATION *Location;
|
||||||
BOOLEAN *CoresVisited;
|
|
||||||
UINTN Index;
|
|
||||||
UINT32 PackageIndex;
|
UINT32 PackageIndex;
|
||||||
UINT32 CoreIndex;
|
UINT32 CoreIndex;
|
||||||
UINT32 First;
|
UINT32 First;
|
||||||
ACPI_CPU_DATA *AcpiCpuData;
|
ACPI_CPU_DATA *AcpiCpuData;
|
||||||
CPU_STATUS_INFORMATION *CpuStatus;
|
CPU_STATUS_INFORMATION *CpuStatus;
|
||||||
UINT32 *ValidCoreCountPerPackage;
|
UINT32 *ThreadCountPerPackage;
|
||||||
|
UINT8 *ThreadCountPerCore;
|
||||||
UINTN NumberOfCpus;
|
UINTN NumberOfCpus;
|
||||||
UINTN NumberOfEnabledProcessors;
|
UINTN NumberOfEnabledProcessors;
|
||||||
|
|
||||||
|
@ -202,36 +201,33 @@ CpuInitDataInitialize (
|
||||||
//
|
//
|
||||||
// Collect valid core count in each package because not all cores are valid.
|
// Collect valid core count in each package because not all cores are valid.
|
||||||
//
|
//
|
||||||
ValidCoreCountPerPackage= AllocateZeroPool (sizeof (UINT32) * CpuStatus->PackageCount);
|
ThreadCountPerPackage = AllocateZeroPool (sizeof (UINT32) * CpuStatus->PackageCount);
|
||||||
ASSERT (ValidCoreCountPerPackage != 0);
|
ASSERT (ThreadCountPerPackage != NULL);
|
||||||
CpuStatus->ValidCoreCountPerPackage = (EFI_PHYSICAL_ADDRESS)(UINTN)ValidCoreCountPerPackage;
|
CpuStatus->ThreadCountPerPackage = (EFI_PHYSICAL_ADDRESS)(UINTN)ThreadCountPerPackage;
|
||||||
CoresVisited = AllocatePool (sizeof (BOOLEAN) * CpuStatus->MaxCoreCount);
|
|
||||||
ASSERT (CoresVisited != NULL);
|
|
||||||
|
|
||||||
for (Index = 0; Index < CpuStatus->PackageCount; Index ++ ) {
|
ThreadCountPerCore = AllocateZeroPool (sizeof (UINT8) * CpuStatus->PackageCount * CpuStatus->MaxCoreCount);
|
||||||
ZeroMem (CoresVisited, sizeof (BOOLEAN) * CpuStatus->MaxCoreCount);
|
ASSERT (ThreadCountPerCore != NULL);
|
||||||
//
|
CpuStatus->ThreadCountPerCore = (EFI_PHYSICAL_ADDRESS)(UINTN)ThreadCountPerCore;
|
||||||
// Collect valid cores in Current package.
|
|
||||||
//
|
for (ProcessorNumber = 0; ProcessorNumber < NumberOfCpus; ProcessorNumber++) {
|
||||||
for (ProcessorNumber = 0; ProcessorNumber < NumberOfCpus; ProcessorNumber++) {
|
Location = &CpuFeaturesData->InitOrder[ProcessorNumber].CpuInfo.ProcessorInfo.Location;
|
||||||
Location = &CpuFeaturesData->InitOrder[ProcessorNumber].CpuInfo.ProcessorInfo.Location;
|
ThreadCountPerPackage[Location->Package]++;
|
||||||
if (Location->Package == Index && !CoresVisited[Location->Core] ) {
|
ThreadCountPerCore[Location->Package * CpuStatus->MaxCoreCount + Location->Core]++;
|
||||||
//
|
}
|
||||||
// The ValidCores position for Location->Core is valid.
|
|
||||||
// The possible values in ValidCores[Index] are 0 or 1.
|
for (PackageIndex = 0; PackageIndex < CpuStatus->PackageCount; PackageIndex++) {
|
||||||
// FALSE means no valid threads in this Core.
|
if (ThreadCountPerPackage[PackageIndex] != 0) {
|
||||||
// TRUE means have valid threads in this core, no matter the thead count is 1 or more.
|
DEBUG ((DEBUG_INFO, "P%02d: Thread Count = %d\n", PackageIndex, ThreadCountPerPackage[PackageIndex]));
|
||||||
//
|
for (CoreIndex = 0; CoreIndex < CpuStatus->MaxCoreCount; CoreIndex++) {
|
||||||
CoresVisited[Location->Core] = TRUE;
|
if (ThreadCountPerCore[PackageIndex * CpuStatus->MaxCoreCount + CoreIndex] != 0) {
|
||||||
ValidCoreCountPerPackage[Index]++;
|
DEBUG ((
|
||||||
|
DEBUG_INFO, " P%02d C%04d, Thread Count = %d\n", PackageIndex, CoreIndex,
|
||||||
|
ThreadCountPerCore[PackageIndex * CpuStatus->MaxCoreCount + CoreIndex]
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FreePool (CoresVisited);
|
|
||||||
|
|
||||||
for (Index = 0; Index <= Package; Index++) {
|
|
||||||
DEBUG ((DEBUG_INFO, "Package: %d, Valid Core : %d\n", Index, ValidCoreCountPerPackage[Index]));
|
|
||||||
}
|
|
||||||
|
|
||||||
CpuFeaturesData->CpuFlags.CoreSemaphoreCount = AllocateZeroPool (sizeof (UINT32) * CpuStatus->PackageCount * CpuStatus->MaxCoreCount * CpuStatus->MaxThreadCount);
|
CpuFeaturesData->CpuFlags.CoreSemaphoreCount = AllocateZeroPool (sizeof (UINT32) * CpuStatus->PackageCount * CpuStatus->MaxCoreCount * CpuStatus->MaxThreadCount);
|
||||||
ASSERT (CpuFeaturesData->CpuFlags.CoreSemaphoreCount != NULL);
|
ASSERT (CpuFeaturesData->CpuFlags.CoreSemaphoreCount != NULL);
|
||||||
|
@ -894,11 +890,11 @@ ProgramProcessorRegister (
|
||||||
CPU_REGISTER_TABLE_ENTRY *RegisterTableEntryHead;
|
CPU_REGISTER_TABLE_ENTRY *RegisterTableEntryHead;
|
||||||
volatile UINT32 *SemaphorePtr;
|
volatile UINT32 *SemaphorePtr;
|
||||||
UINT32 FirstThread;
|
UINT32 FirstThread;
|
||||||
UINT32 PackageThreadsCount;
|
|
||||||
UINT32 CurrentThread;
|
UINT32 CurrentThread;
|
||||||
|
UINT32 CurrentCore;
|
||||||
UINTN ProcessorIndex;
|
UINTN ProcessorIndex;
|
||||||
UINTN ValidThreadCount;
|
UINT32 *ThreadCountPerPackage;
|
||||||
UINT32 *ValidCoreCountPerPackage;
|
UINT8 *ThreadCountPerCore;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
UINT64 CurrentValue;
|
UINT64 CurrentValue;
|
||||||
|
|
||||||
|
@ -1029,28 +1025,44 @@ ProgramProcessorRegister (
|
||||||
switch (RegisterTableEntry->Value) {
|
switch (RegisterTableEntry->Value) {
|
||||||
case CoreDepType:
|
case CoreDepType:
|
||||||
SemaphorePtr = CpuFlags->CoreSemaphoreCount;
|
SemaphorePtr = CpuFlags->CoreSemaphoreCount;
|
||||||
|
ThreadCountPerCore = (UINT8 *)(UINTN)CpuStatus->ThreadCountPerCore;
|
||||||
|
|
||||||
|
CurrentCore = ApLocation->Package * CpuStatus->MaxCoreCount + ApLocation->Core;
|
||||||
//
|
//
|
||||||
// Get Offset info for the first thread in the core which current thread belongs to.
|
// Get Offset info for the first thread in the core which current thread belongs to.
|
||||||
//
|
//
|
||||||
FirstThread = (ApLocation->Package * CpuStatus->MaxCoreCount + ApLocation->Core) * CpuStatus->MaxThreadCount;
|
FirstThread = CurrentCore * CpuStatus->MaxThreadCount;
|
||||||
CurrentThread = FirstThread + ApLocation->Thread;
|
CurrentThread = FirstThread + ApLocation->Thread;
|
||||||
|
|
||||||
//
|
//
|
||||||
// First Notify all threads in current Core that this thread has ready.
|
// Different cores may have different valid threads in them. If driver maintail clearly
|
||||||
|
// thread index in different cores, the logic will be much complicated.
|
||||||
|
// Here driver just simply records the max thread number in all cores and use it as expect
|
||||||
|
// thread number for all cores.
|
||||||
|
// In below two steps logic, first current thread will Release semaphore for each thread
|
||||||
|
// in current core. Maybe some threads are not valid in this core, but driver don't
|
||||||
|
// care. Second, driver will let current thread wait semaphore for all valid threads in
|
||||||
|
// current core. Because only the valid threads will do release semaphore for this
|
||||||
|
// thread, driver here only need to wait the valid thread count.
|
||||||
|
//
|
||||||
|
|
||||||
|
//
|
||||||
|
// First Notify ALL THREADs in current Core that this thread is ready.
|
||||||
//
|
//
|
||||||
for (ProcessorIndex = 0; ProcessorIndex < CpuStatus->MaxThreadCount; ProcessorIndex ++) {
|
for (ProcessorIndex = 0; ProcessorIndex < CpuStatus->MaxThreadCount; ProcessorIndex ++) {
|
||||||
LibReleaseSemaphore ((UINT32 *) &SemaphorePtr[FirstThread + ProcessorIndex]);
|
LibReleaseSemaphore (&SemaphorePtr[FirstThread + ProcessorIndex]);
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// Second, check whether all valid threads in current core have ready.
|
// Second, check whether all VALID THREADs (not all threads) in current core are ready.
|
||||||
//
|
//
|
||||||
for (ProcessorIndex = 0; ProcessorIndex < CpuStatus->MaxThreadCount; ProcessorIndex ++) {
|
for (ProcessorIndex = 0; ProcessorIndex < ThreadCountPerCore[CurrentCore]; ProcessorIndex ++) {
|
||||||
LibWaitForSemaphore (&SemaphorePtr[CurrentThread]);
|
LibWaitForSemaphore (&SemaphorePtr[CurrentThread]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PackageDepType:
|
case PackageDepType:
|
||||||
SemaphorePtr = CpuFlags->PackageSemaphoreCount;
|
SemaphorePtr = CpuFlags->PackageSemaphoreCount;
|
||||||
ValidCoreCountPerPackage = (UINT32 *)(UINTN)CpuStatus->ValidCoreCountPerPackage;
|
ThreadCountPerPackage = (UINT32 *)(UINTN)CpuStatus->ThreadCountPerPackage;
|
||||||
//
|
//
|
||||||
// Get Offset info for the first thread in the package which current thread belongs to.
|
// Get Offset info for the first thread in the package which current thread belongs to.
|
||||||
//
|
//
|
||||||
|
@ -1058,18 +1070,13 @@ ProgramProcessorRegister (
|
||||||
//
|
//
|
||||||
// Get the possible threads count for current package.
|
// Get the possible threads count for current package.
|
||||||
//
|
//
|
||||||
PackageThreadsCount = CpuStatus->MaxThreadCount * CpuStatus->MaxCoreCount;
|
|
||||||
CurrentThread = FirstThread + CpuStatus->MaxThreadCount * ApLocation->Core + ApLocation->Thread;
|
CurrentThread = FirstThread + CpuStatus->MaxThreadCount * ApLocation->Core + ApLocation->Thread;
|
||||||
//
|
|
||||||
// Get the valid thread count for current package.
|
|
||||||
//
|
|
||||||
ValidThreadCount = CpuStatus->MaxThreadCount * ValidCoreCountPerPackage[ApLocation->Package];
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Different packages may have different valid cores in them. If driver maintail clearly
|
// Different packages may have different valid threads in them. If driver maintail clearly
|
||||||
// cores number in different packages, the logic will be much complicated.
|
// thread index in different packages, the logic will be much complicated.
|
||||||
// Here driver just simply records the max core number in all packages and use it as expect
|
// Here driver just simply records the max thread number in all packages and use it as expect
|
||||||
// core number for all packages.
|
// thread number for all packages.
|
||||||
// In below two steps logic, first current thread will Release semaphore for each thread
|
// In below two steps logic, first current thread will Release semaphore for each thread
|
||||||
// in current package. Maybe some threads are not valid in this package, but driver don't
|
// in current package. Maybe some threads are not valid in this package, but driver don't
|
||||||
// care. Second, driver will let current thread wait semaphore for all valid threads in
|
// care. Second, driver will let current thread wait semaphore for all valid threads in
|
||||||
|
@ -1078,15 +1085,15 @@ ProgramProcessorRegister (
|
||||||
//
|
//
|
||||||
|
|
||||||
//
|
//
|
||||||
// First Notify ALL THREADS in current package that this thread has ready.
|
// First Notify ALL THREADS in current package that this thread is ready.
|
||||||
//
|
//
|
||||||
for (ProcessorIndex = 0; ProcessorIndex < PackageThreadsCount ; ProcessorIndex ++) {
|
for (ProcessorIndex = 0; ProcessorIndex < CpuStatus->MaxThreadCount * CpuStatus->MaxCoreCount; ProcessorIndex ++) {
|
||||||
LibReleaseSemaphore ((UINT32 *) &SemaphorePtr[FirstThread + ProcessorIndex]);
|
LibReleaseSemaphore (&SemaphorePtr[FirstThread + ProcessorIndex]);
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// Second, check whether VALID THREADS (not all threads) in current package have ready.
|
// Second, check whether VALID THREADS (not all threads) in current package are ready.
|
||||||
//
|
//
|
||||||
for (ProcessorIndex = 0; ProcessorIndex < ValidThreadCount; ProcessorIndex ++) {
|
for (ProcessorIndex = 0; ProcessorIndex < ThreadCountPerPackage[ApLocation->Package]; ProcessorIndex ++) {
|
||||||
LibWaitForSemaphore (&SemaphorePtr[CurrentThread]);
|
LibWaitForSemaphore (&SemaphorePtr[CurrentThread]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
Code for Processor S3 restoration
|
Code for Processor S3 restoration
|
||||||
|
|
||||||
Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.<BR>
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
@ -235,11 +235,11 @@ ProgramProcessorRegister (
|
||||||
CPU_REGISTER_TABLE_ENTRY *RegisterTableEntryHead;
|
CPU_REGISTER_TABLE_ENTRY *RegisterTableEntryHead;
|
||||||
volatile UINT32 *SemaphorePtr;
|
volatile UINT32 *SemaphorePtr;
|
||||||
UINT32 FirstThread;
|
UINT32 FirstThread;
|
||||||
UINT32 PackageThreadsCount;
|
|
||||||
UINT32 CurrentThread;
|
UINT32 CurrentThread;
|
||||||
|
UINT32 CurrentCore;
|
||||||
UINTN ProcessorIndex;
|
UINTN ProcessorIndex;
|
||||||
UINTN ValidThreadCount;
|
UINT32 *ThreadCountPerPackage;
|
||||||
UINT32 *ValidCoreCountPerPackage;
|
UINT8 *ThreadCountPerCore;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
UINT64 CurrentValue;
|
UINT64 CurrentValue;
|
||||||
|
|
||||||
|
@ -372,35 +372,52 @@ ProgramProcessorRegister (
|
||||||
//
|
//
|
||||||
ASSERT (
|
ASSERT (
|
||||||
(ApLocation != NULL) &&
|
(ApLocation != NULL) &&
|
||||||
(CpuStatus->ValidCoreCountPerPackage != 0) &&
|
(CpuStatus->ThreadCountPerPackage != 0) &&
|
||||||
|
(CpuStatus->ThreadCountPerCore != 0) &&
|
||||||
(CpuFlags->CoreSemaphoreCount != NULL) &&
|
(CpuFlags->CoreSemaphoreCount != NULL) &&
|
||||||
(CpuFlags->PackageSemaphoreCount != NULL)
|
(CpuFlags->PackageSemaphoreCount != NULL)
|
||||||
);
|
);
|
||||||
switch (RegisterTableEntry->Value) {
|
switch (RegisterTableEntry->Value) {
|
||||||
case CoreDepType:
|
case CoreDepType:
|
||||||
SemaphorePtr = CpuFlags->CoreSemaphoreCount;
|
SemaphorePtr = CpuFlags->CoreSemaphoreCount;
|
||||||
|
ThreadCountPerCore = (UINT8 *)(UINTN)CpuStatus->ThreadCountPerCore;
|
||||||
|
|
||||||
|
CurrentCore = ApLocation->Package * CpuStatus->MaxCoreCount + ApLocation->Core;
|
||||||
//
|
//
|
||||||
// Get Offset info for the first thread in the core which current thread belongs to.
|
// Get Offset info for the first thread in the core which current thread belongs to.
|
||||||
//
|
//
|
||||||
FirstThread = (ApLocation->Package * CpuStatus->MaxCoreCount + ApLocation->Core) * CpuStatus->MaxThreadCount;
|
FirstThread = CurrentCore * CpuStatus->MaxThreadCount;
|
||||||
CurrentThread = FirstThread + ApLocation->Thread;
|
CurrentThread = FirstThread + ApLocation->Thread;
|
||||||
|
|
||||||
//
|
//
|
||||||
// First Notify all threads in current Core that this thread has ready.
|
// Different cores may have different valid threads in them. If driver maintail clearly
|
||||||
|
// thread index in different cores, the logic will be much complicated.
|
||||||
|
// Here driver just simply records the max thread number in all cores and use it as expect
|
||||||
|
// thread number for all cores.
|
||||||
|
// In below two steps logic, first current thread will Release semaphore for each thread
|
||||||
|
// in current core. Maybe some threads are not valid in this core, but driver don't
|
||||||
|
// care. Second, driver will let current thread wait semaphore for all valid threads in
|
||||||
|
// current core. Because only the valid threads will do release semaphore for this
|
||||||
|
// thread, driver here only need to wait the valid thread count.
|
||||||
|
//
|
||||||
|
|
||||||
|
//
|
||||||
|
// First Notify ALL THREADs in current Core that this thread is ready.
|
||||||
//
|
//
|
||||||
for (ProcessorIndex = 0; ProcessorIndex < CpuStatus->MaxThreadCount; ProcessorIndex ++) {
|
for (ProcessorIndex = 0; ProcessorIndex < CpuStatus->MaxThreadCount; ProcessorIndex ++) {
|
||||||
S3ReleaseSemaphore (&SemaphorePtr[FirstThread + ProcessorIndex]);
|
S3ReleaseSemaphore (&SemaphorePtr[FirstThread + ProcessorIndex]);
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// Second, check whether all valid threads in current core have ready.
|
// Second, check whether all VALID THREADs (not all threads) in current core are ready.
|
||||||
//
|
//
|
||||||
for (ProcessorIndex = 0; ProcessorIndex < CpuStatus->MaxThreadCount; ProcessorIndex ++) {
|
for (ProcessorIndex = 0; ProcessorIndex < ThreadCountPerCore[CurrentCore]; ProcessorIndex ++) {
|
||||||
S3WaitForSemaphore (&SemaphorePtr[CurrentThread]);
|
S3WaitForSemaphore (&SemaphorePtr[CurrentThread]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PackageDepType:
|
case PackageDepType:
|
||||||
SemaphorePtr = CpuFlags->PackageSemaphoreCount;
|
SemaphorePtr = CpuFlags->PackageSemaphoreCount;
|
||||||
ValidCoreCountPerPackage = (UINT32 *)(UINTN)CpuStatus->ValidCoreCountPerPackage;
|
ThreadCountPerPackage = (UINT32 *)(UINTN)CpuStatus->ThreadCountPerPackage;
|
||||||
//
|
//
|
||||||
// Get Offset info for the first thread in the package which current thread belongs to.
|
// Get Offset info for the first thread in the package which current thread belongs to.
|
||||||
//
|
//
|
||||||
|
@ -408,18 +425,13 @@ ProgramProcessorRegister (
|
||||||
//
|
//
|
||||||
// Get the possible threads count for current package.
|
// Get the possible threads count for current package.
|
||||||
//
|
//
|
||||||
PackageThreadsCount = CpuStatus->MaxThreadCount * CpuStatus->MaxCoreCount;
|
|
||||||
CurrentThread = FirstThread + CpuStatus->MaxThreadCount * ApLocation->Core + ApLocation->Thread;
|
CurrentThread = FirstThread + CpuStatus->MaxThreadCount * ApLocation->Core + ApLocation->Thread;
|
||||||
//
|
|
||||||
// Get the valid thread count for current package.
|
|
||||||
//
|
|
||||||
ValidThreadCount = CpuStatus->MaxThreadCount * ValidCoreCountPerPackage[ApLocation->Package];
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Different packages may have different valid cores in them. If driver maintail clearly
|
// Different packages may have different valid threads in them. If driver maintail clearly
|
||||||
// cores number in different packages, the logic will be much complicated.
|
// thread index in different packages, the logic will be much complicated.
|
||||||
// Here driver just simply records the max core number in all packages and use it as expect
|
// Here driver just simply records the max thread number in all packages and use it as expect
|
||||||
// core number for all packages.
|
// thread number for all packages.
|
||||||
// In below two steps logic, first current thread will Release semaphore for each thread
|
// In below two steps logic, first current thread will Release semaphore for each thread
|
||||||
// in current package. Maybe some threads are not valid in this package, but driver don't
|
// in current package. Maybe some threads are not valid in this package, but driver don't
|
||||||
// care. Second, driver will let current thread wait semaphore for all valid threads in
|
// care. Second, driver will let current thread wait semaphore for all valid threads in
|
||||||
|
@ -428,15 +440,15 @@ ProgramProcessorRegister (
|
||||||
//
|
//
|
||||||
|
|
||||||
//
|
//
|
||||||
// First Notify all threads in current package that this thread has ready.
|
// First Notify ALL THREADS in current package that this thread is ready.
|
||||||
//
|
//
|
||||||
for (ProcessorIndex = 0; ProcessorIndex < PackageThreadsCount ; ProcessorIndex ++) {
|
for (ProcessorIndex = 0; ProcessorIndex < CpuStatus->MaxThreadCount * CpuStatus->MaxCoreCount; ProcessorIndex ++) {
|
||||||
S3ReleaseSemaphore (&SemaphorePtr[FirstThread + ProcessorIndex]);
|
S3ReleaseSemaphore (&SemaphorePtr[FirstThread + ProcessorIndex]);
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// Second, check whether all valid threads in current package have ready.
|
// Second, check whether VALID THREADS (not all threads) in current package are ready.
|
||||||
//
|
//
|
||||||
for (ProcessorIndex = 0; ProcessorIndex < ValidThreadCount; ProcessorIndex ++) {
|
for (ProcessorIndex = 0; ProcessorIndex < ThreadCountPerPackage[ApLocation->Package]; ProcessorIndex ++) {
|
||||||
S3WaitForSemaphore (&SemaphorePtr[CurrentThread]);
|
S3WaitForSemaphore (&SemaphorePtr[CurrentThread]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1059,12 +1071,19 @@ GetAcpiCpuData (
|
||||||
|
|
||||||
CpuStatus = &mAcpiCpuData.CpuStatus;
|
CpuStatus = &mAcpiCpuData.CpuStatus;
|
||||||
CopyMem (CpuStatus, &AcpiCpuData->CpuStatus, sizeof (CPU_STATUS_INFORMATION));
|
CopyMem (CpuStatus, &AcpiCpuData->CpuStatus, sizeof (CPU_STATUS_INFORMATION));
|
||||||
if (AcpiCpuData->CpuStatus.ValidCoreCountPerPackage != 0) {
|
if (AcpiCpuData->CpuStatus.ThreadCountPerPackage != 0) {
|
||||||
CpuStatus->ValidCoreCountPerPackage = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocateCopyPool (
|
CpuStatus->ThreadCountPerPackage = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocateCopyPool (
|
||||||
sizeof (UINT32) * CpuStatus->PackageCount,
|
sizeof (UINT32) * CpuStatus->PackageCount,
|
||||||
(UINT32 *)(UINTN)AcpiCpuData->CpuStatus.ValidCoreCountPerPackage
|
(UINT32 *)(UINTN)AcpiCpuData->CpuStatus.ThreadCountPerPackage
|
||||||
);
|
);
|
||||||
ASSERT (CpuStatus->ValidCoreCountPerPackage != 0);
|
ASSERT (CpuStatus->ThreadCountPerPackage != 0);
|
||||||
|
}
|
||||||
|
if (AcpiCpuData->CpuStatus.ThreadCountPerCore != 0) {
|
||||||
|
CpuStatus->ThreadCountPerCore = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocateCopyPool (
|
||||||
|
sizeof (UINT8) * (CpuStatus->PackageCount * CpuStatus->MaxCoreCount),
|
||||||
|
(UINT32 *)(UINTN)AcpiCpuData->CpuStatus.ThreadCountPerCore
|
||||||
|
);
|
||||||
|
ASSERT (CpuStatus->ThreadCountPerCore != 0);
|
||||||
}
|
}
|
||||||
if (AcpiCpuData->ApLocation != 0) {
|
if (AcpiCpuData->ApLocation != 0) {
|
||||||
mAcpiCpuData.ApLocation = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocateCopyPool (
|
mAcpiCpuData.ApLocation = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocateCopyPool (
|
||||||
|
|
Loading…
Reference in New Issue