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 5EB8494150B for ; Fri, 21 Jun 2024 08:29:57 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=NpeD/mQnG+X2NNuA5KNLKjQAS7V9EiWW9Qjh9Z3Ga0Q=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References:From:Organization: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-Language:Content-Type:Content-Transfer-Encoding; s=20240206; t=1718958597; v=1; b=kAOnM9xBWCxkh0ZmxpLY1XkyNTVGBMy1TrvqaNEF6qR8/slRLNXAdvVJQEJMnTdu6NeqJj2M +2jZVoe/UW/BqiWB2fjSsbm+vmRobTbeEWvS7L8pNVcjoOaUgChqvvIcve8SYHKC5Fa3kwpJyED Of5IH1TWPMNhqZ1VplIrRPE8VPd1uveI+LYzCU8TU14R+Do6dDKC1JCw8/evVlDlnqxGt2MCrqk FNjyPpjV3jJdVAiYJxDKQy0pruEbicMfs07sFZ74ztxZsKOAPG0QBGsSUFKbspjsZo1wY/rPhTA GF+bV/PFZKUBi8aKgwhdPW5m8qyMG7jWeAe9pd+u0vWpQ== X-Received: by 127.0.0.2 with SMTP id H4VxYY7687511xlClUmyABBT; Fri, 21 Jun 2024 01:29:55 -0700 X-Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) by mx.groups.io with SMTP id smtpd.web11.68266.1718958595170682634 for ; Fri, 21 Jun 2024 01:29:55 -0700 X-Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-a6f176c5c10so204755966b.2 for ; Fri, 21 Jun 2024 01:29:54 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCWBxElrVjoOTK5WQg8DFBww6Ur1ts+Blfx+PUZBUfMRc6E/eBH6RVG2r311a2pLpTAwJASBDBxykuFKFD3deaIprJsc2w== X-Gm-Message-State: UUqKHI510uLDl6j9SrJSrSeHx7686176AA= X-Google-Smtp-Source: AGHT+IHnHEixjv3DY/s+iInegzzaPBkXqZjS76lcDUOOYs7ePOZoohqDqXp0oZu1qZzzvEkMGDbfUQ== X-Received: by 2002:a17:906:ba84:b0:a6f:55a5:d90b with SMTP id a640c23a62f3a-a6fab6050cbmr553331066b.1.1718958593138; Fri, 21 Jun 2024 01:29:53 -0700 (PDT) X-Received: from [192.168.200.106] (83.11.22.244.ipv4.supernova.orange.pl. [83.11.22.244]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6fd640fac1sm12065266b.213.2024.06.21.01.29.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 21 Jun 2024 01:29:52 -0700 (PDT) Message-ID: <111932b5-a3e3-4fa5-87a3-ac64403e8b08@linaro.org> Date: Fri, 21 Jun 2024 10:29:51 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [edk2-devel] [PATCH 1/2] Platform/SbsaQemu: get the information of CPU topology via SMC calls To: Xiong Yining , devel@edk2.groups.io Cc: quic_llindhol@quicinc.com, ardb+tianocore@kernel.org, graeme@xora.org.uk, chenbaozi@phytium.com.cn References: <20240417112634.120633-1-xiongyining1480@phytium.com.cn> <20240417112634.120633-2-xiongyining1480@phytium.com.cn> From: "Marcin Juszkiewicz" Organization: Linaro In-Reply-To: <20240417112634.120633-2-xiongyining1480@phytium.com.cn> 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: Fri, 21 Jun 2024 01:29:55 -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: Content-Language: pl-PL, en-GB, en-HK Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=kAOnM9xB; 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 W dniu 17.04.2024 o 13:26, Xiong Yining pisze: > 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 cores. > > 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 > --- > .../Include/IndustryStandard/SbsaQemuSmc.h | 1 + > .../Include/Library/HardwareInfoLib.h | 26 +++++++++++++++ > .../SbsaQemuHardwareInfoLib.c | 33 +++++++++++++++++++ > 3 files changed, 60 insertions(+) > > diff --git a/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuSmc.h b/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuSmc.h > index e3092007d27d..9d9780ca70fe 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 46fdad45353c..3e451ee344c7 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. > + > + @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 4c22e7d6ee47..a12dc0244da5 100644 > --- a/Silicon/Qemu/SbsaQemu/Library/SbsaQemuHardwareInfoLib/SbsaQemuHardwareInfoLib.c > +++ b/Silicon/Qemu/SbsaQemu/Library/SbsaQemuHardwareInfoLib/SbsaQemuHardwareInfoLib.c > @@ -179,3 +179,36 @@ 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); Can you use ArmCallSmc() directly? TF-A returns 5 arguments for this SMC call, we use 4 and calculate 5th one. Once we improve SMCCC code in EDK2 the 5th one would be used directly. > + 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); Once SMCCC gets improved this would be read directly from TF-A. > + } > + > + DEBUG(( DEBUG_INFO, "%a: CPU Topology: sockets are %d, clusters are %d, cores are %d, threads are %d\n", Can you replace " are" with ":" ("sockets: %d, clusters: %d")? Those numbers can be singular. > + __FUNCTION__, > + CpuTopo->Sockets, > + CpuTopo->Clusters, > + CpuTopo->Cores, > + CpuTopo->Threads )); > +} > \ No newline at end of file -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#119668): https://edk2.groups.io/g/devel/message/119668 Mute This Topic: https://groups.io/mt/105575034/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-