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 EE953740038 for ; Tue, 2 Jul 2024 16:33:27 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=QO/+BFXGS5k0bO733VdGDIYyNLBRhpdLT6f/2bRWOWA=; 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=1719938007; v=1; b=jpaV9gqNBrWmeEPbvRFZqS+ppX9QCvlAWMkwMlBLK4MgSH4MNorJgZsuvL1Z2tDzrS+gfFE2 sYYJGsUC82wYoqN/p87J0faDZGEFiKca9UB/yOezphTwDRfO4XJQ9srUF7ecSg+DrPnzxzFdmZz rPeYrla1ku79ZouEa7Cv2v3uGo24A8BK4TWrguYbhOoF42wF7aOKMJxInceQDeC3uuc0jnSunZg kxPHHrqW7x5WsopIWSZBNEgi637KbigkMdO5QLQVwaIOcqX/ktjeHwYjkd0a8eo1bo4pH2T1D0I X0cqAyAY2o1PvbHUxf1pmiGJMzVfkjv6YQIHy6woO4BiA== X-Received: by 127.0.0.2 with SMTP id g4t4YY7687511xr02DB3GNPc; Tue, 02 Jul 2024 09:33:26 -0700 X-Received: from muminek.juszkiewicz.com.pl (muminek.juszkiewicz.com.pl [213.251.184.221]) by mx.groups.io with SMTP id smtpd.web10.29038.1719938005508951892 for ; Tue, 02 Jul 2024 09:33:25 -0700 X-Received: from localhost (localhost [127.0.0.1]) by muminek.juszkiewicz.com.pl (Postfix) with ESMTP id B44B32619DD; Tue, 2 Jul 2024 18:33:21 +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 k6y00MfPGe-k; Tue, 2 Jul 2024 18:33:19 +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 422612602ED; Tue, 2 Jul 2024 18:33:17 +0200 (CEST) From: "Marcin Juszkiewicz" Date: Tue, 02 Jul 2024 18:33:02 +0200 Subject: [edk2-devel] [PATCH edk2-platforms v2 1/3] Platform/SbsaQemu: get the information of CPU topology via SMC calls MIME-Version: 1.0 Message-Id: <20240702-acpi65-v2-1-3cb18a892221@linaro.org> References: <20240702-acpi65-v2-0-3cb18a892221@linaro.org> In-Reply-To: <20240702-acpi65-v2-0-3cb18a892221@linaro.org> To: devel@edk2.groups.io Cc: Leif Lindholm , Ard Biesheuvel , Graeme Gregory , Chen Baozi , Xiong Yining , Marcin Juszkiewicz 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, 02 Jul 2024 09:33:25 -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: mJQHRCINshPAsn6CP5bI86Tnx7686176AA= 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=jpaV9gqN; 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 Provide functions to check for CPU topology information: - the number of sockets on sbsa-ref platform. - the number of clusters in one socket. - the number of cores in one cluster. - the number of threads in one core. As SMC calls can return up to 4 return values. the number of sockets, clusters and cores are read from TF-A using platform specific SMC calls. And the number of threads is caluculated using the total number of cpus and the number of sockets, clusters and cores. Signed-off-by: Xiong Yining Signed-off-by: Marcin Juszkiewicz --- .../SbsaQemu/Include/IndustryStandard/SbsaQemuSmc.h | 1 + .../Qemu/SbsaQemu/Include/Library/HardwareInfoLib.h | 26 ++++++++++++++ .../SbsaQemuHardwareInfoLib.c | 36 ++++++++++++++++= ++++ 3 files changed, 63 insertions(+) diff --git a/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuSmc.h b= /Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuSmc.h index af6b120561ad..b57573735ace 100644 --- a/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuSmc.h +++ b/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuSmc.h @@ -16,6 +16,7 @@ #define SIP_SVC_GET_GIC_ITS SMC_SIP_FUNCTION_ID(101) #define SIP_SVC_GET_CPU_COUNT SMC_SIP_FUNCTION_ID(200) #define SIP_SVC_GET_CPU_NODE SMC_SIP_FUNCTION_ID(201) +#define SIP_SVC_GET_CPU_TOPOLOGY SMC_SIP_FUNCTION_ID(202) #define SIP_SVC_GET_MEMORY_NODE_COUNT SMC_SIP_FUNCTION_ID(300) #define SIP_SVC_GET_MEMORY_NODE SMC_SIP_FUNCTION_ID(301) =20 diff --git a/Silicon/Qemu/SbsaQemu/Include/Library/HardwareInfoLib.h b/Sili= con/Qemu/SbsaQemu/Include/Library/HardwareInfoLib.h index e5076274fa0a..cef6f6f58194 100644 --- a/Silicon/Qemu/SbsaQemu/Include/Library/HardwareInfoLib.h +++ b/Silicon/Qemu/SbsaQemu/Include/Library/HardwareInfoLib.h @@ -15,6 +15,19 @@ typedef struct { UINT64 AddressSize; } MemoryInfo; =20 +/** + Sockets: the number of sockets on sbsa-ref platform. + Clusters: the number of clusters in one socket. + Cores: the number of cores in one cluster. + Threads: the number of threads in one core. +**/ +typedef struct { + UINT32 Sockets; + UINT32 Clusters; + UINT32 Cores; + UINT32 Threads; +} CpuTopology; + /** Get CPU count from information passed by Qemu. =20 @@ -83,4 +96,17 @@ GetNumaNodeCount ( VOID ); =20 +/** + Get cpu topology(sockets, clusters, cores, threads) from device tree pas= sed by Qemu. + + @param [out] CpuTopo A pointer to the cpu topology. + + + @retval the information of cpu topology. +**/ +VOID +GetCpuTopology ( + OUT CpuTopology *CpuTopo + ); + #endif /* HARDWARE_INFO_LIB */ diff --git a/Silicon/Qemu/SbsaQemu/Library/SbsaQemuHardwareInfoLib/SbsaQemu= HardwareInfoLib.c b/Silicon/Qemu/SbsaQemu/Library/SbsaQemuHardwareInfoLib/S= bsaQemuHardwareInfoLib.c index 596a3453c70f..a2ea8a523625 100644 --- a/Silicon/Qemu/SbsaQemu/Library/SbsaQemuHardwareInfoLib/SbsaQemuHardwar= eInfoLib.c +++ b/Silicon/Qemu/SbsaQemu/Library/SbsaQemuHardwareInfoLib/SbsaQemuHardwar= eInfoLib.c @@ -181,3 +181,39 @@ GetNumaNodeCount ( =20 return NumberNumaNodes; } + +/** + Get CPU topology. +**/ +VOID +GetCpuTopology ( + OUT CpuTopology *CpuTopo + ) +{ + UINTN SmcResult; + UINTN Arg0; + UINTN Arg1; + UINTN Arg2; + UINT32 NumCores =3D GetCpuCount (); + + SmcResult =3D ArmCallSmc0 (SIP_SVC_GET_CPU_TOPOLOGY, &Arg0, &Arg1, &Arg2= ); + if (SmcResult !=3D SMC_SIP_CALL_SUCCESS) { + DEBUG ((DEBUG_ERROR, "%a: SIP_SVC_GET_CPU_TOPOLOGY call failed. We hav= e no cpu topology information.\n", __FUNCTION__)); + ResetShutdown (); + } else { + CpuTopo->Sockets =3D Arg0; + CpuTopo->Clusters =3D Arg1; + CpuTopo->Cores =3D Arg2; + CpuTopo->Threads =3D NumCores / (CpuTopo->Sockets * CpuTopo->Clusters= * CpuTopo->Cores); + } + + DEBUG (( + DEBUG_INFO, + "%a: CPU Topology: sockets: %d, clusters: %d, cores: %d, threads: %d\n= ", + __FUNCTION__, + CpuTopo->Sockets, + CpuTopo->Clusters, + CpuTopo->Cores, + CpuTopo->Threads + )); +} --=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 (#119763): https://edk2.groups.io/g/devel/message/119763 Mute This Topic: https://groups.io/mt/107003193/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-