public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Sami Mujawar" <sami.mujawar@arm.com>
To: Sahil Kaushal <Sahil.Kaushal@arm.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>,
	Leif Lindholm <leif@nuviainc.com>,
	Sahil Kaushal <Sahil.Kaushal@arm.com>, nd <nd@arm.com>
Subject: Re: [edk2-devel] [edk2-platforms][PATCH V4 2/4] Platform/ARM/N1Sdp: Add N1SdpNtFwConfigPei PEI module
Date: Fri, 1 Mar 2024 14:23:45 +0000	[thread overview]
Message-ID: <646E0666-56B6-4962-96BA-F3F5D85A4BCD@arm.com> (raw)
In-Reply-To: <20240104131616.474492-3-sahil@arm.com>

Hi Sahil,

There are multiple items that need fixing in this patch. Also, the changes in Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec from Patch 3/4 must be part of this patch.
To save my time from reviewing the whole thing again, I am going to fix that before merging.

However, do find my response inline marked [SAMI] and please do go through my feedback so that you know what to look for next time.

Regards,

Sami Mujawar

On 04/01/2024, 13:16, "sahil" <sahil@arm.com <mailto:sahil@arm.com>> wrote:


This patch adds a PEI to parse NT_FW_CONFIG and pass it to
other PEI modules(as PPI) and DXE modules(as HOB).


Signed-off-by: sahil <sahil@arm.com <mailto:sahil@arm.com>>
---
Platform/ARM/N1Sdp/Drivers/N1SdpNtFwConfigPei/NtFwConfigPei.inf | 41 ++++++
Platform/ARM/N1Sdp/Drivers/N1SdpNtFwConfigPei/NtFwConfigPei.c | 132 ++++++++++++++++++++


[SAMI] I think these files should be moved to Silicon/ARM/NeoverseN1Soc/Library/N1SdpNtFwConfigPei.
I will do that before merging.

2 files changed, 173 insertions(+)


diff --git a/Platform/ARM/N1Sdp/Drivers/N1SdpNtFwConfigPei/NtFwConfigPei.inf b/Platform/ARM/N1Sdp/Drivers/N1SdpNtFwConfigPei/NtFwConfigPei.inf
new file mode 100644
index 000000000000..363351b5a1df
--- /dev/null
+++ b/Platform/ARM/N1Sdp/Drivers/N1SdpNtFwConfigPei/NtFwConfigPei.inf
@@ -0,0 +1,41 @@
+## @file


+# This PEI module parse the NtFwConfig for N1Sdp platform and produce


+# the PPI and HOB.


+#


+# Copyright (c) 2024, ARM Limited. All rights reserved.<BR>


+#


+# SPDX-License-Identifier: BSD-2-Clause-Patent


+#


+##


+


+[Defines]


+ INF_VERSION = 0x0001001B


+ BASE_NAME = N1SdpNtFwConfigPei


+ FILE_GUID = CE76D56C-D3A5-4763-9138-DF09E1D1B614


+ MODULE_TYPE = PEIM


+ VERSION_STRING = 1.0


+ ENTRY_POINT = NtFwConfigPeEntryPoint


+


+[Sources]


+ NtFwConfigPei.c


+


+[Packages]


+ EmbeddedPkg/EmbeddedPkg.dec


+ MdePkg/MdePkg.dec


+ Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec


+


+[LibraryClasses]


+ DebugLib


+ FdtLib


+ HobLib


+ PeimEntryPoint


+


+[Ppis]


+ gArmNeoverseN1SocPlatformInfoDescriptorPpiGuid


+ gArmNeoverseN1SocParameterPpiGuid


+


+[Guids]


+ gArmNeoverseN1SocPlatformInfoDescriptorGuid


+


+[Depex]


+ gArmNeoverseN1SocParameterPpiGuid


