From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id CE534AC138A for ; Wed, 7 Aug 2024 11:35:29 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=wrSfRSAMlQpwZCyruNTKTkfED5K2QEs1fRXz1nEQ4G4=; c=relaxed/simple; d=groups.io; h=From:Date:Subject:MIME-Version:Message-Id:References:In-Reply-To:To:Cc:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type:Content-Transfer-Encoding; s=20240206; t=1723030529; v=1; b=qSwiDp7gJpgHAGhxv1saV1W35ixa8goEcnlMPrDsD5OGi1P8W8F1sZeD96vij9wbwMmUP4vw T+TMcBD3B9n41Ha4ocIbCY/8IdcaAQvSyyFuwQg/RtKspI8QdfPhxfdkZcBYFrAyQtnDJK+f/e7 SsfXdDW2n5Ff4erGkrngrrMMNsu1B+xaQAvlzoY3kn722Vb7N3gDMOXNyb1BfFgije/Hs05SF8k YTV0w3KaJAL8vh3iANBGmkMaGSNBcw7JGMmZ+GyJGJfEUjEaK/K1vXs2A+3JxI6FZbFNsO7JyGZ eDvm/8f0Wg63kPqWZO96jRzV1SmXo0vQJ78ygc4wzIlKA== X-Received: by 127.0.0.2 with SMTP id s4rPYY7687511xlDUisv1HLs; Wed, 07 Aug 2024 04:35:28 -0700 X-Received: from muminek.juszkiewicz.com.pl (muminek.juszkiewicz.com.pl [213.251.184.221]) by mx.groups.io with SMTP id smtpd.web11.31324.1723030522489227426 for ; Wed, 07 Aug 2024 04:35:22 -0700 X-Received: from localhost (localhost [127.0.0.1]) by muminek.juszkiewicz.com.pl (Postfix) with ESMTP id 7EA36261A09; Wed, 7 Aug 2024 13:35:20 +0200 (CEST) X-Virus-Scanned: Debian amavis at juszkiewicz.com.pl X-Received: from muminek.juszkiewicz.com.pl ([127.0.0.1]) by localhost (muminek.juszkiewicz.com.pl [127.0.0.1]) (amavis, port 10024) with ESMTP id rcMu8nfyQ6O2; Wed, 7 Aug 2024 13:35:18 +0200 (CEST) X-Received: from applejack.lan (83.8.56.232.ipv4.supernova.orange.pl [83.8.56.232]) by muminek.juszkiewicz.com.pl (Postfix) with ESMTPSA id B5112261993; Wed, 7 Aug 2024 13:35:16 +0200 (CEST) From: "Marcin Juszkiewicz" Date: Wed, 07 Aug 2024 13:34:43 +0200 Subject: [edk2-devel] [PATCH edk2-platforms v6 5/6] SbsaQemu: introduce helper in PPTT generation MIME-Version: 1.0 Message-Id: <20240807-acpi65-v6-5-fc426e4abfe2@linaro.org> References: <20240807-acpi65-v6-0-fc426e4abfe2@linaro.org> In-Reply-To: <20240807-acpi65-v6-0-fc426e4abfe2@linaro.org> To: devel@edk2.groups.io Cc: Xiong Yining , Marcin Juszkiewicz , Leif Lindholm , Ard Biesheuvel , Graeme Gregory , Chen Baozi , Jonathan Cameron Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Wed, 07 Aug 2024 04:35:22 -0700 Resent-From: marcin.juszkiewicz@linaro.org Reply-To: devel@edk2.groups.io,marcin.juszkiewicz@linaro.org List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: JR4f1EZAPBYmCNJ8Jil6r6k0x7686176AA= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=qSwiDp7g; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=linaro.org (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io Function AddPpttTable() adding PPTT got too long. This change moves part of it into helper function AddCoresToPpttTable() which takes care of generating entries for Core and below (Cache, Thread). Signed-off-by: Marcin Juszkiewicz --- .../Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c | 243 +++++++++++-----= ---- 1 file changed, 133 insertions(+), 110 deletions(-) diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.= c b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c index e4bdd5edbd95..61f9de45d082 100644 --- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c +++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c @@ -31,6 +31,9 @@ static UINTN GicItsBase; =20 #pragma pack () =20 +static UINTN mCpuId; +static UINTN mCacheId; + /* * A Function to Compute the ACPI Table Checksum */ @@ -491,6 +494,127 @@ AddSsdtTable ( return Status; } =20 +STATIC +UINT32 +AddCoresToPpttTable ( + UINT8 *New, + UINT32 ClusterOffset, + CpuTopology CpuTopo + ) +{ + UINT32 L1DCacheOffset; + UINT32 L1ICacheOffset; + UINT32 L2CacheOffset; + UINT32 CoreOffset; + UINT32 Offset; + UINT32 CoreCpuId; + UINT32 CoreIndex; + UINT32 ThreadIndex; + UINT32 *PrivateResourcePtr; + + EFI_ACPI_6_5_PPTT_STRUCTURE_PROCESSOR_FLAGS CoreFlags =3D { + EFI_ACPI_6_5_PPTT_PACKAGE_NOT_PHYSICAL, + EFI_ACPI_6_5_PPTT_PROCESSOR_ID_VALID, + EFI_ACPI_6_5_PPTT_PROCESSOR_IS_NOT_THREAD, + EFI_ACPI_6_5_PPTT_NODE_IS_LEAF, + EFI_ACPI_6_5_PPTT_IMPLEMENTATION_IDENTICAL + }; + + if (CpuTopo.Threads > 1) { + // The Thread structure is the leaf structure, adjust the value of Cor= eFlags. + CoreFlags.AcpiProcessorIdValid =3D EFI_ACPI_6_5_PPTT_PROCESSOR_ID_INVA= LID; + CoreFlags.NodeIsALeaf =3D EFI_ACPI_6_5_PPTT_NODE_IS_NOT_LEAF; + } + + EFI_ACPI_6_5_PPTT_STRUCTURE_PROCESSOR_FLAGS ThreadFlags =3D { + EFI_ACPI_6_5_PPTT_PACKAGE_NOT_PHYSICAL, + EFI_ACPI_6_5_PPTT_PROCESSOR_ID_VALID, + EFI_ACPI_6_5_PPTT_PROCESSOR_IS_THREAD, + EFI_ACPI_6_5_PPTT_NODE_IS_LEAF, + EFI_ACPI_6_5_PPTT_IMPLEMENTATION_IDENTICAL + }; + + EFI_ACPI_6_5_PPTT_STRUCTURE_CACHE L1DCache =3D SBSAQEMU_ACPI_PPTT_L1_D_= CACHE_STRUCT; + EFI_ACPI_6_5_PPTT_STRUCTURE_CACHE L1ICache =3D SBSAQEMU_ACPI_PPTT_L1_I_= CACHE_STRUCT; + EFI_ACPI_6_5_PPTT_STRUCTURE_CACHE L2Cache =3D SBSAQEMU_ACPI_PPTT_L2_CA= CHE_STRUCT; + + CoreOffset =3D ClusterOffset + sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_PROCE= SSOR); + Offset =3D CoreOffset; + + for (CoreIndex =3D 0; CoreIndex < CpuTopo.Cores; CoreIndex++) { + if (CpuTopo.Threads =3D=3D 1) { + CoreCpuId =3D mCpuId; + } else { + CoreCpuId =3D 0; + } + + // space for Core + PrivateResourcePtr + Offset +=3D sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_PROCESSOR); + Offset +=3D sizeof (UINT32) * 2; + + L1DCacheOffset =3D Offset; + L1ICacheOffset =3D L1DCacheOffset + sizeof (EFI_ACPI_6_5_PPTT_STRUCTUR= E_CACHE); + L2CacheOffset =3D L1ICacheOffset + sizeof (EFI_ACPI_6_5_PPTT_STRUCTUR= E_CACHE); + + EFI_ACPI_6_5_PPTT_STRUCTURE_PROCESSOR Core =3D SBSAQEMU_ACPI_PROCESSO= R_HIERARCHY_NODE_STRUCTURE_INIT ( + CoreFlags, + ClusterOffset, + CoreCpuId, + 2 + ); + + CopyMem (New, &Core, sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_PROCESSOR)); + New +=3D sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_PROCESSOR); + + PrivateResourcePtr =3D (UINT32 *)New; + PrivateResourcePtr[0] =3D L1DCacheOffset; + PrivateResourcePtr[1] =3D L1ICacheOffset; + New +=3D (2 * sizeof (UINT32)); + + // Add L1 D Cache structure + L1DCache.CacheId =3D mCacheId++; + CopyMem (New, &L1DCache, sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_CACHE)); + ((EFI_ACPI_6_5_PPTT_STRUCTURE_CACHE *)New)->NextLevelOfCache =3D L2Cac= heOffset; + New +=3D sizeo= f (EFI_ACPI_6_5_PPTT_STRUCTURE_CACHE); + + // Add L1 I Cache structure + L1ICache.CacheId =3D mCacheId++; + CopyMem (New, &L1ICache, sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_CACHE)); + ((EFI_ACPI_6_5_PPTT_STRUCTURE_CACHE *)New)->NextLevelOfCache =3D L2Cac= heOffset; + New +=3D sizeo= f (EFI_ACPI_6_5_PPTT_STRUCTURE_CACHE); + + // Add L2 Cache structure + L2Cache.CacheId =3D mCacheId++; + CopyMem (New, &L2Cache, sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_CACHE)); + New +=3D sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_CACHE); + + Offset +=3D sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_CACHE) * 3; + + if (CpuTopo.Threads =3D=3D 1) { + mCpuId++; + } else { + // Add the Thread PPTT structure + for (ThreadIndex =3D 0; ThreadIndex < CpuTopo.Threads; ThreadIndex++= ) { + EFI_ACPI_6_5_PPTT_STRUCTURE_PROCESSOR Thread =3D SBSAQEMU_ACPI_PR= OCESSOR_HIERARCHY_NODE_STRUCTURE_INIT ( + ThreadFlags, + CoreOffset, + mCpuId, + 0 + ); + CopyMem (New, &Thread, sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_PROCESS= OR)); + New +=3D sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_PROCESSOR); + mCpuId++; + } + + Offset +=3D CpuTopo.Threads * sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_P= ROCESSOR); + } + + CoreOffset =3D Offset; + } + + return CoreOffset - ClusterOffset; +} + /* * A function that adds the PPTT ACPI table. */ @@ -502,28 +626,17 @@ AddPpttTable ( EFI_STATUS Status; UINTN TableHandle; UINT32 TableSize; - EFI_PHYSICAL_ADDRESS PageAddress; - UINT8 *New; - UINT32 CpuId; - CpuTopology CpuTopo; + UINT32 CoresPartSize; UINT32 SocketIndex; UINT32 ClusterIndex; - UINT32 CoreIndex; - UINT32 ThreadIndex; UINT32 SocketOffset; UINT32 ClusterOffset; - UINT32 CoreOffset; - UINT32 L1DCacheOffset; - UINT32 L1ICacheOffset; - UINT32 L2CacheOffset; - UINT32 CacheId; + EFI_PHYSICAL_ADDRESS PageAddress; + UINT8 *New; + CpuTopology CpuTopo; =20 GetCpuTopology (&CpuTopo); =20 - EFI_ACPI_6_5_PPTT_STRUCTURE_CACHE L1DCache =3D SBSAQEMU_ACPI_PPTT_L1_D_= CACHE_STRUCT; - EFI_ACPI_6_5_PPTT_STRUCTURE_CACHE L1ICache =3D SBSAQEMU_ACPI_PPTT_L1_I_= CACHE_STRUCT; - EFI_ACPI_6_5_PPTT_STRUCTURE_CACHE L2Cache =3D SBSAQEMU_ACPI_PPTT_L2_CA= CHE_STRUCT; - EFI_ACPI_6_5_PPTT_STRUCTURE_PROCESSOR_FLAGS SocketFlags =3D { EFI_ACPI_6_5_PPTT_PACKAGE_PHYSICAL, EFI_ACPI_6_5_PPTT_PROCESSOR_ID_INVALID, @@ -540,28 +653,6 @@ AddPpttTable ( EFI_ACPI_6_5_PPTT_IMPLEMENTATION_IDENTICAL }; =20 - EFI_ACPI_6_5_PPTT_STRUCTURE_PROCESSOR_FLAGS CoreFlags =3D { - EFI_ACPI_6_5_PPTT_PACKAGE_NOT_PHYSICAL, - EFI_ACPI_6_5_PPTT_PROCESSOR_ID_VALID, - EFI_ACPI_6_5_PPTT_PROCESSOR_IS_NOT_THREAD, - EFI_ACPI_6_5_PPTT_NODE_IS_LEAF, - EFI_ACPI_6_5_PPTT_IMPLEMENTATION_IDENTICAL - }; - - if (CpuTopo.Threads > 1) { - // The Thread structure is the leaf structure, adjust the value of Cor= eFlags. - CoreFlags.AcpiProcessorIdValid =3D EFI_ACPI_6_5_PPTT_PROCESSOR_ID_INVA= LID; - CoreFlags.NodeIsALeaf =3D EFI_ACPI_6_5_PPTT_NODE_IS_NOT_LEAF; - } - - EFI_ACPI_6_5_PPTT_STRUCTURE_PROCESSOR_FLAGS ThreadFlags =3D { - EFI_ACPI_6_5_PPTT_PACKAGE_NOT_PHYSICAL, - EFI_ACPI_6_5_PPTT_PROCESSOR_ID_VALID, - EFI_ACPI_6_5_PPTT_PROCESSOR_IS_THREAD, - EFI_ACPI_6_5_PPTT_NODE_IS_LEAF, - EFI_ACPI_6_5_PPTT_IMPLEMENTATION_IDENTICAL - }; - EFI_ACPI_DESCRIPTION_HEADER Header =3D SBSAQEMU_ACPI_HEADER ( EFI_ACPI_6_5_PROCESSOR_PROPERTIES_TOPOLOGY_TABLE_STRUCTURE_SIGNATURE= , @@ -600,8 +691,8 @@ AddPpttTable ( ((EFI_ACPI_DESCRIPTION_HEADER *)New)->Length =3D TableSize; New +=3D sizeof (EFI_ACPI_DESCRI= PTION_HEADER); =20 - CpuId =3D 0; - CacheId =3D 1; // 0 is not a valid Cache ID. + mCpuId =3D 0; + mCacheId =3D 1; // 0 is not a valid Cache ID. =20 SocketOffset =3D sizeof (EFI_ACPI_DESCRIPTION_HEADER); for (SocketIndex =3D 0; SocketIndex < CpuTopo.Sockets; SocketIndex++) { @@ -627,77 +718,9 @@ AddPpttTable ( CopyMem (New, &Cluster, sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_PROCESSO= R)); New +=3D sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_PROCESSOR); =20 - CoreOffset =3D ClusterOffset + sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_P= ROCESSOR); - for (CoreIndex =3D 0; CoreIndex < CpuTopo.Cores; CoreIndex++) { - UINT32 *PrivateResourcePtr; - UINT32 CoreCpuId; - - // two UINT32s for PrivateResourcePtr data - L1DCacheOffset =3D CoreOffset + sizeof (EFI_ACPI_6_5_PPTT_STRUCTUR= E_PROCESSOR) + sizeof (UINT32) * 2; - L1ICacheOffset =3D L1DCacheOffset + sizeof (EFI_ACPI_6_5_PPTT_STRU= CTURE_CACHE); - L2CacheOffset =3D L1ICacheOffset + sizeof (EFI_ACPI_6_5_PPTT_STRU= CTURE_CACHE); - - if (CpuTopo.Threads =3D=3D 1) { - CoreCpuId =3D CpuId; - } else { - CoreCpuId =3D 0; - } - - EFI_ACPI_6_5_PPTT_STRUCTURE_PROCESSOR Core =3D SBSAQEMU_ACPI_PROC= ESSOR_HIERARCHY_NODE_STRUCTURE_INIT ( - CoreFlags, - ClusterOffset, - CoreCpuId, - 2 - ); - CopyMem (New, &Core, sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_PROCESSOR= )); - New +=3D sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_PROCESSOR); - - PrivateResourcePtr =3D (UINT32 *)New; - PrivateResourcePtr[0] =3D L1DCacheOffset; - PrivateResourcePtr[1] =3D L1ICacheOffset; - New +=3D (2 * sizeof (UINT32)); - - // Add L1 D Cache structure - L1DCache.CacheId =3D CacheId++; - CopyMem (New, &L1DCache, sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_CACHE= )); - ((EFI_ACPI_6_5_PPTT_STRUCTURE_CACHE *)New)->NextLevelOfCache =3D L= 2CacheOffset; - New +=3D s= izeof (EFI_ACPI_6_5_PPTT_STRUCTURE_CACHE); - - // Add L1 I Cache structure - L1ICache.CacheId =3D CacheId++; - CopyMem (New, &L1ICache, sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_CACHE= )); - ((EFI_ACPI_6_5_PPTT_STRUCTURE_CACHE *)New)->NextLevelOfCache =3D L= 2CacheOffset; - New +=3D s= izeof (EFI_ACPI_6_5_PPTT_STRUCTURE_CACHE); - - // Add L2 Cache structure - L2Cache.CacheId =3D CacheId++; - CopyMem (New, &L2Cache, sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_CACHE)= ); - New +=3D sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_CACHE); - - if (CpuTopo.Threads =3D=3D 1) { - CpuId++; - } else { - // Add the Thread PPTT structure - for (ThreadIndex =3D 0; ThreadIndex < CpuTopo.Threads; ThreadInd= ex++) { - EFI_ACPI_6_5_PPTT_STRUCTURE_PROCESSOR Thread =3D SBSAQEMU_ACP= I_PROCESSOR_HIERARCHY_NODE_STRUCTURE_INIT ( - ThreadFlags, - CoreOffset, - CpuId, - 0 - ); - CopyMem (New, &Thread, sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_PRO= CESSOR)); - New +=3D sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_PROCESSOR); - CpuId++; - } - - CoreOffset +=3D CpuTopo.Threads * sizeof (EFI_ACPI_6_5_PPTT_STR= UCTURE_PROCESSOR); - } - - CoreOffset +=3D sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_PROCESSOR) + = sizeof (UINT32) * 2; - CoreOffset +=3D 3 * sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_CACHE); - } - - ClusterOffset =3D CoreOffset; + CoresPartSize =3D AddCoresToPpttTable (New, ClusterOffset, CpuTopo)= ; + ClusterOffset +=3D CoresPartSize; + New +=3D CoresPartSize - sizeof (EFI_ACPI_6_5_PPTT_STRUCTU= RE_PROCESSOR); } =20 SocketOffset =3D ClusterOffset; --=20 2.45.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 (#120279): https://edk2.groups.io/g/devel/message/120279 Mute This Topic: https://groups.io/mt/107767187/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-