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 D2A0FD80127 for ; Tue, 9 Jul 2024 10:47:45 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=DKtDidP0nv8SaMgApAiJiPDAa7q5CEBC61WfRfWpLoc=; 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=1720522065; v=1; b=kbs5mFi/VPl+pWzwgwbldGHK8slhvhI7LUqoxy9tW2ph542FiOOJpKuaX7gQoeUcpRkyE6Od JdxKz/1sUWDrR2lJ4d6IaDik4leIj2NCJ3cNR/D6qGaXkxiTXgLe1CrGiAyePSaY3mOcOxvw1TO Irm1rVr+nUisiScGS1oChy/zR3/7hav8rY8V2B7nhndBGfvwB0uHoZndFFA5YiYEXPnxVr1rase 3U3pBIAgqPtW0Q1H06hYvSLCCqSikvc+CpannuG6aNNueZ5H27Dw1ZdoYSuHRSG5je8lC2mwnFl an8tpH6srJl8ejy+PADIrxVILauDunQM/An62QpTj2f/w== X-Received: by 127.0.0.2 with SMTP id lXsVYY7687511xyCLZKz4bIE; Tue, 09 Jul 2024 03:47:44 -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.10031.1720522063596050633 for ; Tue, 09 Jul 2024 03:47:44 -0700 X-Received: from localhost (localhost [127.0.0.1]) by muminek.juszkiewicz.com.pl (Postfix) with ESMTP id 853FD260ACD; Tue, 9 Jul 2024 12:47:41 +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 86bW-c7PsZXc; Tue, 9 Jul 2024 12:47:39 +0200 (CEST) X-Received: from applejack.lan (83.8.74.165.ipv4.supernova.orange.pl [83.8.74.165]) by muminek.juszkiewicz.com.pl (Postfix) with ESMTPSA id 14F5F260836; Tue, 9 Jul 2024 12:47:39 +0200 (CEST) From: "Marcin Juszkiewicz" Date: Tue, 09 Jul 2024 12:47:10 +0200 Subject: [edk2-devel] [PATCH edk2-platforms v3 5/5] SbsaQemu: introduce helper in PPTT generation MIME-Version: 1.0 Message-Id: <20240709-acpi65-v3-5-ee93ba536fcf@linaro.org> References: <20240709-acpi65-v3-0-ee93ba536fcf@linaro.org> In-Reply-To: <20240709-acpi65-v3-0-ee93ba536fcf@linaro.org> To: devel@edk2.groups.io Cc: Xiong Yining , Marcin Juszkiewicz , Leif Lindholm , Ard Biesheuvel , Graeme Gregory , Chen Baozi 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: Tue, 09 Jul 2024 03:47:44 -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: REPqyG3kNEylhNyNQ3hpSCNKx7686176AA= 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="kbs5mFi/"; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=linaro.org (policy=none) 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 | 237 +++++++++++-----= ---- 1 file changed, 133 insertions(+), 104 deletions(-) diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.= c b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c index a7a9664abdcb..a4b2ee2fdcb0 100644 --- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c +++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c @@ -29,6 +29,9 @@ =20 static UINTN GicItsBase; =20 +static UINTN CpuId; +static UINTN CacheId; + #pragma pack () =20 /* @@ -491,6 +494,126 @@ AddSsdtTable ( return Status; } =20 +UINT32 +AddCoresToPpttTable ( + UINT8 *New, + UINT32 ClusterIndex, + CpuTopology CpuTopo + ) +{ + UINT32 L1DCacheIndex; + UINT32 L1ICacheIndex; + UINT32 L2CacheIndex; + UINT32 CoreIndex; + UINT32 Index; + UINT32 CoreCpuId; + UINT32 CoreNum; + UINT32 ThreadNum; + 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; + + CoreIndex =3D ClusterIndex + sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_PROCESS= OR); + Index =3D CoreIndex; + + for (CoreNum =3D 0; CoreNum < CpuTopo.Cores; CoreNum++) { + if (CpuTopo.Threads =3D=3D 1) { + CoreCpuId =3D CpuId; + } else { + CoreCpuId =3D 0; + } + + // space for Core + PrivateResourcePtr + Index +=3D sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_PROCESSOR); + Index +=3D sizeof (UINT32) * 2; + + L1DCacheIndex =3D Index; + L1ICacheIndex =3D L1DCacheIndex + sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_= CACHE); + L2CacheIndex =3D L1ICacheIndex + sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_= CACHE); + + EFI_ACPI_6_5_PPTT_STRUCTURE_PROCESSOR Core =3D SBSAQEMU_ACPI_PROCESSO= R_HIERARCHY_NODE_STRUCTURE_INIT ( + CoreFlags, + ClusterIndex, + 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 L1DCacheIndex; + PrivateResourcePtr[1] =3D L1ICacheIndex; + 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 L2Cac= heIndex; + New +=3D sizeo= f (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 L2Cac= heIndex; + New +=3D sizeo= f (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); + + Index +=3D sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_CACHE) * 3; + + if (CpuTopo.Threads =3D=3D 1) { + CpuId++; + } else { + // Add the Thread PPTT structure + for (ThreadNum =3D 0; ThreadNum < CpuTopo.Threads; ThreadNum++) { + EFI_ACPI_6_5_PPTT_STRUCTURE_PROCESSOR Thread =3D SBSAQEMU_ACPI_PR= OCESSOR_HIERARCHY_NODE_STRUCTURE_INIT ( + ThreadFlags, + CoreIndex, + CpuId, + 0 + ); + CopyMem (New, &Thread, sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_PROCESS= OR)); + New +=3D sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_PROCESSOR); + CpuId++; + } + + Index +=3D CpuTopo.Threads * sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_PR= OCESSOR); + } + + CoreIndex =3D Index; + } + + return CoreIndex - ClusterIndex - sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_PR= OCESSOR); +} + /* * A function that adds the PPTT ACPI table. */ @@ -502,18 +625,17 @@ AddPpttTable ( EFI_STATUS Status; UINTN TableHandle; UINT32 TableSize; + UINT32 CoresPartSize; + UINT32 SocketNum; + UINT32 ClusterNum; + UINT32 SocketIndex; + UINT32 ClusterIndex; EFI_PHYSICAL_ADDRESS PageAddress; UINT8 *New; - UINT32 CpuId; CpuTopology CpuTopo; - UINT32 CacheId; =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, @@ -530,28 +652,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= , @@ -590,11 +690,9 @@ AddPpttTable ( ((EFI_ACPI_DESCRIPTION_HEADER *)New)->Length =3D TableSize; New +=3D sizeof (EFI_ACPI_DESCRI= PTION_HEADER); =20 - UINT32 SocketNum, ClusterNum, CoreNum, ThreadNum; - UINT32 SocketIndex, ClusterIndex, CoreIndex, L1DCacheIndex, L1ICacheInd= ex, L2CacheIndex; + CpuId =3D 0; + CacheId =3D 1; // 0 is not a valid Cache ID. =20 - CpuId =3D 0; - CacheId =3D 1; // 0 is not a valid Cache ID. SocketIndex =3D sizeof (EFI_ACPI_DESCRIPTION_HEADER); for (SocketNum =3D 0; SocketNum < CpuTopo.Sockets; SocketNum++) { // Add the Socket PPTT structure @@ -609,8 +707,6 @@ AddPpttTable ( =20 ClusterIndex =3D SocketIndex + sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_PRO= CESSOR); for (ClusterNum =3D 0; ClusterNum < CpuTopo.Clusters; ClusterNum++) { - CoreIndex =3D ClusterIndex + sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_PRO= CESSOR); - // Add the Cluster PPTT structure EFI_ACPI_6_5_PPTT_STRUCTURE_PROCESSOR Cluster =3D SBSAQEMU_ACPI_PRO= CESSOR_HIERARCHY_NODE_STRUCTURE_INIT ( ClusterFlags, @@ -621,76 +717,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 - for (CoreNum =3D 0; CoreNum < CpuTopo.Cores; CoreNum++) { - UINT32 *PrivateResourcePtr; - UINT32 CoreCpuId; - - // two UINT32s for PrivateResourcePtr data - L1DCacheIndex =3D CoreIndex + sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_= PROCESSOR) + sizeof (UINT32) * 2; - L1ICacheIndex =3D L1DCacheIndex + sizeof (EFI_ACPI_6_5_PPTT_STRUCT= URE_CACHE); - L2CacheIndex =3D L1ICacheIndex + sizeof (EFI_ACPI_6_5_PPTT_STRUCT= URE_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, - ClusterIndex, - 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 L1DCacheIndex; - PrivateResourcePtr[1] =3D L1ICacheIndex; - 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= 2CacheIndex; - 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= 2CacheIndex; - 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 (ThreadNum =3D 0; ThreadNum < CpuTopo.Threads; ThreadNum++) = { - EFI_ACPI_6_5_PPTT_STRUCTURE_PROCESSOR Thread =3D SBSAQEMU_ACP= I_PROCESSOR_HIERARCHY_NODE_STRUCTURE_INIT ( - ThreadFlags, - CoreIndex, - 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++; - } - - CoreIndex +=3D CpuTopo.Threads * sizeof (EFI_ACPI_6_5_PPTT_STRU= CTURE_PROCESSOR); - } - - CoreIndex +=3D sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_PROCESSOR) + si= zeof (UINT32) * 2; - CoreIndex +=3D sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_CACHE) * 3; - } - - ClusterIndex =3D CoreIndex; + CoresPartSize =3D AddCoresToPpttTable (New, ClusterIndex, CpuTopo); + ClusterIndex +=3D CoresPartSize; + New +=3D CoresPartSize; } =20 SocketIndex =3D ClusterIndex; --=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 (#119835): https://edk2.groups.io/g/devel/message/119835 Mute This Topic: https://groups.io/mt/107120147/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-