diff --git a/Platform/ARM/N1Sdp/Drivers/N1SdpNtFwConfigPei/NtFwConfigPei.c b/Platform/ARM/N1Sdp/Drivers/N1SdpNtFwConfigPei/NtFwConfigPei.c
new file mode 100644
index 000000000000..330377d21a79
--- /dev/null
+++ b/Platform/ARM/N1Sdp/Drivers/N1SdpNtFwConfigPei/NtFwConfigPei.c
@@ -0,0 +1,132 @@
+/** @file


+


+ Copyright (c) 2024, ARM Limited. All rights reserved.<BR>


+ SPDX-License-Identifier: BSD-2-Clause-Patent


+


+**/


+


+#include <Library/DebugLib.h>


+#include <Library/HobLib.h>


+#include <Library/PeiServicesLib.h>


+


+#include <NeoverseN1Soc.h>


+#include <libfdt.h>


+


+STATIC EFI_PEI_PPI_DESCRIPTOR mPpi;


+


+/**


+ The entrypoint of the module, parse NtFwConfig and produce the PPI and HOB.


+


+ @param[in] FileHandle Handle of the file being invoked.


+ @param[in] PeiServices Describes the list of possible PEI Services.


+


+ @retval EFI_SUCCESS Either no NT_FW_CONFIG was given by EL3 firmware


+ OR the N1Sdp FDT HOB was successfully created.
[SAMI] Would it not be enough to say Success? The documentation for the function already mentions what is expected.


+ @retval EFI_NOT_FOUND Error processing the DTB


+ @retval EFI_OUT_OF_RESOURCES Could not allocate memory for the HOB


+ @retval * Other errors are possible.


+**/


+EFI_STATUS


+EFIAPI


+NtFwConfigPeEntryPoint (


+ IN EFI_PEI_FILE_HANDLE FileHandle,


+ IN CONST EFI_PEI_SERVICES **PeiServices


+ )


+{


+ CONST NEOVERSEN1SOC_EL3_FW_HANDOFF_PARAM_PPI *ParamPpi;


+ CONST UINT32 *Property;


+ INT32 Offset;


+ NEOVERSEN1SOC_PLAT_INFO *PlatInfo;


+ INT32 Status;
[SAMI] This should be EFI_STATUS.


+


+ PlatInfo = BuildGuidHob (


+ &gArmNeoverseN1SocPlatformInfoDescriptorGuid,


+ sizeof (*PlatInfo)


+ );


+


+ if (PlatInfo == NULL) {


+ DEBUG ((


+ DEBUG_ERROR,


+ "[%a]: failed to allocate platform info HOB\n",


+ gEfiCallerBaseName


+ ));


+ return EFI_OUT_OF_RESOURCES;


+ }


+


+ Status = PeiServicesLocatePpi (


+ &gArmNeoverseN1SocParameterPpiGuid,


+ 0,


+ NULL,


+ (VOID **)&ParamPpi


+ );

[SAMI] I think Locate PPI should be done fist, that way if it fails we do not allocate the HOB.
+


+ if (EFI_ERROR (Status)) {


+ DEBUG ((


+ DEBUG_ERROR,


+ "[%a]: failed to locate gArmNeoverseN1SocParameterPpiGuid - %r\n",


+ gEfiCallerBaseName,


+ Status


+ ));


+ return Status;


+ }


+


+ if (fdt_check_header (ParamPpi->NtFwConfig) != 0) {
[SAMI] There should be a check to see if ParamPpi is NULL. Also ParamPpi is dereferenced too many times in this function. It is advisable to have a local variable instead.


+ DEBUG ((DEBUG_ERROR, "Invalid DTB file %p passed\n", ParamPpi->NtFwConfig));


+ return EFI_NOT_FOUND;


+ }


+


+ Offset = fdt_subnode_offset (ParamPpi->NtFwConfig, 0, "platform-info");


+ if (Offset == -FDT_ERR_NOTFOUND) {


+ DEBUG ((DEBUG_ERROR, "Invalid DTB : platform-info node not found\n"));


+ return EFI_NOT_FOUND;


+ }


+


+ Property = fdt_getprop (ParamPpi->NtFwConfig, Offset, "local-ddr-size", NULL);


+ if (Property == NULL) {


+ DEBUG ((DEBUG_ERROR, "local-ddr-size property not found\n"));


+ return EFI_NOT_FOUND;


+ }


+


+ PlatInfo->LocalDdrSize = fdt32_to_cpu (*Property);


+


+ Property = fdt_getprop (ParamPpi->NtFwConfig, Offset, "remote-ddr-size", NULL);


+ if (Property == NULL) {


+ DEBUG ((DEBUG_ERROR, "remote-ddr-size property not found\n"));


+ return EFI_NOT_FOUND;


+ }


+


+ PlatInfo->RemoteDdrSize = fdt32_to_cpu (*Property);


+


+ Property = fdt_getprop (ParamPpi->NtFwConfig, Offset, "secondary-chip-count", NULL);


+ if (Property == NULL) {


+ DEBUG ((DEBUG_ERROR, "secondary-chip-count property not found\n"));


+ return EFI_NOT_FOUND;


+ }


+


+ PlatInfo->SecondaryChipCount = fdt32_to_cpu (*Property);


+


+ Property = fdt_getprop (ParamPpi->NtFwConfig, Offset, "multichip-mode", NULL);


+ if (Property == NULL) {


+ DEBUG ((DEBUG_ERROR, "multichip-mode property not found\n"));


+ return EFI_NOT_FOUND;


+ }


+


+ PlatInfo->MultichipMode = fdt32_to_cpu (*Property);


+


+ mPpi.Flags = EFI_PEI_PPI_DESCRIPTOR_PPI


+ | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;


+ mPpi.Guid = &gArmNeoverseN1SocPlatformInfoDescriptorPpiGuid;


+ mPpi.Ppi = PlatInfo;


+


+ Status = PeiServicesInstallPpi (&mPpi);


+ if (EFI_ERROR (Status)) {


+ DEBUG ((


+ DEBUG_ERROR,


+ "[%a]: failed to install PEI service - %r\n",


+ gEfiCallerBaseName,


+ Status


+ ));


+ }


+


+ return Status;


+}


