Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AF055ECAAD1 for ; Wed, 31 Aug 2022 11:20:12 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 94336849A1; Wed, 31 Aug 2022 13:20:10 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="HhjTQpiW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BEB158487B; Wed, 31 Aug 2022 05:08:39 +0200 (CEST) Received: from mail-ot1-x331.google.com (mail-ot1-x331.google.com [IPv6:2607:f8b0:4864:20::331]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id B3A4F849BA for ; Wed, 31 Aug 2022 05:08:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-ot1-x331.google.com with SMTP id z22-20020a056830129600b0063711f456ceso9434469otp.7 for ; Tue, 30 Aug 2022 20:08:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=z6nG37oFKvxV9cpLQLDSvXr6FRbfimSfL/irKiSiH5U=; b=HhjTQpiWzf6JhzxO0Oj0WnqYoPRL+cCQRquOtSgnl05wbMI/652gvELD4QVKPgM4gt rDq6IlBfgf4SLVniHnzbSnY51E560OfPyAoPUHbNFRW5iX+Zq7IMceCragHXTH1algQv EgG6vFuQSTUoiHL6VuCNklTmnXQb0b7W2YfVc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=z6nG37oFKvxV9cpLQLDSvXr6FRbfimSfL/irKiSiH5U=; b=U1w5PjCDjVPNZ1+CXyVrNBSwWhSm01Cuu4A6QmIbq4vXh2Q8IZKaZRgDP8pd5zeXj6 U818N0TrZ2ZACyUEpNAHYe70uhcjewFQ7o7Boz9WshqZqmunQ5jBfk/LPdTspjJieCWp 1ZTImZ188iDU/qD2YwaEsdG09ayirDTdM8ZipcVdLWGq2in7HwLBz27+TjNxcpoapPbj MV2ambHCnMusCU71uxM1IHDF5lTUUjq+pxM2uODNYCcPQrOX0ITwh0D4UdlhURjW59To 4zIxwOPigjdwtfqf7476YbMeqHx2opafz3iPQZVwKBh5F7mEni/3rltBIJnwj7Fs5WiG qyQQ== X-Gm-Message-State: ACgBeo0T19e+aN0pgTCMaLCxkca+tHshoqK4pqC6Y2bznAyK7d2FP8++ RKAhVek2W1pkJswuI4z4QJZemACytsfqzQ== X-Google-Smtp-Source: AA6agR7NYHHTLqA+lROJ72vccZeWGeyrdoFGWPfCyJVp93jLt83MfQmIsazXu8fcYuaDJu6nABlHUA== X-Received: by 2002:a9d:7a55:0:b0:637:1874:a2cb with SMTP id z21-20020a9d7a55000000b006371874a2cbmr9318692otm.318.1661915311112; Tue, 30 Aug 2022 20:08:31 -0700 (PDT) Received: from sjg1.roam.corp.google.com (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id fp39-20020a05687065a700b00116d5103487sm9282605oab.31.2022.08.30.20.08.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 20:08:30 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Michal Simek , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Kishon Vijay Abraham I , Tom Rini , Simon Glass , AKASHI Takahiro , Adrian Fiergolski , Alexandru Gagniuc , Alexey Brodkin , Alper Nebi Yasak , Andre Przywara , Andrew Davis , Angelo Dureghello , Artem Lapkin , Ashok Reddy Soma , Aspeed BMC SW team , Balamanikandan Gunasundar , Bin Meng , Chia-Wei Wang , Chunfeng Yun , Daniel Golle , Daniel Schwierzeck , Dzmitry Sankouski , Eugeniy Paltsev , Ezequiel Garcia , Fabio Estevam , GSS_MTK_Uboot_upstream , Harald Seiler , Heiko Schocher , Heiko Thiery , Heinrich Schuchardt , Huan Wang , Ilias Apalodimas , Jagan Teki , Jan Kiszka , Jason Liu , Jens Wiklander , Joe Hershberger , Joel Stanley , =?UTF-8?q?J=C3=A9r=C3=B4me=20Carretero?= , Leo , Ley Foon Tan , Lokesh Vutla , Lukasz Majewski , Mamta Shukla , Marek Vasut , Max Filippov , Michael Trimarchi , "NXP i.MX U-Boot Team" , Nobuhiro Iwamatsu , Oleksandr Suvorov , Ovidiu Panait , Ovidiu Panait , =?UTF-8?q?Pali=20Roh=C3=A1r?= , Patrick Delaunay , Pavel Herrmann , Peng Fan , Peter Hoyes , Philippe Reynes , Rasmus Villemoes , Ricardo Salveti , Rick Chen , Ryan Chen , Ryder Lee , Samuel Holland , Sean Anderson , Simon Goldschmidt , Stefan Eichenberger , Stefan Roese , Stefano Babic , Thomas Chou , Thomas Haemmerle , Thomas Huth , Tien Fong Chee , Vaishnav Achath , Vignesh Raghavendra , Vitaly Andrianov , Weijie Gao , Wolfgang Denk , uboot-snps-arc@synopsys.com Subject: [PATCH 00/21] dm: core: Support multiple device trees in ofnode Date: Tue, 30 Aug 2022 21:07:56 -0600 Message-Id: <20220831030817.27804-1-sjg@chromium.org> X-Mailer: git-send-email 2.37.2.672.g94769d06f0-goog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Wed, 31 Aug 2022 13:20:08 +0200 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean At present the ofnode interface is somewhat limited, in that it cannot access the device tree provided by the OS, only the one used by U-Boot itself (assuming these are separate). This prevents using ofnode functions to handle device tree fixups, i.e. ft_board_setup() and the like. The ofnode interface was introduced to allow a consistent API to access the device tree, whether a flat tree or a live tree (OF_LIVE) is in use. With the flat tree, adding nodes and properties at the start of the tree (as often happens when writing to the /chosen node) requires copying a lot of data for each operation. With live tree, such operations are quite a bit faster, since there is no memory copying required. This has to be weighed against the required memory allocation with OF_LIVE, as well as the cost of unflattening and flattening the device tree which U-Boot is running. This series enables support for access to multiple device trees with the ofnode interface. This is already available to some extent with OF_LIVE, but some of the ofnode functions need changes to allow the tree to be specified. The mechanism works by using the top 1-4 bits of the device tree offset. The sign bit is not affected, since negative values must be supported. With this implemented, it becomes possible to use the ofnode interface to do device tree fixups. The only current user is the EVT_FT_FIXUP event. This has two main benefits: - ofnode can now be used everywhere, in preference to the libfdt calls - live tree can eventually be used everywhere, with potential speed improvements when larger number of fixups are used This series is only a step along the way. Firstly, while it is possible to access the 'fix-up' tree using OF_LIVE, most of the fixup functions use flat tree directly, rather than the ofnode interface. These need to be updated. Also the tree must be flattened again before it is passed to the OS. This is not currently implemented. With OFNODE_MULTI_TREE disabled this has almost no effect on code size: around 4 bytes if EVENT is enabled, 0 if not. With the feature enabled, the increase is around 500 bytes, e.g. on venice2: buildman -b ofn venice2 -sS --step 0 Summary of 2 commits for 1 boards (1 thread, 64 jobs per thread) 01: image: Drop some other #ifdefs in image-board.c arm: w+ venice2 23: dm: core: Add the ofnode multi-tree implementation 24: wip arm: (for 1/1 boards) all +580.0 text +580.0 This size increase is not too bad, considering the extra functionality, but is too large to enable everywhere. So for now this features needs to be opt-in only, based on EVENT. Simon Glass (21): image: Fix BOOTM_STATE values treewide: Drop bootm_headers_t typedef treewide: Drop image_info_t typedef treewide: Drop image_header_t typedef event: Fix a typo in the EVENT help dm: core: Pass a root node to of_find_node_by_phandle() event: Pass the images to EVT_FT_FIXUP dm: core: Allow adding ofnode subnodes dm: core: Support writing a property to an empty node dm: core: Drop the const from ofnode test: Make a copy of the device tree before running a test test: Detect a change in the device tree test: Drop the UT_TESTF_LIVE_OR_FLAT flag dm: core: Provide a way to reset the device tree dm: core: Add an ofnode function to obtain the flat tree dm: core: Add ofnode functions to obtain an oftree dm: core: Add a way to look up a phandle in an oftree dm: core: Allow obtaining a node offset in the same tree dm: core: Add definitions for multiple ofnode trees dm: core: Reduce code size with dev_of_offset() dm: core: Add the ofnode multi-tree implementation arch/arc/lib/bootm.c | 8 +- arch/arm/lib/bootm.c | 13 +- arch/arm/mach-aspeed/ast2600/spl.c | 4 +- arch/arm/mach-imx/hab.c | 2 +- arch/arm/mach-imx/spl_imx_romapi.c | 6 +- arch/arm/mach-k3/common.c | 2 +- arch/arm/mach-k3/sysfw-loader.c | 6 +- arch/arm/mach-keystone/cmd_mon.c | 6 +- arch/arm/mach-socfpga/board.c | 2 +- arch/arm/mach-sunxi/spl_spi_sunxi.c | 4 +- arch/m68k/lib/bootm.c | 2 +- arch/microblaze/lib/bootm.c | 6 +- arch/mips/lib/bootm.c | 16 +- arch/mips/mach-jz47xx/jz4780/jz4780.c | 6 +- arch/mips/mach-mtmips/mt7621/spl/spl.c | 4 +- arch/mips/mach-mtmips/mt7621/tpl/tpl.c | 4 +- arch/nios2/lib/bootm.c | 2 +- arch/powerpc/lib/bootm.c | 16 +- arch/riscv/lib/bootm.c | 8 +- arch/sandbox/lib/bootm.c | 2 +- arch/sh/lib/bootm.c | 2 +- arch/x86/lib/bootm.c | 8 +- arch/xtensa/lib/bootm.c | 2 +- board/synopsys/hsdk/hsdk.c | 2 +- board/ti/ks2_evm/board.c | 4 +- boot/boot_fit.c | 4 +- boot/bootm.c | 26 +-- boot/bootm_os.c | 35 ++-- boot/image-android.c | 6 +- boot/image-board.c | 26 +-- boot/image-fdt.c | 13 +- boot/image-fit.c | 16 +- boot/image.c | 14 +- cmd/bootefi.c | 2 +- cmd/booti.c | 2 +- cmd/bootm.c | 4 +- cmd/bootz.c | 2 +- cmd/disk.c | 4 +- cmd/fpga.c | 2 +- cmd/nand.c | 4 +- cmd/source.c | 2 +- cmd/ximg.c | 4 +- common/Kconfig | 2 +- common/board_r.c | 2 + common/spl/spl.c | 10 +- common/spl/spl_ext.c | 4 +- common/spl/spl_fat.c | 6 +- common/spl/spl_legacy.c | 8 +- common/spl/spl_mmc.c | 4 +- common/spl/spl_nand.c | 4 +- common/spl/spl_net.c | 2 +- common/spl/spl_nor.c | 8 +- common/spl/spl_onenand.c | 2 +- common/spl/spl_ram.c | 8 +- common/spl/spl_sata.c | 2 +- common/spl/spl_semihosting.c | 4 +- common/spl/spl_spi.c | 6 +- common/spl/spl_ubi.c | 4 +- common/spl/spl_xip.c | 2 +- common/spl/spl_ymodem.c | 14 +- common/splash_source.c | 6 +- doc/develop/driver-model/livetree.rst | 30 ++- doc/uImage.FIT/source_file_format.txt | 2 +- drivers/core/Kconfig | 24 +++ drivers/core/fdtaddr.c | 18 +- drivers/core/of_access.c | 65 +++++- drivers/core/ofnode.c | 263 ++++++++++++++++++++----- drivers/fpga/socfpga_arria10.c | 4 +- drivers/usb/gadget/f_sdp.c | 2 +- include/asm-generic/global_data.h | 4 + include/bootm.h | 6 +- include/configs/uniphier.h | 2 +- include/dm/device.h | 6 +- include/dm/of_access.h | 16 +- include/dm/ofnode.h | 159 +++++++++++++-- include/dm/ofnode_decl.h | 31 ++- include/event.h | 2 + include/image.h | 118 +++++------ include/spl.h | 8 +- include/tee/optee.h | 4 +- include/test/test.h | 8 +- lib/efi_loader/efi_dt_fixup.c | 2 +- lib/fdtdec.c | 5 +- test/dm/ofnode.c | 30 ++- test/image/spl_load.c | 4 +- test/test-main.c | 89 ++++++++- tools/binman/ftest.py | 4 +- tools/default_image.c | 31 ++- tools/fit_image.c | 4 +- tools/imx8mimage.c | 8 +- tools/mkimage.c | 2 +- tools/mtk_image.c | 10 +- 92 files changed, 951 insertions(+), 411 deletions(-) -- 2.37.2.672.g94769d06f0-goog