From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c0c::235; helo=mail-wr0-x235.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x235.google.com (mail-wr0-x235.google.com [IPv6:2a00:1450:400c:c0c::235]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 8356221A1099A for ; Tue, 12 Dec 2017 09:27:55 -0800 (PST) Received: by mail-wr0-x235.google.com with SMTP id v22so21999671wrb.0 for ; Tue, 12 Dec 2017 09:32:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=8LU92iLCoJm1raRd82vM/LhOMgdITdBWOcoS2setEqg=; b=NkKOjMQAlYfzv7aJFFDjb9jhM5WdVCv15xaOk8jyj/xRw5LAAHiBJXRPE1pzDPT9b8 NXA47vcNThBsNJwPceo+lDhf44Au5S7yM2aH+o6k0wjEWBJfGm7znH9psUwlJB8p+BZ/ DrykJIYwUYJ+IAmGQ5yLBguFVVwRUNCml5h+w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=8LU92iLCoJm1raRd82vM/LhOMgdITdBWOcoS2setEqg=; b=a8dHNo/t1E2FFfQaRpPyuntEZaASK+FMOWfZCM5+rGW/WQcIo3gzUeOxEChV8RmIUv yUq1mHHQKpaQ3VVR8SBiEn5kP7e35Uy0riTuPTV1zK/ovCgjBbaMtvD4jBMqRMOSDgZX bhNcANAJ4In+N1kY/VyzmVqDddDBXscJdrMDR8SKaRUbRh+H81/Zlm2Nmijml3z5Z/NC VPzQnaDB74+gQRzURXlXZw4sUI0xcBqN0UIs+NsGrpKT6jEBzBPjYNNUiydggReZdKhd uimCPGFAojtrIlqlQwL2vpcH0rUzOQ9HN+GYwYEKB8mwHWT2wQt9vunifhp3QGKve0HF qBRg== X-Gm-Message-State: AKGB3mImdDC1S2tu8lF4OnGewxs5a4U7ozXF5tEbLg1dcZPQS8M6AZbs MJ9xqJryX6NTIPA2c/pnhiR3XhUD+5g= X-Google-Smtp-Source: ACJfBotXAiOas+ylCS2cYLT8RYlo8wHZ38FhGOyXGZ0hiRDLM54s2EB/q1sAFsuG5b+emb1W+Wq7DQ== X-Received: by 10.223.134.76 with SMTP id 12mr4857086wrw.137.1513099952800; Tue, 12 Dec 2017 09:32:32 -0800 (PST) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id p42sm21113556wrb.28.2017.12.12.09.32.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Dec 2017 09:32:31 -0800 (PST) Date: Tue, 12 Dec 2017 17:32:30 +0000 From: Leif Lindholm To: Ard Biesheuvel Cc: edk2-devel@lists.01.org, daniel.thompson@linaro.org, masami.hiramatsu@linaro.org Message-ID: <20171212173230.bcm2osdd4iw5auyd@bivouac.eciton.net> References: <20171212103807.18836-1-ard.biesheuvel@linaro.org> <20171212103807.18836-6-ard.biesheuvel@linaro.org> MIME-Version: 1.0 In-Reply-To: <20171212103807.18836-6-ard.biesheuvel@linaro.org> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [PATCH edk2-platforms 5/8] Silicon/SynQuacer: disable PCI RC #0 DT node if disabled X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Dec 2017 17:27:56 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Suggested subject tweak: Silicon/SynQuacer: disable PCI RC #0 DT node if disabled -> Silicon/SynQuacer: disable PCI RC DT node if RC disabled. The code below will disable either #0 or #1 node if not enabled by Pcd. On Tue, Dec 12, 2017 at 10:38:04AM +0000, Ard Biesheuvel wrote: > If PCIe RC #0 is not enabled (due to the fact that the slot is not > populated), set its DT node 'status' property to 'disabled' so that > the OS will not attempt to attach to it. > > This means we will need to switch from the default DtPlatformDtbLoaderLib > to a special one for our platform. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ard Biesheuvel > --- > Platform/Socionext/DeveloperBox/DeveloperBox.dsc | 8 +- > Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc | 3 +- > Silicon/Socionext/SynQuacer/Library/SynQuacerDtbLoaderLib/SynQuacerDtbLoaderLib.c | 94 ++++++++++++++++++++ > Silicon/Socionext/SynQuacer/Library/SynQuacerDtbLoaderLib/SynQuacerDtbLoaderLib.inf | 42 +++++++++ > 4 files changed, 141 insertions(+), 6 deletions(-) > > diff --git a/Platform/Socionext/DeveloperBox/DeveloperBox.dsc b/Platform/Socionext/DeveloperBox/DeveloperBox.dsc > index 5ec26f9cdd34..80728fedbc20 100644 > --- a/Platform/Socionext/DeveloperBox/DeveloperBox.dsc > +++ b/Platform/Socionext/DeveloperBox/DeveloperBox.dsc > @@ -160,7 +160,8 @@ [LibraryClasses.common.DXE_CORE] > PerformanceLib|MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf > > [LibraryClasses.common.DXE_DRIVER] > - DtPlatformDtbLoaderLib|EmbeddedPkg/Library/DxeDtPlatformDtbLoaderLibDefault/DxeDtPlatformDtbLoaderLibDefault.inf > + DtPlatformDtbLoaderLib|Silicon/Socionext/SynQuacer/Library/SynQuacerDtbLoaderLib/SynQuacerDtbLoaderLib.inf > + FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf > SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf > PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf > > @@ -611,10 +612,7 @@ [Components.common] > # > # Console preference selection > # > - EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.inf { > - > - FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf > - } > + EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.inf > > # > # DT support > diff --git a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc > index bc8ddd452d4b..c71425664bdc 100644 > --- a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc > +++ b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc > @@ -159,7 +159,8 @@ [LibraryClasses.common.DXE_CORE] > PerformanceLib|MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf > > [LibraryClasses.common.DXE_DRIVER] > - DtPlatformDtbLoaderLib|EmbeddedPkg/Library/DxeDtPlatformDtbLoaderLibDefault/DxeDtPlatformDtbLoaderLibDefault.inf > + DtPlatformDtbLoaderLib|Silicon/Socionext/SynQuacer/Library/SynQuacerDtbLoaderLib/SynQuacerDtbLoaderLib.inf > + FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf > SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf > PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf > > diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerDtbLoaderLib/SynQuacerDtbLoaderLib.c b/Silicon/Socionext/SynQuacer/Library/SynQuacerDtbLoaderLib/SynQuacerDtbLoaderLib.c > new file mode 100644 > index 000000000000..a93a6027e64d > --- /dev/null > +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerDtbLoaderLib/SynQuacerDtbLoaderLib.c > @@ -0,0 +1,94 @@ > +/** @file > +* > +* Copyright (c) 2017, Linaro, Ltd. All rights reserved. > +* > +* This program and the accompanying materials > +* are licensed and made available under the terms and conditions of the BSD License > +* which accompanies this distribution. The full text of the license may be found at > +* http://opensource.org/licenses/bsd-license.php > +* > +* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, > +* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. > +* > +**/ > + > +#include > + > +#include > +#include > +#include > +#include > +#include > + > +#define DTB_PADDING 64 If there isn't a simplish way of determining this value arithmetically, can you add a comment explaining why 64 is sufficient? / Leif > + > +STATIC > +VOID > +DisableDtNode ( > + IN VOID *Dtb, > + IN CONST CHAR8 *NodePath > + ) > +{ > + INT32 Node; > + INT32 Rc; > + > + Node = fdt_path_offset (Dtb, NodePath); > + if (Node < 0) { > + DEBUG ((DEBUG_ERROR, "%a: failed to locate DT path '%a': %a\n", > + __FUNCTION__, NodePath, fdt_strerror (Node))); > + return; > + } > + Rc = fdt_setprop_string (Dtb, Node, "status", "disabled"); > + if (Rc < 0) { > + DEBUG ((DEBUG_ERROR, "%a: failed to set status to 'disabled' on '%a': %a\n", > + __FUNCTION__, NodePath, fdt_strerror (Rc))); > + } > +} > + > +/** > + Return a pool allocated copy of the DTB image that is appropriate for > + booting the current platform via DT. > + > + @param[out] Dtb Pointer to the DTB copy > + @param[out] DtbSize Size of the DTB copy > + > + @retval EFI_SUCCESS Operation completed successfully > + @retval EFI_NOT_FOUND No suitable DTB image could be located > + @retval EFI_OUT_OF_RESOURCES No pool memory available > + > +**/ > +EFI_STATUS > +EFIAPI > +DtPlatformLoadDtb ( > + OUT VOID **Dtb, > + OUT UINTN *DtbSize > + ) > +{ > + EFI_STATUS Status; > + VOID *OrigDtb; > + VOID *CopyDtb; > + UINTN OrigDtbSize; > + > + Status = GetSectionFromAnyFv (&gDtPlatformDefaultDtbFileGuid, > + EFI_SECTION_RAW, 0, &OrigDtb, &OrigDtbSize); > + if (EFI_ERROR (Status)) { > + return EFI_NOT_FOUND; > + } > + > + CopyDtb = AllocateCopyPool (OrigDtbSize + DTB_PADDING, OrigDtb); > + if (CopyDtb == NULL) { > + return EFI_OUT_OF_RESOURCES; > + } > + > + if (!(PcdGet8 (PcdPcieEnableMask) & BIT0)) { > + DisableDtNode (CopyDtb, "/pcie@60000000"); > + } > + if (!(PcdGet8 (PcdPcieEnableMask) & BIT1)) { > + DisableDtNode (CopyDtb, "/pcie@70000000"); > + } > + > + *Dtb = CopyDtb; > + *DtbSize = OrigDtbSize + DTB_PADDING; > + > + return EFI_SUCCESS; > +} > diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerDtbLoaderLib/SynQuacerDtbLoaderLib.inf b/Silicon/Socionext/SynQuacer/Library/SynQuacerDtbLoaderLib/SynQuacerDtbLoaderLib.inf > new file mode 100644 > index 000000000000..e1f564f73078 > --- /dev/null > +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerDtbLoaderLib/SynQuacerDtbLoaderLib.inf > @@ -0,0 +1,42 @@ > +/** @file > +* > +* Copyright (c) 2017, Linaro, Ltd. All rights reserved. > +* > +* This program and the accompanying materials > +* are licensed and made available under the terms and conditions of the BSD License > +* which accompanies this distribution. The full text of the license may be found at > +* http://opensource.org/licenses/bsd-license.php > +* > +* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, > +* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. > +* > +**/ > + > +[Defines] > + INF_VERSION = 0x0001001A > + BASE_NAME = SynQuacerDtbLoaderLib > + FILE_GUID = 59df69c4-8724-4e49-8974-d0691364338c > + MODULE_TYPE = DXE_DRIVER > + VERSION_STRING = 1.0 > + LIBRARY_CLASS = DtPlatformDtbLoaderLib|DXE_DRIVER > + > +[Sources] > + SynQuacerDtbLoaderLib.c > + > +[Packages] > + MdePkg/MdePkg.dec > + EmbeddedPkg/EmbeddedPkg.dec > + Silicon/Socionext/SynQuacer/SynQuacer.dec > + > +[LibraryClasses] > + BaseLib > + DebugLib > + DxeServicesLib > + FdtLib > + MemoryAllocationLib > + > +[Pcd] > + gSynQuacerTokenSpaceGuid.PcdPcieEnableMask > + > +[Guids] > + gDtPlatformDefaultDtbFileGuid > -- > 2.11.0 >