-- 
2.25.1







-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116257): https://edk2.groups.io/g/devel/message/116257
Mute This Topic: https://groups.io/mt/103521644/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



  parent reply	other threads:[~2024-03-01 14:24 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-04 13:16 [edk2-devel] [edk2-platforms][PATCH V4 0/4] Add support to parse NT_FW_CONFIG sahil
2024-01-04 13:16 ` [edk2-devel] [edk2-platforms][PATCH V4 1/4] Silicon/ARM/NeoverseN1Soc: Extract NT_FW_CONFIG address passed by TF-A sahil
2024-01-23  8:58   ` sahil
2024-03-01 14:02   ` Sami Mujawar
2024-01-04 13:16 ` [edk2-devel] [edk2-platforms][PATCH V4 2/4] Platform/ARM/N1Sdp: Add N1SdpNtFwConfigPei PEI module sahil
2024-01-23  9:11   ` sahil
2024-03-01 14:23   ` Sami Mujawar [this message]
2024-01-04 13:16 ` [edk2-devel] [edk2-platforms][PATCH V4 3/4] Platform/ARM/N1Sdp: Enable N1SdpNtFwConfigPei PEI module for N1Sdp sahil
2024-01-23  9:14   ` sahil
2024-03-01 14:19   ` Sami Mujawar
2024-01-04 13:16 ` [edk2-devel] [edk2-platforms][PATCH V4 4/4] Silicon/ARM/NeoverseN1Soc: Consume N1SdpNtFwConfigPei supplied data sahil
2024-01-23  9:14   ` sahil
2024-03-01 14:22   ` Sami Mujawar
2024-01-19 11:24 ` [edk2-devel] [edk2-platforms][PATCH V4 0/4] Add support to parse NT_FW_CONFIG Sami Mujawar
2024-03-04 14:38 ` Sami Mujawar
2024-03-04 14:40   ` Sami Mujawar

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=646E0666-56B6-4962-96BA-F3F5D85A4BCD@arm.com \
    --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