From nobody Fri Apr 19 07:35:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+96415+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+96415+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1668567215; cv=none; d=zohomail.com; s=zohoarc; b=arFkqqiDyZcCZwGu8ZmJ942ZpbIONn/5NUtmfRIHVbMgsEOtoMYG8In1q1TUZSUGRFriGKLV1cscD4FsmKS9OCPk76X2RPH4Qia6JMNwCZQ5TFlGQCZ0hbn0wzFrJa64uv9SuUut+Bn39K7RjMYVZGgVgScJLZ09Ypa/K2KhQhQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668567215; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=F4VFPL6S66Ug4xtYWYhPmC4sf7Wnrg7eM7e4joj/Bq8=; b=ctXanWIa9wqXsnQX2DKswkG5cqtg3eNVWCStBqa/zokpIBhPuB956J8Tw1kbGn62A9cOkDYIWPDUDi45ieCQEdGF4YZmupkEg7wx4Nr69ijzYA9Dc8FWJf/6GEVG01PegJHZeBBAKWgM4AB0shDtLNGNfilN+v/UrbrllLOxMwI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+96415+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1668567215767250.55702230911731; Tue, 15 Nov 2022 18:53:35 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id Ah0FYY1788612xer7PUEHUB8; Tue, 15 Nov 2022 18:53:35 -0800 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web09.2422.1668567214748866853 for ; Tue, 15 Nov 2022 18:53:34 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10532"; a="313578416" X-IronPort-AV: E=Sophos;i="5.96,167,1665471600"; d="scan'208";a="313578416" X-Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2022 18:53:34 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10532"; a="968247967" X-IronPort-AV: E=Sophos;i="5.96,167,1665471600"; d="scan'208";a="968247967" X-Received: from lins2x-desk1.gar.corp.intel.com ([10.225.33.149]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2022 18:53:12 -0800 From: "JackX Lin" To: devel@edk2.groups.io Cc: JackX Lin , JackX Lin , Chasel Chiu , Nate DeSimone , Isaac Oram , Liming Gao , Eric Dong , Donald Kuo , Chandana C Kumar Subject: [edk2-devel] [edk2-platforms: PATCH] BIOS needs to present cores in order of relative performance in MADT Date: Wed, 16 Nov 2022 10:52:46 +0800 Message-Id: <20221116025246.2075-1-jackx.lin@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,JackX.Lin@intel.com X-Gm-Message-State: jogvnzgtzuKWKm4R4gNuiIdFx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1668567215; bh=v45x0BJoo+rp3Qt8TclfYeeTZi67JHAQomIAv/3a6SA=; h=Cc:Date:From:Reply-To:Subject:To; b=tbc/EvBJKQrJRncRyS/i++4bxkxKka0a+8Z+fMLEo1aW1mM5SMxk6XhneAH/eFj4Fc7 s6Aq4xd0cSK61u92Uo0cEAcfIdvgEJQzmKO57q1eolNK34+IQaedDILBV/ze0hxTPlGLg APUoAOQCRJO+vn/kxAbiOwA0QkPa1IC27UY= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1668567216974100002 Content-Type: text/plain; charset="utf-8" BIOS should keep MADT ordering by big core first then small core Signed-off-by: JackX Lin Cc: Chasel Chiu Cc: Nate DeSimone Cc: Isaac Oram Cc: Liming Gao Cc: Eric Dong Cc: Donald Kuo Cc: Chandana C Kumar Cc: JackX Lin --- Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c | 149 +++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 142 insertions(+), 7 deletions(-) diff --git a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c b= /Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c index 6e57b638e0..02c1dd3a91 100644 --- a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c +++ b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c @@ -18,6 +18,7 @@ typedef struct { UINT32 Flags; UINT32 SocketNum; UINT32 Thread; + BOOLEAN IsBigCore; } EFI_CPU_ID_ORDER_MAP; =20 // @@ -131,6 +132,104 @@ AppendCpuMapTableEntry ( =20 } =20 +/** + Detect if Hetero Core is supported. + + @retval TRUE - Processor support HeteroCore + @retval FALSE - Processor doesnt support HeteroCore +**/ +BOOLEAN +EFIAPI +IsHeteroCoreSupported ( + VOID + ) +{ + CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_EDX Edx; + + /// + /// Check Hetero feature is supported + /// with CPUID.(EAX=3D7,ECX=3D0):EDX[15]=3D1 + /// + AsmCpuidEx (CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS, 0, NULL, NULL, NULL= , &Edx.Uint32); + if (Edx.Bits.Hybrid =3D=3D 1) { + return TRUE; + } + return FALSE; +} + +/** + Detect the type of core, whether it is Big/Small Core. + + @param[out] CoreType Output pointer that get CPUID_NATIVE_MODEL_= ID_INFO data + 10h - Quark + 20h - Atom + 30H - Knights + 40H - Core +**/ +VOID +EFIAPI +GetCoreType ( + OUT UINT8 *CoreType + ) +{ + UINT32 Eax; + + if (IsHeteroCoreSupported ()) { + // + // Check which is the running core by reading CPUID.(EAX=3D1AH, ECX=3D= 00H):EAX + // + AsmCpuid (CPUID_HYBRID_INFORMATION, &Eax, NULL, NULL, NULL); + *CoreType =3D (UINT8)((Eax & 0xFF000000) >> 24); + } else { + *CoreType =3D CPUID_CORE_TYPE_INTEL_CORE; + } +} + +/** + Function will go through all processors to identify Core or Atom + by checking Core Type and update in IsBigCore. + + @param[in] CpuApicIdOrderTable Point to a buffer which will be f= illed in Core type information. +**/ +VOID +STATIC +EFIAPI +CollectCpuCoreType ( + IN EFI_CPU_ID_ORDER_MAP *CpuApicIdOrderTable + ) +{ + CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_EDX Edx; + UINT32 Eax; + UINTN ApNumber; + EFI_STATUS Status; + UINT8 CoreType; + + Status =3D mMpService->WhoAmI ( + mMpService, + &ApNumber + ); + ASSERT_EFI_ERROR (Status); + + /// + /// Check Hetero feature is supported + /// with CPUID.(EAX=3D7,ECX=3D0):EDX[15]=3D1 + /// + AsmCpuidEx (CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS, 0, NULL, NULL, NULL= , &Edx.Uint32); + if (Edx.Bits.Hybrid =3D=3D 1) { + // + // Check which is the running core by reading CPUID.(EAX=3D1AH, ECX=3D= 00H):EAX + // + AsmCpuid (CPUID_HYBRID_INFORMATION, &Eax, NULL, NULL, NULL); + CoreType =3D (UINT8) ((Eax & 0xFF000000) >> 24); + } else { + CoreType =3D CPUID_CORE_TYPE_INTEL_CORE; + } + + if (CoreType =3D=3D CPUID_CORE_TYPE_INTEL_CORE) { + CpuApicIdOrderTable[ApNumber].IsBigCore =3D TRUE; + } +} + /** Collect all processors information and create a Cpu Apic Id table. =20 @@ -138,7 +237,7 @@ AppendCpuMapTableEntry ( **/ EFI_STATUS CreateCpuLocalApicInTable ( - IN EFI_CPU_ID_ORDER_MAP *CpuApicIdOrderTable + IN EFI_CPU_ID_ORDER_MAP *CpuApicIdOrderTable ) { EFI_STATUS Status; @@ -146,9 +245,24 @@ CreateCpuLocalApicInTable ( UINT32 Index; UINT32 CurrProcessor; EFI_CPU_ID_ORDER_MAP *CpuIdMapPtr; + EFI_CPU_ID_ORDER_MAP *TempCpuApicIdOrderTable; UINT32 Socket; =20 - Status =3D EFI_SUCCESS; + TempCpuApicIdOrderTable =3D AllocateZeroPool (mNumberOfCpus * sizeof (EF= I_CPU_ID_ORDER_MAP)); + if (TempCpuApicIdOrderTable =3D=3D NULL) { + return EFI_UNSUPPORTED; + } + + CollectCpuCoreType (TempCpuApicIdOrderTable); + mMpService->StartupAllAPs ( + mMpService, // This + (EFI_AP_PROCEDURE) CollectCpuCoreType, // Procedure + TRUE, // SingleThread + NULL, // WaitEvent + 0, // TimeoutInMicr= osecsond + TempCpuApicIdOrderTable, // ProcedureArgu= ment + NULL // FailedCpuList + ); =20 for (CurrProcessor =3D 0, Index =3D 0; CurrProcessor < mNumberOfCpus; Cu= rrProcessor++, Index++) { Status =3D mMpService->GetProcessorInfo ( @@ -157,9 +271,9 @@ CreateCpuLocalApicInTable ( &ProcessorInfoBuffer ); =20 - CpuIdMapPtr =3D (EFI_CPU_ID_ORDER_MAP *) &CpuApicIdOrderTable[Index]; + CpuIdMapPtr =3D (EFI_CPU_ID_ORDER_MAP *) &TempCpuApicIdOrderTable[Inde= x]; if ((ProcessorInfoBuffer.StatusFlag & PROCESSOR_ENABLED_BIT) !=3D 0) { - CpuIdMapPtr->ApicId =3D (UINT32)ProcessorInfoBuffer.ProcessorId; + CpuIdMapPtr->ApicId =3D (UINT32) ProcessorInfoBuffer.ProcessorId; CpuIdMapPtr->Thread =3D ProcessorInfoBuffer.Location.Thread; CpuIdMapPtr->Flags =3D ((ProcessorInfoBuffer.StatusFlag & PROCESSO= R_ENABLED_BIT) !=3D 0); CpuIdMapPtr->SocketNum =3D ProcessorInfoBuffer.Location.Package; @@ -184,22 +298,43 @@ CreateCpuLocalApicInTable ( // DEBUG ((DEBUG_INFO, "BspApicId - 0x%x\n", GetApicId ())); =20 - // // Fill in AcpiProcessorUid. // for (Socket =3D 0; Socket < FixedPcdGet32 (PcdMaxCpuSocketCount); Socket= ++) { for (CurrProcessor =3D 0, Index =3D 0; CurrProcessor < mNumberOfCpus; = CurrProcessor++) { - if (CpuApicIdOrderTable[CurrProcessor].Flags && (CpuApicIdOrderTable= [CurrProcessor].SocketNum =3D=3D Socket)) { - CpuApicIdOrderTable[CurrProcessor].AcpiProcessorUid =3D (CpuApicId= OrderTable[CurrProcessor].SocketNum << mNumOfBitShift) + Index; + if (TempCpuApicIdOrderTable[CurrProcessor].Flags && (TempCpuApicIdOr= derTable[CurrProcessor].SocketNum =3D=3D Socket)) { + TempCpuApicIdOrderTable[CurrProcessor].AcpiProcessorUid =3D (TempC= puApicIdOrderTable[CurrProcessor].SocketNum << mNumOfBitShift) + Index; Index++; } } } =20 + // + // Re-ordering Cpu cores information to CpuApicIdOrderTable + // by big core first, then small core. + // + for (Index =3D 0, CurrProcessor =3D 0; Index < mNumberOfCpus; Index++) { + if (TempCpuApicIdOrderTable[Index].IsBigCore) { + CopyMem (&CpuApicIdOrderTable[CurrProcessor], &TempCpuApicIdOrderTab= le[Index], sizeof (EFI_CPU_ID_ORDER_MAP)); + CurrProcessor++; + } + } + + for (Index =3D 0; Index < mNumberOfCpus; Index++) { + if (!(TempCpuApicIdOrderTable[Index].IsBigCore)) { + CopyMem (&CpuApicIdOrderTable[CurrProcessor], &TempCpuApicIdOrderTab= le[Index], sizeof (EFI_CPU_ID_ORDER_MAP)); + CurrProcessor++; + } + } + DEBUG ((DEBUG_INFO, "::ACPI:: APIC ID Order Table Init. mNumOfBitShif= t =3D %x\n", mNumOfBitShift)); DebugDisplayReOrderTable (CpuApicIdOrderTable); =20 + if (TempCpuApicIdOrderTable !=3D NULL) { + FreePool (TempCpuApicIdOrderTable); + } + return Status; } =20 --=20 2.32.0.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#96415): https://edk2.groups.io/g/devel/message/96415 Mute This Topic: https://groups.io/mt/95059445/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-