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 46916D8026F for ; Tue, 9 Jul 2024 12:41:07 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=PgmIcsGhyVw4jm6Jtt5tegLpaHgOpvbrMyiehtwyfFU=; c=relaxed/simple; d=groups.io; h=Date:From:To:CC:Subject:Message-ID:References:MIME-Version:In-Reply-To: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-Disposition; s=20240206; t=1720528866; v=1; b=i5/HeG2vRPCVn2+ujby2f9F6dHva5hr5O6fO0nJ4fpPA5o6TL6NBTiFsjGml78gn9wriPtmk WKpNqjyHfopAwORcXsYR8s4riIyUUrMre995WqRFjhmIdaPkKsIVCKiBviGfLvr82y81E7RAeNr 5Q2GptLOjqUFWKbjyEVw0ABNDHwt4P3Y7hiIIi+uLdrvsWNBA+ynTXsScBPu5e2CCQ6DP4avrkp HcJ7c4DbMGT17OI/kAnfZT+VB9RUxybcLRtwkGtFc+u4SeAvk4sbf4LrsdFdP79qSXqNVFqECk6 MEjYLr6mRoFhE5gVWskeVQYOqVtUg4rRi58+ohE3lovJw== X-Received: by 127.0.0.2 with SMTP id E0CkYY7687511xqcr9VJ0OU7; Tue, 09 Jul 2024 05:41:05 -0700 X-Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by mx.groups.io with SMTP id smtpd.web10.12031.1720528864736954963 for ; Tue, 09 Jul 2024 05:41:04 -0700 X-Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46931PZ6012640; Tue, 9 Jul 2024 12:41:04 GMT X-Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 406y3he61d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 Jul 2024 12:41:04 +0000 (GMT) X-Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA04.qualcomm.com (8.17.1.19/8.17.1.19) with ESMTPS id 469Cf3ZG028042 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 9 Jul 2024 12:41:03 GMT X-Received: from qc-i7.hemma.eciton.net (10.80.80.8) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Tue, 9 Jul 2024 05:40:59 -0700 Date: Tue, 9 Jul 2024 13:40:55 +0100 From: "Leif Lindholm" To: Marcin Juszkiewicz CC: , Xiong Yining , Ard Biesheuvel , Graeme Gregory , Chen Baozi Subject: Re: [edk2-devel] [PATCH edk2-platforms v3 1/5] SbsaQemu: get the information of CPU topology via SMC calls Message-ID: References: <20240709-acpi65-v3-0-ee93ba536fcf@linaro.org> <20240709-acpi65-v3-1-ee93ba536fcf@linaro.org> MIME-Version: 1.0 In-Reply-To: <20240709-acpi65-v3-1-ee93ba536fcf@linaro.org> X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-ORIG-GUID: 6Mqxt_Y5-yLni-6SMM5RXVZrtu2Qln7_ X-Proofpoint-GUID: 6Mqxt_Y5-yLni-6SMM5RXVZrtu2Qln7_ 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 05:41:04 -0700 Resent-From: quic_llindhol@quicinc.com Reply-To: devel@edk2.groups.io,quic_llindhol@quicinc.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: QDAPE4AVmOwjkkfDk3LDHWM6x7686176AA= Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b="i5/HeG2v"; 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=quicinc.com (policy=none) On Tue, Jul 09, 2024 at 12:47:06 +0200, Marcin Juszkiewicz wrote: > 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 > 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) > > diff --git a/Silicon/Qemu/SbsaQemu/Include/Library/HardwareInfoLib.h b/Silicon/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; > > +/** > + 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 device tree passed by Qemu. We don't need to talk about qemu internals that will change in the future. "Get cpu topology ... from Qemu.) Other than that: Reviewed-by: Leif Lindholm / Leif > + > + @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 596a3453c70f..b17a2ae99b4e 100644 > --- a/Silicon/Qemu/SbsaQemu/Library/SbsaQemuHardwareInfoLib/SbsaQemuHardwareInfoLib.c > +++ b/Silicon/Qemu/SbsaQemu/Library/SbsaQemuHardwareInfoLib/SbsaQemuHardwareInfoLib.c > @@ -181,3 +181,39 @@ GetNumaNodeCount ( > > return NumberNumaNodes; > } > + > +/** > + Get CPU topology. > +**/ > +VOID > +GetCpuTopology ( > + OUT CpuTopology *CpuTopo > + ) > +{ > + UINTN SmcResult; > + UINTN Arg0; > + UINTN Arg1; > + UINTN Arg2; > + UINT32 NumCores = GetCpuCount (); > + > + SmcResult = ArmCallSmc0 (SIP_SVC_GET_CPU_TOPOLOGY, &Arg0, &Arg1, &Arg2); > + if (SmcResult != 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 = Arg0; > + CpuTopo->Clusters = Arg1; > + CpuTopo->Cores = Arg2; > + CpuTopo->Threads = NumCores / (CpuTopo->Sockets * CpuTopo->Clusters * CpuTopo->Cores); > + } > + > + DEBUG (( > + DEBUG_INFO, > + "%a: CPU Topology: sockets are %d, clusters are %d, cores are %d, threads are %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 (#119836): https://edk2.groups.io/g/devel/message/119836 Mute This Topic: https://groups.io/mt/107120143/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-