From: "Marcin Juszkiewicz" <marcin.juszkiewicz@linaro.org>
To: devel@edk2.groups.io
Cc: Xiong Yining <xiongyining1480@phytium.com.cn>,
Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>,
Leif Lindholm <quic_llindhol@quicinc.com>,
Ard Biesheuvel <ardb+tianocore@kernel.org>,
Graeme Gregory <graeme@xora.org.uk>,
Chen Baozi <chenbaozi@phytium.com.cn>,
Jonathan Cameron <Jonathan.Cameron@Huawei.com>
Subject: [edk2-devel] [PATCH edk2-platforms v6 1/6] SbsaQemu: get the information of CPU topology via SMC calls
Date: Wed, 07 Aug 2024 13:34:39 +0200 [thread overview]
Message-ID: <20240807-acpi65-v6-1-fc426e4abfe2@linaro.org> (raw)
In-Reply-To: <20240807-acpi65-v6-0-fc426e4abfe2@linaro.org>
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 call.
Number of threads is caluculated using the cpu count and the number of
sockets, clusters and cores.
Signed-off-by: Xiong Yining <xiongyining1480@phytium.com.cn>
Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
---
.../SbsaQemu/Include/IndustryStandard/SbsaQemuSmc.h | 1 +
.../Qemu/SbsaQemu/Include/Library/HardwareInfoLib.h | 26 +++++++++++++++
.../SbsaQemuHardwareInfoLib.c | 35 ++++++++++++++++++++
3 files changed, 62 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)
diff --git a/Silicon/Qemu/SbsaQemu/Include/Library/HardwareInfoLib.h b/Silicon/Qemu/SbsaQemu/Include/Library/HardwareInfoLib.h
index e5076274fa0a..7e0bd962f8a9 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;
+/**
+ 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.
@@ -83,4 +96,17 @@ GetNumaNodeCount (
VOID
);
+/**
+ Get cpu topology (sockets, clusters, cores, threads) from TF-A.
+
+ @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/SbsaQemuHardwareInfoLib.c b/Silicon/Qemu/SbsaQemu/Library/SbsaQemuHardwareInfoLib/SbsaQemuHardwareInfoLib.c
index 05b6fca9e538..b8d1abe2d0bc 100644
--- a/Silicon/Qemu/SbsaQemu/Library/SbsaQemuHardwareInfoLib/SbsaQemuHardwareInfoLib.c
+++ b/Silicon/Qemu/SbsaQemu/Library/SbsaQemuHardwareInfoLib/SbsaQemuHardwareInfoLib.c
@@ -8,6 +8,7 @@
**/
#include <Library/ArmSmcLib.h>
+#include <Library/ArmMonitorLib.h>
#include <Library/DebugLib.h>
#include <Library/PcdLib.h>
#include <Library/ResetSystemLib.h>
@@ -181,3 +182,37 @@ GetNumaNodeCount (
return NumberNumaNodes;
}
+
+/**
+ Get CPU topology.
+**/
+VOID
+GetCpuTopology (
+ OUT CpuTopology *CpuTopo
+ )
+{
+ ARM_MONITOR_ARGS SmcArgs;
+
+ SmcArgs.Arg0 = SIP_SVC_GET_CPU_TOPOLOGY;
+ ArmMonitorCall (&SmcArgs);
+
+ if (SmcArgs.Arg0 != SMC_SIP_CALL_SUCCESS) {
+ DEBUG ((DEBUG_ERROR, "%a: SIP_SVC_GET_CPU_TOPOLOGY call failed. We have no cpu topology information.\n", __FUNCTION__));
+ ResetShutdown ();
+ } else {
+ CpuTopo->Sockets = SmcArgs.Arg1;
+ CpuTopo->Clusters = SmcArgs.Arg2;
+ CpuTopo->Cores = SmcArgs.Arg3;
+ CpuTopo->Threads = SmcArgs.Arg4;
+ }
+
+ DEBUG ((
+ DEBUG_INFO,
+ "%a: CPU Topology: sockets: %d, clusters: %d, cores: %d, threads: %d\n",
+ __FUNCTION__,
+ CpuTopo->Sockets,
+ CpuTopo->Clusters,
+ CpuTopo->Cores,
+ CpuTopo->Threads
+ ));
+}
--
2.45.2
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#120276): https://edk2.groups.io/g/devel/message/120276
Mute This Topic: https://groups.io/mt/107767180/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
next prev parent reply other threads:[~2024-08-07 11:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-07 11:34 [edk2-devel] [PATCH edk2-platforms v6 0/6] SbsaQemu: Align the PPTT tables with QEMU Marcin Juszkiewicz
2024-08-07 11:34 ` Marcin Juszkiewicz [this message]
2024-08-07 11:34 ` [edk2-devel] [PATCH edk2-platforms v6 2/6] SbsaQemu: align " Marcin Juszkiewicz
2024-08-07 11:34 ` [edk2-devel] [PATCH edk2-platforms v6 3/6] SbsaQemu: update PPTT to ACPI 6.5 Marcin Juszkiewicz
2024-08-07 11:34 ` [edk2-devel] [PATCH edk2-platforms v6 4/6] SbsaQemu: provide cache info per core in PPTT Marcin Juszkiewicz
2024-08-07 11:34 ` [edk2-devel] [PATCH edk2-platforms v6 5/6] SbsaQemu: introduce helper in PPTT generation Marcin Juszkiewicz
2024-08-07 11:34 ` [edk2-devel] [PATCH edk2-platforms v6 6/6] SbsaQemu: export proper cache values in PPTT Marcin Juszkiewicz
2024-08-07 16:29 ` [edk2-devel] [PATCH edk2-platforms v6 0/6] SbsaQemu: Align the PPTT tables with QEMU Leif Lindholm
2024-08-07 16:42 ` Marcin Juszkiewicz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240807-acpi65-v6-1-fc426e4abfe2@linaro.org \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox