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 BC0727803CD for ; Tue, 9 Jul 2024 12:42:14 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=gG3InNxTb6IzzHkitWYYkn3/Nb+b7J5jcJk/4r06n3I=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:User-Agent:Subject:From:To:CC:Reply-To:References:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20240206; t=1720528934; v=1; b=bqzoEgIaQrzHXFagmFDP6osxuAmXaxDwIYcdrst3sLZLLP4caJurSBN9suC16/RZqv5UqtfK OfXH8N8nyikyMxQkOitqNesc3aT9zap2QdFKzCzP9uYAhriK3yc6JcCO1Fpo3fhuN2Vk63WX1b+ kICydEXdsHhggMFk+ZMWp+IyqYaao21tfYO0HGXoa4nITLTxo92MECuj3HmxEGYNxfBsAN1r8ne 4ypCkBc+ZfYMaCcxmtOjxyP6hEFW+c/tOnZTBZTpWZ1lN8RZRAEt9I2h2GwZsH3HrUnf8H3PVuf JBfRWQJ8Nk2qlwl4L3awkdvg1/D5yxFtZdBneYRIeEU9w== X-Received: by 127.0.0.2 with SMTP id Fz10YY7687511xcVhKPQRJj2; Tue, 09 Jul 2024 05:42:13 -0700 X-Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by mx.groups.io with SMTP id smtpd.web10.12057.1720528932585043477 for ; Tue, 09 Jul 2024 05:42:12 -0700 X-Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 469Bb95T001911; Tue, 9 Jul 2024 12:42:11 GMT X-Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 406wgwpd5u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 Jul 2024 12:42:11 +0000 (GMT) X-Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA01.qualcomm.com (8.17.1.19/8.17.1.19) with ESMTPS id 469CgARe003151 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 9 Jul 2024 12:42:10 GMT X-Received: from [10.111.132.33] (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:42:08 -0700 Message-ID: Date: Tue, 9 Jul 2024 13:42:06 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [edk2-devel] [PATCH edk2-platforms v3 1/5] SbsaQemu: get the information of CPU topology via SMC calls From: "Leif Lindholm" To: Marcin Juszkiewicz CC: , Xiong Yining , Ard Biesheuvel , Graeme Gregory , Chen Baozi Reply-To: devel@edk2.groups.io,quic_llindhol@quicinc.com References: <20240709-acpi65-v3-0-ee93ba536fcf@linaro.org> <20240709-acpi65-v3-1-ee93ba536fcf@linaro.org> <17E08BE30DD079C5.26166@groups.io> In-Reply-To: <17E08BE30DD079C5.26166@groups.io> 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-GUID: O_qgo7fbE278NYlUTmzPGhs26Znpe21y X-Proofpoint-ORIG-GUID: O_qgo7fbE278NYlUTmzPGhs26Znpe21y 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:42:12 -0700 Resent-From: quic_llindhol@quicinc.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: JTvBE4iEOELgBANWFeqzJUCkx7686176AA= Content-Language: en-GB Content-Type: text/plain; charset="UTF-8"; format=flowed 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=bqzoEgIa; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=quicinc.com (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 On 2024-07-09 13:40, Leif Lindholm wrote: > 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) >> =20 >> diff --git a/Silicon/Qemu/SbsaQemu/Include/Library/HardwareInfoLib.h b/S= ilicon/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 = passed by Qemu. >=20 > We don't need to talk about qemu internals that will change in the > future. "Get cpu topology ... from Qemu.) No, hang on, that's rubbish. "from TF-A". / Leif >=20 > Other than that: > Reviewed-by: Leif Lindholm >=20 > / > Leif >=20 >> + >> + @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/SbsaQ= emuHardwareInfoLib.c b/Silicon/Qemu/SbsaQemu/Library/SbsaQemuHardwareInfoLi= b/SbsaQemuHardwareInfoLib.c >> index 596a3453c70f..b17a2ae99b4e 100644 >> --- a/Silicon/Qemu/SbsaQemu/Library/SbsaQemuHardwareInfoLib/SbsaQemuHard= wareInfoLib.c >> +++ b/Silicon/Qemu/SbsaQemu/Library/SbsaQemuHardwareInfoLib/SbsaQemuHard= wareInfoLib.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, &A= rg2); >> + if (SmcResult !=3D 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 =3D Arg0; >> + CpuTopo->Clusters =3D Arg1; >> + CpuTopo->Cores =3D Arg2; >> + CpuTopo->Threads =3D NumCores / (CpuTopo->Sockets * CpuTopo->Clust= ers * CpuTopo->Cores); >> + } >> + >> + DEBUG (( >> + DEBUG_INFO, >> + "%a: CPU Topology: sockets are %d, clusters are %d, cores are %d, t= hreads are %d\n", >> + __FUNCTION__, >> + CpuTopo->Sockets, >> + CpuTopo->Clusters, >> + CpuTopo->Cores, >> + CpuTopo->Threads >> + )); >> +} >> >> --=20 >> 2.45.2 >> >=20 >=20 >=20 >=20 >=20 -=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 (#119837): https://edk2.groups.io/g/devel/message/119837 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] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-