From patchwork Sun Mar 27 20:26:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1609933 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=ZFsoqYRS; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KRS6p1Wbgz9sG6 for ; Mon, 28 Mar 2022 07:27:14 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 77CFB839B1; Sun, 27 Mar 2022 22:27:07 +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="ZFsoqYRS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 82A5E81DDF; Sun, 27 Mar 2022 22:26:53 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) (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 9050882065 for ; Sun, 27 Mar 2022 22:26:48 +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-pj1-x1030.google.com with SMTP id l4-20020a17090a49c400b001c6840df4a3so13597492pjm.0 for ; Sun, 27 Mar 2022 13:26:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aRFP8WYWhSBhs6uuMSjsRdEtZCEgpKF+blqnPMwUUOQ=; b=ZFsoqYRSgrZDjoyKJ43lQA9NqeE0QSOgPP7riztaUs7TIwl3q7DX1NKs2HITcZlXkv l06B7n7sHH51BnfSM3SCQ2Ipohg2l1Jk/2H7/lbFFikNCz9YRAHbK1X6BSfHlhQZ979f zjCrJUlNulo4a4L2U2CLeAtGicKU2k78PppzM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aRFP8WYWhSBhs6uuMSjsRdEtZCEgpKF+blqnPMwUUOQ=; b=lcmMN8hJiZRRixriC2m/FBNKS2DJ4CyQenrro1StQWGJnasc58DUrs5EcbZJedBJJZ FENx0RdGwwueKQuL8luFECx+COHerkS+n4IP/w7T3Gae4x6CQcqbUHFNrCjk3EgGTFzV tquJ+MFOFag2doxJfu83S9EAzOxW9VQB6mtKiXJgYnUdLQPtWi4ECLBfl3pyek1Ujgbo /1VMCX4Kh0ea57IaF9IBURV6dHCtqY8uWeS30Lm3/1CxjiDdT01YUFkTVp8Ddh/Ktyw9 kCzgashO4/f0dWP+yDSMvgrHaIzTmVeTDjhUe6A0IZDMa8xGMtMeEBbD3gZsSEphU5ll 7pFA== X-Gm-Message-State: AOAM531VrWA6n3y5eNl/ttmu7A2UNTCeJIdx0FX1V1TXpd3eyiI/xLeP Mz+tSwykhxSwKnytxW5iGhaYYnGV01dhKw== X-Google-Smtp-Source: ABdhPJyUQBvqNKhtXmgheQxf3AGpV4+S2ZMRlMPU8kpg7ECLPRYqbfR+URe3hFGTz07x8DEVCRHO3A== X-Received: by 2002:a17:90b:1d04:b0:1c7:1174:56ae with SMTP id on4-20020a17090b1d0400b001c7117456aemr37128397pjb.153.1648412806638; Sun, 27 Mar 2022 13:26:46 -0700 (PDT) Received: from localhost.localdomain (118-93-105-181.dsl.dyn.ihug.co.nz. [118.93.105.181]) by smtp.gmail.com with ESMTPSA id k3-20020a056a00168300b004f7e60da26csm13915466pfc.182.2022.03.27.13.26.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Mar 2022 13:26:46 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Sean Anderson , =?utf-8?q?Marek_Beh=C3=BAn?= , U-Boot Custodians , Tom Rini , Simon Glass , Bin Meng , Ilias Apalodimas , Joel Peshkin , Masahiro Yamada , Patrick Delaunay , Ye Li Subject: [PATCH 01/10] Makefile: v2 Allow LTO to be disabled for a build Date: Sun, 27 Mar 2022 14:26:13 -0600 Message-Id: <20220327202622.3438333-2-sjg@chromium.org> X-Mailer: git-send-email 2.35.1.1021.g381101b075-goog In-Reply-To: <20220327202622.3438333-1-sjg@chromium.org> References: <20220327202622.3438333-1-sjg@chromium.org> MIME-Version: 1.0 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.5 at phobos.denx.de X-Virus-Status: Clean LTO (Link-Time Optimisation) is an very useful feature which can significantly reduce the size of U-Boot binaries. So far it has been made available for selected ARM boards and sandbox. However, incremental builds are much slower when LTO is used. For example, an incremental build of sandbox takes 2.1 seconds on my machine, but 6.7 seconds with LTO enabled. Add a LTO_BUILD=n parameter to the build, so it can be disabled during development if needed, for faster builds. Add some documentation about LTO while we are here. Signed-off-by: Simon Glass --- Makefile | 18 +++++++++++++----- arch/arm/config.mk | 4 ++-- arch/arm/include/asm/global_data.h | 2 +- doc/build/gcc.rst | 17 +++++++++++++++++ scripts/Makefile.spl | 2 +- 5 files changed, 34 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 06572ac07ee..c9585ddebfc 100644 --- a/Makefile +++ b/Makefile @@ -434,6 +434,9 @@ KBUILD_CFLAGS += -fshort-wchar -fno-strict-aliasing KBUILD_AFLAGS := -D__ASSEMBLY__ KBUILD_LDFLAGS := +# Set this to "n" use of LTO for this build, e.g. LTO_BUILD=n +LTO_BUILD ?= y + ifeq ($(cc-name),clang) ifneq ($(CROSS_COMPILE),) CLANG_TARGET := --target=$(notdir $(CROSS_COMPILE:%-=%)) @@ -643,6 +646,11 @@ export CFLAGS_EFI # Compiler flags to add when building EFI app export CFLAGS_NON_EFI # Compiler flags to remove when building EFI app export EFI_TARGET # binutils target if EFI is natively supported +export LTO_ENABLE + +# This is y if LTO is enabled for this build +LTO_ENABLE=$(if $(CONFIG_LTO),$(LTO_BUILD),) + # If board code explicitly specified LDSCRIPT or CONFIG_SYS_LDSCRIPT, use # that (or fail if absent). Otherwise, search for a linker script in a # standard location. @@ -690,16 +698,16 @@ endif LTO_CFLAGS := LTO_FINAL_LDFLAGS := export LTO_CFLAGS LTO_FINAL_LDFLAGS -ifdef CONFIG_LTO +ifeq ($(LTO_ENABLE),y) ifeq ($(cc-name),clang) - LTO_CFLAGS += -flto + LTO_CFLAGS += -DLTO_ENABLE -flto LTO_FINAL_LDFLAGS += -flto AR = $(shell $(CC) -print-prog-name=llvm-ar) NM = $(shell $(CC) -print-prog-name=llvm-nm) else NPROC := $(shell nproc 2>/dev/null || echo 1) - LTO_CFLAGS += -flto=$(NPROC) + LTO_CFLAGS += -DLTO_ENABLE -flto=$(NPROC) LTO_FINAL_LDFLAGS += -fuse-linker-plugin -flto=$(NPROC) # use plugin aware tools @@ -1740,7 +1748,7 @@ ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(ARCH)/Makefile.postlink) # Generate linker list symbols references to force compiler to not optimize # them away when compiling with LTO -ifdef CONFIG_LTO +ifeq ($(LTO_ENABLE),y) u-boot-keep-syms-lto := keep-syms-lto.o u-boot-keep-syms-lto_c := $(patsubst %.o,%.c,$(u-boot-keep-syms-lto)) @@ -1762,7 +1770,7 @@ endif # Rule to link u-boot # May be overridden by arch/$(ARCH)/config.mk -ifdef CONFIG_LTO +ifeq ($(LTO_ENABLE),y) quiet_cmd_u-boot__ ?= LTO $@ cmd_u-boot__ ?= \ $(CC) -nostdlib -nostartfiles \ diff --git a/arch/arm/config.mk b/arch/arm/config.mk index b107b1af27a..065dbec4064 100644 --- a/arch/arm/config.mk +++ b/arch/arm/config.mk @@ -15,11 +15,11 @@ CFLAGS_NON_EFI := -fno-pic -ffixed-r9 -ffunction-sections -fdata-sections \ -fstack-protector-strong CFLAGS_EFI := -fpic -fshort-wchar -ifneq ($(CONFIG_LTO)$(CONFIG_USE_PRIVATE_LIBGCC),yy) +ifneq ($(LTO_ENABLE)$(CONFIG_USE_PRIVATE_LIBGCC),yy) LDFLAGS_FINAL += --gc-sections endif -ifndef CONFIG_LTO +ifneq ($(LTO_ENABLE),y) PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections endif diff --git a/arch/arm/include/asm/global_data.h b/arch/arm/include/asm/global_data.h index 085e12b5d4d..b255b195aa0 100644 --- a/arch/arm/include/asm/global_data.h +++ b/arch/arm/include/asm/global_data.h @@ -98,7 +98,7 @@ struct arch_global_data { #include -#if defined(__clang__) || defined(CONFIG_LTO) +#if defined(__clang__) || defined(LTO_ENABLE) #define DECLARE_GLOBAL_DATA_PTR #define gd get_gd() diff --git a/doc/build/gcc.rst b/doc/build/gcc.rst index 470a7aa3498..792be176aad 100644 --- a/doc/build/gcc.rst +++ b/doc/build/gcc.rst @@ -152,6 +152,23 @@ of dtc is new enough. It also makes sure that pylibfdt is present, if needed Note that the :doc:`tools` are always built with the included version of libfdt so it is not possible to build U-Boot tools with a system libfdt, at present. +Link-time optimisation (LTO) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +U-Boot supports link-time optimisation which can reduce the size of the final +U-Boot binaries, particularly with SPL. + +At present this can be enabled by ARM boards by adding `CONFIG_LTO=y` into the +defconfig file. Other architectures are not supported. LTO is enabled by default +for sandbox. + +This does incur a link-time penalty of several seconds. For faster incremental +builds during development, you can disable it by setting `LTO_BUILD` to `n`. + +.. code-block:: bash + + LTO_BUILD=n make + Other build targets ~~~~~~~~~~~~~~~~~~~ diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl index 83a95ee4aa2..e3ca69c4449 100644 --- a/scripts/Makefile.spl +++ b/scripts/Makefile.spl @@ -472,7 +472,7 @@ endif # Rule to link u-boot-spl # May be overridden by arch/$(ARCH)/config.mk -ifdef CONFIG_LTO +ifeq ($(LTO_ENABLE),y) quiet_cmd_u-boot-spl ?= LTO $@ cmd_u-boot-spl ?= \ ( \ From patchwork Sun Mar 27 20:26:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1609934 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=STHqI2w/; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KRS706b7yz9sG6 for ; Mon, 28 Mar 2022 07:27:24 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1219F839A8; Sun, 27 Mar 2022 22:27:12 +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="STHqI2w/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8B93D836A9; Sun, 27 Mar 2022 22:26:57 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) (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 0E95E8395A for ; Sun, 27 Mar 2022 22:26:52 +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-pf1-x42c.google.com with SMTP id h19so9810196pfv.1 for ; Sun, 27 Mar 2022 13:26:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mb22H+rGrw6rva4zMbvPK77WheLgz1993Hwr/ZW1UHk=; b=STHqI2w/WZDUVoj12KxtwBF2Jrb5Cb9z9BrycK7UxXt+cG4SyPY4lrTzX7tjEtUGk0 FtKR082+LY177LqG8O+QTKGESPyhxGnhcM8t/gObxqBCV0LpbUOGpYrPY82ck9v2wwE0 49aC10KjBdwLM2cy6kyz0KUQP/t90KBgkbZ+s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mb22H+rGrw6rva4zMbvPK77WheLgz1993Hwr/ZW1UHk=; b=vr3tg5C5LL9fmsvtDKHEycj1KPSPtDUr3Qk9UEwyN92f+XkrY52ahDRhGiWftLE6b7 w48dP2vwLcBVvtKhxXBc29CqVS1zTDBswbjLy8iWhUVyOlEXVkepn1ySFTE4vzFXJc5t hHTKwpym2mS+8OW41pCYc67F7hPG80jy4bjcsipfLSvR1yF9u1ay2LBFqpiQ2eEKzNq2 jlMh8RV+LwIMKkgeb7ZP49jE+oWmMJAo69i0j2uxciqPVMuvmOEYaRNRykGcT28vC5Dv jW5D2CB/y32F5U4i0YyVLoWMIn9v1XlMJvTOierzZsjBcmSjGj7ydbGTtblQF+iamvcr PvFg== X-Gm-Message-State: AOAM530y/CRUPMGWDGQOMAbYt1NmneScia+Br2sRV4PHP4es4YW5JB69 a37CIsbkc6ggXONb3pObmReKhBYxBQfxSg== X-Google-Smtp-Source: ABdhPJxWsq2Kzs53EA9OW2MhCygWD6qI3Oed46n9yH9oDpkgSnrUJfUZ/Bn3w6zah3IFAtmDVtCp0g== X-Received: by 2002:a63:5744:0:b0:385:fe08:e835 with SMTP id h4-20020a635744000000b00385fe08e835mr7584772pgm.397.1648412810379; Sun, 27 Mar 2022 13:26:50 -0700 (PDT) Received: from localhost.localdomain (118-93-105-181.dsl.dyn.ihug.co.nz. [118.93.105.181]) by smtp.gmail.com with ESMTPSA id k3-20020a056a00168300b004f7e60da26csm13915466pfc.182.2022.03.27.13.26.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Mar 2022 13:26:50 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Sean Anderson , =?utf-8?q?Marek_Beh=C3=BAn?= , U-Boot Custodians , Tom Rini , Simon Glass Subject: [PATCH 02/10] sandbox: Correct loss of early output in SPL Date: Sun, 27 Mar 2022 14:26:14 -0600 Message-Id: <20220327142415.2.If1c273ffb4d69da0ebb02720f7ff997e8b35944c@changeid> X-Mailer: git-send-email 2.35.1.1021.g381101b075-goog In-Reply-To: <20220327202622.3438333-1-sjg@chromium.org> References: <20220327202622.3438333-1-sjg@chromium.org> MIME-Version: 1.0 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.5 at phobos.denx.de X-Virus-Status: Clean At present fputc() is used before the console is available, then write() is used. These are not compatible. Since fputc() buffers internally it is better to use the write(), so that a partial line is immediately displayed. This has a slight effect on performance, but we are already using write() for the vast majority of the output with no obvious impacts. Signed-off-by: Simon Glass --- arch/sandbox/cpu/os.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index d83c862182d..5ea54179176 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -644,7 +644,7 @@ int os_get_filesize(const char *fname, long long *size) void os_putc(int ch) { - fputc(ch, stdout); + os_write(1, &ch, 1); } void os_puts(const char *str) From patchwork Sun Mar 27 20:26:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1609935 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=YI94NdSW; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KRS7D6yDYz9sG6 for ; Mon, 28 Mar 2022 07:27:36 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EE9CA83A70; Sun, 27 Mar 2022 22:27:21 +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="YI94NdSW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2C3DF83025; Sun, 27 Mar 2022 22:27:00 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) (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 D971D8398D for ; Sun, 27 Mar 2022 22:26:55 +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-pj1-x102c.google.com with SMTP id n7-20020a17090aab8700b001c6aa871860so13578856pjq.2 for ; Sun, 27 Mar 2022 13:26:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xUNFrWdAvTqpsfdIEWeaGN+cvySd6ubSiaqvPXhYEjQ=; b=YI94NdSWP5XnUSeYYQdlg+tpo50Tsgnfk+4I2aueSoD6mW2uXtjPS287VLLJLz0zEd UUQ+PMLCSdtZj/MMaYKw7fAChIR6J1mXDuvZNIqRIgotiKoZeL9kzimrtPrDA1GBcGh1 uATEys4qUzETWi11wP05xvq7kQ7+AxHPgKdVg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xUNFrWdAvTqpsfdIEWeaGN+cvySd6ubSiaqvPXhYEjQ=; b=RDSE5RmWyIws8WKqF8/Oa8Du9GPOcwS0fAOBqcEqZ+p9QthQQyEif2BMYv4MZk3+u6 4SkZNf70ZyGwEEPKytqGuGyLuLT3c5bgrmDOvsIE1syDdxPC/Zq75KNFUs1dvQQ8tVcN lmGrRGlBb1KJ1r7ORGsQWfIwPMduGhc+OI1nfEYHalIIw1lfjD0IArmXRYiLaHIpjcbC 3oVwrVZKlNF4ONGeSZafdm3vl7u7emzc2+4f8dV/o9X+ATBNq5VTZ3MvcBctx5Q7U1ci N765v2DnLTkrYrBllTsU3dtCx2vHY5tS8IEN/UZqRpgFl+4aOO2KRQsvwtLIgoMBgNva aDnw== X-Gm-Message-State: AOAM533x4PfjLGlCw31ofSWWo+YruTZb2fFEn1wAgSS43b6K5jMiPke+ TeMtuy0VImX+SwtJt4jFrZPZ+hPAzE8dsw== X-Google-Smtp-Source: ABdhPJzO2AZQQUkqcSl5wxiUpU6Cf5kkofprctJlVApmWxAzmPd6JWeXeFWufDGb8n7Tcn1mNwRrng== X-Received: by 2002:a17:902:8f94:b0:154:839b:809f with SMTP id z20-20020a1709028f9400b00154839b809fmr22525622plo.150.1648412814264; Sun, 27 Mar 2022 13:26:54 -0700 (PDT) Received: from localhost.localdomain (118-93-105-181.dsl.dyn.ihug.co.nz. [118.93.105.181]) by smtp.gmail.com with ESMTPSA id k3-20020a056a00168300b004f7e60da26csm13915466pfc.182.2022.03.27.13.26.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Mar 2022 13:26:54 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Sean Anderson , =?utf-8?q?Marek_Beh=C3=BAn?= , U-Boot Custodians , Tom Rini , Simon Glass , Masahiro Yamada Subject: [PATCH 03/10] Makefile: Drop a stale comment about linking Date: Sun, 27 Mar 2022 14:26:15 -0600 Message-Id: <20220327202622.3438333-3-sjg@chromium.org> X-Mailer: git-send-email 2.35.1.1021.g381101b075-goog In-Reply-To: <20220327202622.3438333-1-sjg@chromium.org> References: <20220327202622.3438333-1-sjg@chromium.org> MIME-Version: 1.0 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.5 at phobos.denx.de X-Virus-Status: Clean The bug mentioned here is fixed, so drop the comment. Signed-off-by: Simon Glass --- Makefile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Makefile b/Makefile index c9585ddebfc..e23c3204d21 100644 --- a/Makefile +++ b/Makefile @@ -1785,10 +1785,6 @@ quiet_cmd_u-boot__ ?= LTO $@ -Wl,-Map,u-boot.map; \ $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) else -# Note: Linking efi-x86_app64 causes a segfault in the linker at present -# when using x86_64-linux-gnu-ld.bfd -# For now, disable --whole-archive which makes things link, although not -# correctly quiet_cmd_u-boot__ ?= LD $@ cmd_u-boot__ ?= $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_u-boot) -o $@ \ -T u-boot.lds $(u-boot-init) \ From patchwork Sun Mar 27 20:26:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1609936 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=BLW+syB3; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KRS7T2qn0z9sG6 for ; Mon, 28 Mar 2022 07:27:49 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2168483ABA; Sun, 27 Mar 2022 22:27:26 +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="BLW+syB3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1E3DD836A9; Sun, 27 Mar 2022 22:27:08 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) (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 D62B0836A9 for ; Sun, 27 Mar 2022 22:27:00 +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-pf1-x42f.google.com with SMTP id b15so10811061pfm.5 for ; Sun, 27 Mar 2022 13:27:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HVLJanl7xXKQbbTCeXwgq2QX6v9hzKiBXbTS78dAIG0=; b=BLW+syB3LlQtVQb62bK+G3J44D1BNVrIKZTOo1HB36T5X43cyeO6DW7PEMSuKsarlN lvc3TxiWyDi1VLmIwobZL1z68b/n4F2vDGTGfuX0lv5dFhDNOOzMpk7rXD0ki2HAhmL7 3+jdYkazA6ZAjWKwgFBEOY9B01kjZNxLD7/pQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HVLJanl7xXKQbbTCeXwgq2QX6v9hzKiBXbTS78dAIG0=; b=0vVqXyjldtICivv6WZdRX05h4O1PnlrjfBrN6RyGgOIhPapP61jB8jpCHQJc93THO4 0UGeWAuDBnmdNALx0gQgaZ2LPWOFqEcqrqT2eLxE6nafUQQ+jmOcAmzy8dJSXYIwGjRW E1fpAucjuW/gQggTdnl+Og0K/swkY/Kk1NeRgUyPnutEuIJrnRKcKc2zW8jtprF1tnju z5fsZPBpMAuO4W73PEwpjSPdJqchg35U09vQ+SU4BVXfPbnaFK8MwaUor8oDUAL/uR6l ufDPMNoppZ4uURtRi1kPJKbuOLXnVjrgtJR/FspEL41LYj/pMF6sEtIemI56Ae5O671h FagA== X-Gm-Message-State: AOAM531ToSC7h+WWPb7pBmENewXZNs/QC8NH9dL6C3FiJHjPnWVhKIzo rGTw0y3pW44MqOSSP2ACvjoHDIwvbPbhOg== X-Google-Smtp-Source: ABdhPJzMUHpfKHVSOjvjJ9JuBNOF4Qt8sI2LDBUkxYGIHAWneLEDG2+077IhfIOr0NC6geDO4Zn3Qg== X-Received: by 2002:a63:445f:0:b0:381:6cef:d841 with SMTP id t31-20020a63445f000000b003816cefd841mr7826042pgk.363.1648412819163; Sun, 27 Mar 2022 13:26:59 -0700 (PDT) Received: from localhost.localdomain (118-93-105-181.dsl.dyn.ihug.co.nz. [118.93.105.181]) by smtp.gmail.com with ESMTPSA id k3-20020a056a00168300b004f7e60da26csm13915466pfc.182.2022.03.27.13.26.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Mar 2022 13:26:58 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Sean Anderson , =?utf-8?q?Marek_Beh=C3=BAn?= , U-Boot Custodians , Tom Rini , Simon Glass , Masahiro Yamada Subject: [PATCH 04/10] Makefile: Avoid resetting link flags in config.mk Date: Sun, 27 Mar 2022 14:26:16 -0600 Message-Id: <20220327202622.3438333-4-sjg@chromium.org> X-Mailer: git-send-email 2.35.1.1021.g381101b075-goog In-Reply-To: <20220327202622.3438333-1-sjg@chromium.org> References: <20220327202622.3438333-1-sjg@chromium.org> MIME-Version: 1.0 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.5 at phobos.denx.de X-Virus-Status: Clean This makes it impossible to change them elsewhere. The default value is 'empty' anyway, so just drop it. Signed-off-by: Simon Glass --- config.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/config.mk b/config.mk index 2595aed218b..b915c29b3f3 100644 --- a/config.mk +++ b/config.mk @@ -12,7 +12,6 @@ # If we did not have Tegra SoCs, build system would be much simpler...) PLATFORM_RELFLAGS := PLATFORM_CPPFLAGS := -KBUILD_LDFLAGS := LDFLAGS_FINAL := LDFLAGS_STANDALONE := OBJCOPYFLAGS := From patchwork Sun Mar 27 20:26:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1609937 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=HlGPVmBI; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KRS7j0jhcz9sG6 for ; Mon, 28 Mar 2022 07:28:01 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9635E839B2; Sun, 27 Mar 2022 22:27:37 +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="HlGPVmBI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B4CAB8399E; Sun, 27 Mar 2022 22:27:11 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) (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 DDF2683997 for ; Sun, 27 Mar 2022 22:27:04 +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-pl1-x636.google.com with SMTP id e5so13129963pls.4 for ; Sun, 27 Mar 2022 13:27:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oCEV7mLNmwcF5xoq1YeC3KKtsm9SxQPkseT+WFOnLE4=; b=HlGPVmBIOwr9lpi+0W8hoyAkCk4/6onvgEiyAzWIPKi3EKC5caxZXLdmuIxDaYevDT aWc6FxASEAOsqKQdN5Sg6obc8voTJPzQJMgBpumXAvUOGjZnvEPExyEOcZEOpUpHyND9 jNUQ9vh4SF4iZ6Vz6voeneKd2PaLQ/VDStpNE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oCEV7mLNmwcF5xoq1YeC3KKtsm9SxQPkseT+WFOnLE4=; b=16hWkJX48+dx0SvwFi/RBORW2PFzJRrPnlWb/xDLxJIbFdvmMNqjPTW/+ki9Ronvg+ +kEK+aavPM3xOM1KBzLLf2Xwb9Vxkt5koNgSocrNA6MIdAQm5n+Hhzsir8/zWBKLneHd /HeTiOaQFRAAgtZZQGqHw6/lHIWDHFrzzCkvlFwVSEN//aIGLi46G2MYmn+Z+VTykCVd r0x7EwWspW5T8OJPgCuK3+jTgiCdrPwS8YZr8UqN3fsKR60mO4UHH+uAQIy38ODPmMDd cBViAOiyqEy4g0rDJRfQQ4WzCi+5ZgXLk4hjcXLwRyE9Wh5biDDZnOEQ3DEiHYk64x3x v+ng== X-Gm-Message-State: AOAM530Kcs6XWzzUSziLmaK05HTZF8aKJiRiEY/ncCCA+02+ljEiFe9O ANOvwv5LlC3F9ZKtW4g+ttOwOIgTyKgJuA== X-Google-Smtp-Source: ABdhPJxB+Qh8bKi+s4vqsFsX9Ry3Jxep1iV3GTyt/gQSGjg9gvP3Fnw5OqDdH9Aqus4q757RygDwmw== X-Received: by 2002:a17:90a:f48a:b0:1c9:95c9:3092 with SMTP id bx10-20020a17090af48a00b001c995c93092mr4865447pjb.238.1648412823264; Sun, 27 Mar 2022 13:27:03 -0700 (PDT) Received: from localhost.localdomain (118-93-105-181.dsl.dyn.ihug.co.nz. [118.93.105.181]) by smtp.gmail.com with ESMTPSA id k3-20020a056a00168300b004f7e60da26csm13915466pfc.182.2022.03.27.13.26.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Mar 2022 13:27:03 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Sean Anderson , =?utf-8?q?Marek_Beh=C3=BAn?= , U-Boot Custodians , Tom Rini , Simon Glass Subject: [PATCH 05/10] sandbox: Allow link flags to be given Date: Sun, 27 Mar 2022 14:26:17 -0600 Message-Id: <20220327202622.3438333-5-sjg@chromium.org> X-Mailer: git-send-email 2.35.1.1021.g381101b075-goog In-Reply-To: <20220327202622.3438333-1-sjg@chromium.org> References: <20220327202622.3438333-1-sjg@chromium.org> MIME-Version: 1.0 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.5 at phobos.denx.de X-Virus-Status: Clean At present the link flags are not used for sandbox. Update the command line to use them. Signed-off-by: Simon Glass --- arch/sandbox/config.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/sandbox/config.mk b/arch/sandbox/config.mk index 2b1b657831c..02a3ba0c0e9 100644 --- a/arch/sandbox/config.mk +++ b/arch/sandbox/config.mk @@ -16,7 +16,7 @@ PLATFORM_CPPFLAGS += $(shell $(SDL_CONFIG) --cflags) endif cmd_u-boot__ = $(CC) -o $@ -Wl,-T u-boot.lds $(u-boot-init) \ - $(LTO_FINAL_LDFLAGS) \ + $(KBUILD_LDFLAGS:%=-Wl,%)$(LTO_FINAL_LDFLAGS) \ -Wl,--whole-archive \ $(u-boot-main) \ $(u-boot-keep-syms-lto) \ @@ -24,7 +24,7 @@ cmd_u-boot__ = $(CC) -o $@ -Wl,-T u-boot.lds $(u-boot-init) \ $(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map cmd_u-boot-spl = (cd $(obj) && $(CC) -o $(SPL_BIN) -Wl,-T u-boot-spl.lds \ - $(LTO_FINAL_LDFLAGS) \ + $(KBUILD_LDFLAGS:%=-Wl,%) $(LTO_FINAL_LDFLAGS) \ $(patsubst $(obj)/%,%,$(u-boot-spl-init)) \ -Wl,--whole-archive \ $(patsubst $(obj)/%,%,$(u-boot-spl-main)) \ From patchwork Sun Mar 27 20:26:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1609938 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=YP89oObq; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KRS7w5Hv6z9sG6 for ; Mon, 28 Mar 2022 07:28:12 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CB2AF81DDF; Sun, 27 Mar 2022 22:27:44 +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="YP89oObq"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E279A839D3; Sun, 27 Mar 2022 22:27:15 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) (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 2ED558395A for ; Sun, 27 Mar 2022 22:27:09 +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-pg1-x52c.google.com with SMTP id k14so10716764pga.0 for ; Sun, 27 Mar 2022 13:27:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UFOOkcS9rh4flZrYkL5g5ay84HOkSFRgjEMMQP4SmeA=; b=YP89oObq5QU/eahWzryit6STuToBIugLU23w6x3SEcz/hQj/ub7MRDUzy3bsFCGwGo orDWi8zxT2qwaumGWtiP1Gy04D2PumILmGMaEADAVz7s2ibi/qJMP7iQmIaMTmG/7zKc +yNxHRVGeJa7o5PCjV638r9pvmL65rH9yYTZU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UFOOkcS9rh4flZrYkL5g5ay84HOkSFRgjEMMQP4SmeA=; b=QwK78cYmmq6cyBK5UqA8hHcfe4pDNeoPnH5Cxieb3xypuQG0GIHhH5bKKflyBZJwVx /2trgFATab/W0to3kNvKhaqDkAv4OjbhB1mabxBnB+qPGPZYqi6vTAClVeIVtbO2oU2e yri4Q6WMoMU3uSzxMS+jUeAibe5kmUYNLQ5WK0H/hKPg4CwcEJCAv/jP3A3+5rp+ThmZ ak4gm7vmqkFFG2CrzZITPLryUlxYGh+KRMsxq1FBcZA6RQFXbyYUCnUQKlYNf9YjaML7 8fJsvr4iJTgSJ6CVf4WiD2SZtcMikMRHzdm2k2BkBpUICWrKbQE0JGhGsWGsFUX9IaJq z9sw== X-Gm-Message-State: AOAM531tzcr9eNuc5418uUfL2NNCsOzRaoyLOFEwjoqz5lzE59P17rtF Et+8o7P+zP7NBBMfL2o6AAYa27gIwVplAA== X-Google-Smtp-Source: ABdhPJwo0Q5zFm0tBMu4L8uZvI9VGatdEzAtjKuHT0G6wYWbbBAD8oLi6489s0XwmPG6M22UthgzMw== X-Received: by 2002:a05:6a00:124f:b0:4fb:2608:78de with SMTP id u15-20020a056a00124f00b004fb260878demr9952715pfi.27.1648412827470; Sun, 27 Mar 2022 13:27:07 -0700 (PDT) Received: from localhost.localdomain (118-93-105-181.dsl.dyn.ihug.co.nz. [118.93.105.181]) by smtp.gmail.com with ESMTPSA id k3-20020a056a00168300b004f7e60da26csm13915466pfc.182.2022.03.27.13.27.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Mar 2022 13:27:07 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Sean Anderson , =?utf-8?q?Marek_Beh=C3=BAn?= , U-Boot Custodians , Tom Rini , Simon Glass Subject: [PATCH 06/10] sandbox: Align linker lists to a 32-byte boundary Date: Sun, 27 Mar 2022 14:26:18 -0600 Message-Id: <20220327202622.3438333-6-sjg@chromium.org> X-Mailer: git-send-email 2.35.1.1021.g381101b075-goog In-Reply-To: <20220327202622.3438333-1-sjg@chromium.org> References: <20220327202622.3438333-1-sjg@chromium.org> MIME-Version: 1.0 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.5 at phobos.denx.de X-Virus-Status: Clean Use this larger boundary to ensure that linker lists at least start on the maximum possible alignment boundary. See also the CONFIG_LINKER_LIST_ALIGN setting, but that is host-arch-specific, so it seems better to use the largest value for every host architecture. Signed-off-by: Simon Glass --- arch/sandbox/cpu/u-boot-spl.lds | 2 +- arch/sandbox/cpu/u-boot.lds | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/sandbox/cpu/u-boot-spl.lds b/arch/sandbox/cpu/u-boot-spl.lds index 6754f4ef6cc..206e265e74b 100644 --- a/arch/sandbox/cpu/u-boot-spl.lds +++ b/arch/sandbox/cpu/u-boot-spl.lds @@ -8,7 +8,7 @@ SECTIONS { - . = ALIGN(4); + . = ALIGN(32); .u_boot_list : { KEEP(*(SORT(.u_boot_list*))); } diff --git a/arch/sandbox/cpu/u-boot.lds b/arch/sandbox/cpu/u-boot.lds index 6d710618f59..92e834a8d2b 100644 --- a/arch/sandbox/cpu/u-boot.lds +++ b/arch/sandbox/cpu/u-boot.lds @@ -8,7 +8,7 @@ SECTIONS { - . = ALIGN(4); + . = ALIGN(32); .u_boot_list : { KEEP(*(SORT(.u_boot_list*))); } From patchwork Sun Mar 27 20:26:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1609939 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=htof+y5p; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KRS8740gbz9sG6 for ; Mon, 28 Mar 2022 07:28:23 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 075D683ADC; Sun, 27 Mar 2022 22:27:52 +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="htof+y5p"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 57FC0839D3; Sun, 27 Mar 2022 22:27:24 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) (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 0CD84839D4 for ; Sun, 27 Mar 2022 22:27:14 +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-pj1-x102b.google.com with SMTP id n7-20020a17090aab8700b001c6aa871860so13579254pjq.2 for ; Sun, 27 Mar 2022 13:27:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1Dp9LCHVaJiE1wc6zIIhhN3ypBOvESIGHJE6PNe2SIY=; b=htof+y5pN1FQtXBCYzrRHB+CpdSIKxOSz3UES2Vg3A7PU8zXbIzplzdpsbXl/yw5s+ V7ptMmramrzicDmKekYq6kE02zZYphiWAn8F6cY0J/8JuenXHuuTnZ26lY6OTyhnk4RT mk6pHNeYdy0ht4XeafDNXA4kwuLpKUa9WkUg4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1Dp9LCHVaJiE1wc6zIIhhN3ypBOvESIGHJE6PNe2SIY=; b=qEuRdA58xZEw8LZg65Z/o+5VBwk0uEhHkPmPko5TC72YGsyNjBCLNp08VLkny4gLOa 0b3gbDO+ypXWI/Trdzl/DsOJ0zXvGVjeULzHW6RiKHY7QV8+TY9cZd4toclK+f6d3D3E +6+9JGKeixVTIZLv9T8wnq73RkdC3vFnNpx0Q0juMdDfDFC2mmYLPPHLDHSRusns/09f IW+hLQ2ozBTIi88FNBrMDXxl5vYm3GdeoT+pA/sefGb1QMyXf33h731SNoa08w8d3uts T0U8VehvjQTNrDdu2XfvyKCN7t+Kq14exwnuO+o4kXJdpsBlYaKd6YJFMMTQJtNtMG5J y6Sw== X-Gm-Message-State: AOAM5333gL4M7TVlwJLVr+HR19JxPFosFmwFo5P2CVrvGZ9vuES6QJdw +L2ZQM6B4RYeJYTMiu/XBAmAw16F+VwqXQ== X-Google-Smtp-Source: ABdhPJxsHUC9eXV2q5Gdc+e5Q5DT32KPgPrcAcCI2+vJYJOCMp8nUdPIsISuS7ds9gIePazln3Elvw== X-Received: by 2002:a17:90a:aa84:b0:1c5:f4e3:c69d with SMTP id l4-20020a17090aaa8400b001c5f4e3c69dmr37541557pjq.169.1648412832310; Sun, 27 Mar 2022 13:27:12 -0700 (PDT) Received: from localhost.localdomain (118-93-105-181.dsl.dyn.ihug.co.nz. [118.93.105.181]) by smtp.gmail.com with ESMTPSA id k3-20020a056a00168300b004f7e60da26csm13915466pfc.182.2022.03.27.13.27.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Mar 2022 13:27:12 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Sean Anderson , =?utf-8?q?Marek_Beh=C3=BAn?= , U-Boot Custodians , Tom Rini , Simon Glass , Marek Vasut , Pavel Herrmann Subject: [PATCH 07/10] dm: core: Allow devres to be disabled in SPL Date: Sun, 27 Mar 2022 14:26:19 -0600 Message-Id: <20220327142415.7.I1c802c77c131021c932f0fd418b837e2efbd5bbc@changeid> X-Mailer: git-send-email 2.35.1.1021.g381101b075-goog In-Reply-To: <20220327202622.3438333-1-sjg@chromium.org> References: <20220327202622.3438333-1-sjg@chromium.org> MIME-Version: 1.0 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.5 at phobos.denx.de X-Virus-Status: Clean At present if devres is enabled in U-Boot proper it is enabled in SPL. We don't normally want it there, so disable it. Signed-off-by: Simon Glass Tested-by: Angus Ainslie --- drivers/core/Makefile | 2 +- drivers/core/device.c | 2 +- include/dm/device-internal.h | 6 +++--- include/dm/device.h | 2 +- include/dm/devres.h | 4 ++-- test/dm/Makefile | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/core/Makefile b/drivers/core/Makefile index 5edd4e41357..0cbc3ab217e 100644 --- a/drivers/core/Makefile +++ b/drivers/core/Makefile @@ -4,7 +4,7 @@ obj-y += device.o fdtaddr.o lists.o root.o uclass.o util.o obj-$(CONFIG_$(SPL_TPL_)ACPIGEN) += acpi.o -obj-$(CONFIG_DEVRES) += devres.o +obj-$(CONFIG_$(SPL_TPL_)DEVRES) += devres.o obj-$(CONFIG_$(SPL_)DM_DEVICE_REMOVE) += device-remove.o obj-$(CONFIG_$(SPL_)SIMPLE_BUS) += simple-bus.o obj-$(CONFIG_SIMPLE_PM_BUS) += simple-pm-bus.o diff --git a/drivers/core/device.c b/drivers/core/device.c index 1b356f12dd8..b7ce8544140 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -68,7 +68,7 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv, INIT_LIST_HEAD(&dev->sibling_node); INIT_LIST_HEAD(&dev->child_head); INIT_LIST_HEAD(&dev->uclass_node); -#ifdef CONFIG_DEVRES +#if CONFIG_IS_ENABLED(DEVRES) INIT_LIST_HEAD(&dev->devres_head); #endif dev_set_plat(dev, plat); diff --git a/include/dm/device-internal.h b/include/dm/device-internal.h index c420726287e..2fc41f31f5a 100644 --- a/include/dm/device-internal.h +++ b/include/dm/device-internal.h @@ -396,7 +396,7 @@ fdt_addr_t simple_bus_translate(struct udevice *dev, fdt_addr_t addr); #define DM_UCLASS_ROOT_S_NON_CONST (((gd_t *)gd)->uclass_root_s) /* device resource management */ -#ifdef CONFIG_DEVRES +#if CONFIG_IS_ENABLED(DEVRES) /** * devres_release_probe - Release managed resources allocated after probing @@ -416,7 +416,7 @@ void devres_release_probe(struct udevice *dev); */ void devres_release_all(struct udevice *dev); -#else /* ! CONFIG_DEVRES */ +#else /* ! DEVRES */ static inline void devres_release_probe(struct udevice *dev) { @@ -426,7 +426,7 @@ static inline void devres_release_all(struct udevice *dev) { } -#endif /* ! CONFIG_DEVRES */ +#endif /* DEVRES */ static inline int device_notify(const struct udevice *dev, enum event_t type) { diff --git a/include/dm/device.h b/include/dm/device.h index cb52a0997c8..3d8961f9ac6 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -184,7 +184,7 @@ struct udevice { #if CONFIG_IS_ENABLED(OF_REAL) ofnode node_; #endif -#ifdef CONFIG_DEVRES +#if CONFIG_IS_ENABLED(DEVRES) struct list_head devres_head; #endif #if CONFIG_IS_ENABLED(DM_DMA) diff --git a/include/dm/devres.h b/include/dm/devres.h index 0ab277ec38e..697534aa5be 100644 --- a/include/dm/devres.h +++ b/include/dm/devres.h @@ -30,7 +30,7 @@ struct devres_stats { int total_size; }; -#ifdef CONFIG_DEVRES +#if CONFIG_IS_ENABLED(DEVRES) #ifdef CONFIG_DEBUG_DEVRES void *__devres_alloc(dr_release_t release, size_t size, gfp_t gfp, @@ -207,7 +207,7 @@ void devm_kfree(struct udevice *dev, void *ptr); /* Get basic stats on allocations */ void devres_get_stats(const struct udevice *dev, struct devres_stats *stats); -#else /* ! CONFIG_DEVRES */ +#else /* ! DEVRES */ static inline void *devres_alloc(dr_release_t release, size_t size, gfp_t gfp) { diff --git a/test/dm/Makefile b/test/dm/Makefile index d46552fbf32..9a1a904d906 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -32,7 +32,7 @@ obj-$(CONFIG_CLK) += clk.o clk_ccf.o obj-$(CONFIG_CPU) += cpu.o obj-$(CONFIG_CROS_EC) += cros_ec.o obj-$(CONFIG_PWM_CROS_EC) += cros_ec_pwm.o -obj-$(CONFIG_DEVRES) += devres.o +obj-$(CONFIG_$(SPL_TPL_)DEVRES) += devres.o obj-$(CONFIG_DMA) += dma.o obj-$(CONFIG_VIDEO_MIPI_DSI) += dsi_host.o obj-$(CONFIG_DM_DSA) += dsa.o From patchwork Sun Mar 27 20:26:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1609940 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=VPEeDErO; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KRS8K6CS1z9sG6 for ; Mon, 28 Mar 2022 07:28:33 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 95827839E7; Sun, 27 Mar 2022 22:27:54 +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="VPEeDErO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 53C7483AD0; Sun, 27 Mar 2022 22:27:31 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) (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 B7C0D83A5B for ; Sun, 27 Mar 2022 22:27:18 +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-pl1-x629.google.com with SMTP id e5so13130277pls.4 for ; Sun, 27 Mar 2022 13:27:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tL1VUDRxz8hdXs7hLG0AMzE8m1LYd62C0bYmcB4X9cM=; b=VPEeDErORbMeX9eU6GN0k12UaybYied+PXwk27L9VwHVrVz2/b0ZzgIzqNUKjjkuTp vvoZ7AQV6xMj85Z7Hkw8b9WJvLWbxBWz8mcMTR9Hs3APm2qp/SXbOoHsgnepsmv9ICch t7cB6O4HlUtqe8bsJaiwrXu62v/Q5Am9ngs38= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tL1VUDRxz8hdXs7hLG0AMzE8m1LYd62C0bYmcB4X9cM=; b=DCr9UpfCkGn7V9Gm52sX3f6JF3/Z+xntFeVC+VtDcb2XYj/eX4HPlIFid3XMDLFecV XzlhdfR0yCH/pCLk4lQxp3gJCWSFNgcSMD8siO1v+FxH6QXeBkoFSvuOeOTfqBA8x4i4 tT1PUfNd0VqJIQu1ugcmKeMxgXVMKCIG+vr50ETXSivhLr5scEIAOqTAqODGuYEc8+Uf czXrjnawnr/Df5Sdz8BDhRF2hchfrBkjT6whDR/XJBLRs+9FE88P/+di/kTRY9LpS3Rw 13iPr3amxjkXne3T+mpA6Ka+svDcOu4UBYxWYEilwOHiKWnHdH+QdWoAwKrJCHz4Y7oy WQIw== X-Gm-Message-State: AOAM533QxqmYpq4BFvMBwHQRiz0uMA9ixWG66adHkVA0KVmVLYIYQFSd x+S9AI+IfPmrhG9bN+lOei1ujQOvigHu8g== X-Google-Smtp-Source: ABdhPJy6XtgMXW78qXw2SeECwesEJ4b+XOE7EyddJbfCAovKiYX+6qJA+mFuTDrZYZMBBsb/AKDsAw== X-Received: by 2002:a17:902:cec2:b0:154:6df6:1e6a with SMTP id d2-20020a170902cec200b001546df61e6amr23093613plg.58.1648412837043; Sun, 27 Mar 2022 13:27:17 -0700 (PDT) Received: from localhost.localdomain (118-93-105-181.dsl.dyn.ihug.co.nz. [118.93.105.181]) by smtp.gmail.com with ESMTPSA id k3-20020a056a00168300b004f7e60da26csm13915466pfc.182.2022.03.27.13.27.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Mar 2022 13:27:16 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Sean Anderson , =?utf-8?q?Marek_Beh=C3=BAn?= , U-Boot Custodians , Tom Rini , Simon Glass , Marek Vasut , Pavel Herrmann Subject: [PATCH 08/10] dm: core: Deal with a wrinkle with linker lists Date: Sun, 27 Mar 2022 14:26:20 -0600 Message-Id: <20220327202622.3438333-7-sjg@chromium.org> X-Mailer: git-send-email 2.35.1.1021.g381101b075-goog In-Reply-To: <20220327202622.3438333-1-sjg@chromium.org> References: <20220327202622.3438333-1-sjg@chromium.org> MIME-Version: 1.0 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.5 at phobos.denx.de X-Virus-Status: Clean When every member of a linker list is aligned by the compiler, we can no longer rely on the sizeof of the struct to determine the number of entries. For example, if the struct size is 0x90 but every entry is aligned to 0xa0 by the compiler, the linker list entries takes more space in memory and the calculation of the number of entries is incorrect. For example, we may see 0x12 entries when there are only 0x11. This is a real problem. There may be a general solution, although I cannot currently think of one. So far it only bites with OF_PLATDATA_RT which creates a pointer to each entry of the 'struct udevice' linker_list. This does not happen without that option, so it only affects SPL. Work around it by manually calculating the aligned size of struct udevice, then using that for the n_ent calculation. Note: the alignment fix to linker list was here: 0b2fa98aa5e linker_lists: Fix alignment issue Signed-off-by: Simon Glass --- drivers/core/device.c | 3 ++- drivers/core/root.c | 8 +++++++- include/dm/device.h | 8 ++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/core/device.c b/drivers/core/device.c index b7ce8544140..3ab2583df38 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -1186,7 +1186,8 @@ int dev_enable_by_path(const char *path) static struct udevice_rt *dev_get_rt(const struct udevice *dev) { struct udevice *base = ll_entry_start(struct udevice, udevice); - int idx = dev - base; + uint each_size = dm_udevice_size(); + int idx = ((void *)dev - (void *)base) / each_size; struct udevice_rt *urt = gd_dm_udevice_rt() + idx; diff --git a/drivers/core/root.c b/drivers/core/root.c index 8efb4256b27..6d1a4097e14 100644 --- a/drivers/core/root.c +++ b/drivers/core/root.c @@ -136,12 +136,18 @@ static int dm_setup_inst(void) if (CONFIG_IS_ENABLED(OF_PLATDATA_RT)) { struct udevice_rt *urt; + void *start, *end; + int each_size; void *base; int n_ents; uint size; /* Allocate the udevice_rt table */ - n_ents = ll_entry_count(struct udevice, udevice); + each_size = dm_udevice_size(); + start = ll_entry_start(struct udevice, udevice); + end = ll_entry_end(struct udevice, udevice); + size = end - start; + n_ents = size / each_size; urt = calloc(n_ents, sizeof(struct udevice_rt)); if (!urt) return log_msg_ret("urt", -ENOMEM); diff --git a/include/dm/device.h b/include/dm/device.h index 3d8961f9ac6..e0f86f5df9f 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -192,6 +192,14 @@ struct udevice { #endif }; +static inline int dm_udevice_size(void) +{ + if (CONFIG_IS_ENABLED(OF_PLATDATA_RT)) + return ALIGN(sizeof(struct udevice), CONFIG_LINKER_LIST_ALIGN); + + return sizeof(struct udevice); +} + /** * struct udevice_rt - runtime information set up by U-Boot * From patchwork Sun Mar 27 20:26:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1609941 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=i/2GapDf; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KRS8X2R0Tz9sG6 for ; Mon, 28 Mar 2022 07:28:44 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D738383AC2; Sun, 27 Mar 2022 22:27:58 +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="i/2GapDf"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B0183839FD; Sun, 27 Mar 2022 22:27:39 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) (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 D1131839C7 for ; Sun, 27 Mar 2022 22:27:24 +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-pg1-x530.google.com with SMTP id t13so9451384pgn.8 for ; Sun, 27 Mar 2022 13:27:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yPp2bGhdeUFimOMHtTruSVnrWZkYmSmUP3HvTyAwjpA=; b=i/2GapDfgJuNx8cSEgVf5YUdKzNUleqLgZJQSmTc07FCcK3e/FpdO1II/61mpMBzDc ygTeCa9NP4Z3cFWRwPcnm8JHLIFFDT4M88Ac4Wb3KT4f3193kNkJyPTVWJBri5atfZQY q2jgRpo78rbmoammQySPC2d3auoHqKyPIGm5o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yPp2bGhdeUFimOMHtTruSVnrWZkYmSmUP3HvTyAwjpA=; b=pkZGPWG7cFNZeRU+dLZeCBiwxrrEu7VCWOLh4FG1fpd2+4SIBMfbl5mWNcHXgN8zE0 4hJB9ZChy0nNwcSPybRasnHskmex/Ij6UfXbeukPtXAYRvsQ5vLi3qUIlkqADjq/Pe3R t30Ahtixh8D6BOzr+NxT1h9dh0/Apvxp3YTdqy2dBj0JtHCIJlP4OzG9KAhZx2km6yk+ PGEvAUHkmFNNclTy0pWcf2XphvcQ2KWgEFCI85ztYB6pehLYMJjIr1il6zZ3m7jz6IHw osNzwMLbiePs43go1srDHA9vkFrvpQ3SFGBZFEMnQnwQj9N4Lvos5OmIYtBeOJeGt4DD Cu2A== X-Gm-Message-State: AOAM533pYl03PyglFkUvkcZBY2Uh+UwP/CVEE/m0xk+p2eN6xh5QCeU9 gmmaidg9wUQFRIn5ePsFgpfQR7/KWM6nHw== X-Google-Smtp-Source: ABdhPJwePHWSC1Ip5wQq/XSc2V3vZFlq7OvzWZzBkhR2TRPSm41++6B5nAJFBv6+8MxqUZge0jHDQg== X-Received: by 2002:a65:4b84:0:b0:382:65ea:bb10 with SMTP id t4-20020a654b84000000b0038265eabb10mr7732532pgq.50.1648412843132; Sun, 27 Mar 2022 13:27:23 -0700 (PDT) Received: from localhost.localdomain (118-93-105-181.dsl.dyn.ihug.co.nz. [118.93.105.181]) by smtp.gmail.com with ESMTPSA id k3-20020a056a00168300b004f7e60da26csm13915466pfc.182.2022.03.27.13.27.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Mar 2022 13:27:22 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Sean Anderson , =?utf-8?q?Marek_Beh=C3=BAn?= , U-Boot Custodians , Tom Rini , AKASHI Takahiro , Simon Glass , Bin Meng , Dario Binacchi , Marek Vasut , Pavel Herrmann , Rasmus Villemoes Subject: [PATCH 09/10] RFC: dm: add tag support Date: Sun, 27 Mar 2022 14:26:21 -0600 Message-Id: <20220327202622.3438333-8-sjg@chromium.org> X-Mailer: git-send-email 2.35.1.1021.g381101b075-goog In-Reply-To: <20220327202622.3438333-1-sjg@chromium.org> References: <20220327202622.3438333-1-sjg@chromium.org> MIME-Version: 1.0 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.5 at phobos.denx.de X-Virus-Status: Clean From: AKASHI Takahiro Note: This patch is *still* pending, so it is included in this series just to make it work. With dm-tag feature, any U-Boot subsystem is allowed to associate arbitrary number of data with a particular udevice. This can been see as expanding "struct udevice" without modifying the definition. As a first user, UEFI subsystem makes use of tags to associate an efi_disk object with a block device. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass Signed-off-by: Simon Glass --- drivers/core/Makefile | 2 +- drivers/core/root.c | 2 + drivers/core/tag.c | 139 ++++++++++++++++++++++++++++++ include/asm-generic/global_data.h | 4 + include/dm/tag.h | 110 +++++++++++++++++++++++ 5 files changed, 256 insertions(+), 1 deletion(-) create mode 100644 drivers/core/tag.c create mode 100644 include/dm/tag.h diff --git a/drivers/core/Makefile b/drivers/core/Makefile index 0cbc3ab217e..7099073a533 100644 --- a/drivers/core/Makefile +++ b/drivers/core/Makefile @@ -2,7 +2,7 @@ # # Copyright (c) 2013 Google, Inc -obj-y += device.o fdtaddr.o lists.o root.o uclass.o util.o +obj-y += device.o fdtaddr.o lists.o root.o uclass.o util.o tag.o obj-$(CONFIG_$(SPL_TPL_)ACPIGEN) += acpi.o obj-$(CONFIG_$(SPL_TPL_)DEVRES) += devres.o obj-$(CONFIG_$(SPL_)DM_DEVICE_REMOVE) += device-remove.o diff --git a/drivers/core/root.c b/drivers/core/root.c index 6d1a4097e14..e09c12f4d6e 100644 --- a/drivers/core/root.c +++ b/drivers/core/root.c @@ -205,6 +205,8 @@ int dm_init(bool of_live) return ret; } + INIT_LIST_HEAD((struct list_head *)&gd->dmtag_list); + return 0; } diff --git a/drivers/core/tag.c b/drivers/core/tag.c new file mode 100644 index 00000000000..6829bcd8806 --- /dev/null +++ b/drivers/core/tag.c @@ -0,0 +1,139 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2021 Linaro Limited + * Author: AKASHI Takahiro + */ + +#include +#include +#include +#include +#include +#include + +struct udevice; + +DECLARE_GLOBAL_DATA_PTR; + +int dev_tag_set_ptr(struct udevice *dev, enum dm_tag_t tag, void *ptr) +{ + struct dmtag_node *node; + + if (!dev || tag >= DM_TAG_COUNT) + return -EINVAL; + + list_for_each_entry(node, &gd->dmtag_list, sibling) { + if (node->dev == dev && node->tag == tag) + return -EEXIST; + } + + node = calloc(sizeof(*node), 1); + if (!node) + return -ENOSPC; + + node->dev = dev; + node->tag = tag; + node->ptr = ptr; + list_add_tail(&node->sibling, (struct list_head *)&gd->dmtag_list); + + return 0; +} + +int dev_tag_set_val(struct udevice *dev, enum dm_tag_t tag, ulong val) +{ + struct dmtag_node *node; + + if (!dev || tag >= DM_TAG_COUNT) + return -EINVAL; + + list_for_each_entry(node, &gd->dmtag_list, sibling) { + if (node->dev == dev && node->tag == tag) + return -EEXIST; + } + + node = calloc(sizeof(*node), 1); + if (!node) + return -ENOSPC; + + node->dev = dev; + node->tag = tag; + node->val = val; + list_add_tail(&node->sibling, (struct list_head *)&gd->dmtag_list); + + return 0; +} + +int dev_tag_get_ptr(struct udevice *dev, enum dm_tag_t tag, void **ptrp) +{ + struct dmtag_node *node; + + if (!dev || tag >= DM_TAG_COUNT) + return -EINVAL; + + list_for_each_entry(node, &gd->dmtag_list, sibling) { + if (node->dev == dev && node->tag == tag) { + *ptrp = node->ptr; + return 0; + } + } + + return -ENOENT; +} + +int dev_tag_get_val(struct udevice *dev, enum dm_tag_t tag, ulong *valp) +{ + struct dmtag_node *node; + + if (!dev || tag >= DM_TAG_COUNT) + return -EINVAL; + + list_for_each_entry(node, &gd->dmtag_list, sibling) { + if (node->dev == dev && node->tag == tag) { + *valp = node->val; + return 0; + } + } + + return -ENOENT; +} + +int dev_tag_del(struct udevice *dev, enum dm_tag_t tag) +{ + struct dmtag_node *node, *tmp; + + if (!dev || tag >= DM_TAG_COUNT) + return -EINVAL; + + list_for_each_entry_safe(node, tmp, &gd->dmtag_list, sibling) { + if (node->dev == dev && node->tag == tag) { + list_del(&node->sibling); + free(node); + + return 0; + } + } + + return -ENOENT; +} + +int dev_tag_del_all(struct udevice *dev) +{ + struct dmtag_node *node, *tmp; + bool found = false; + + if (!dev) + return -EINVAL; + + list_for_each_entry_safe(node, tmp, &gd->dmtag_list, sibling) { + if (node->dev == dev) { + list_del(&node->sibling); + free(node); + found = true; + } + } + + if (found) + return 0; + + return -ENOENT; +} diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h index e49f5bf2f7d..59bd6804368 100644 --- a/include/asm-generic/global_data.h +++ b/include/asm-generic/global_data.h @@ -474,6 +474,10 @@ struct global_data { */ struct event_state event_state; #endif + /** + * @dmtag_list: List of DM tags + */ + struct list_head dmtag_list; }; #ifndef DO_DEPS_ONLY static_assert(sizeof(struct global_data) == GD_SIZE); diff --git a/include/dm/tag.h b/include/dm/tag.h new file mode 100644 index 00000000000..54fc31eb153 --- /dev/null +++ b/include/dm/tag.h @@ -0,0 +1,110 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (c) 2021 Linaro Limited + * Author: AKASHI Takahiro + */ + +#ifndef _DM_TAG_H +#define _DM_TAG_H + +#include +#include + +struct udevice; + +enum dm_tag_t { + /* EFI_LOADER */ + DM_TAG_EFI = 0, + + DM_TAG_COUNT, +}; + +/** + * dmtag_node + * + * @sibling: List of dm-tag nodes + * @dev: Associated udevice + * @tag: Tag type + * @ptr: Pointer as a value + * @val: Value + */ +struct dmtag_node { + struct list_head sibling; + struct udevice *dev; + enum dm_tag_t tag; + union { + void *ptr; + ulong val; + }; +}; + +/** + * dev_tag_set_ptr() - set a tag's value as a pointer + * @dev: Device to operate + * @tag: Tag type + * @ptr: Pointer to set + * + * Set the value, @ptr, as of @tag associated with the device, @dev + * + * Return: 0 on success, -ve on error + */ +int dev_tag_set_ptr(struct udevice *dev, enum dm_tag_t tag, void *ptr); + +/** + * dev_tag_set_val() set a tag's value as an integer + * @dev: Device to operate + * @tag: Tag type + * @val: Value to set + * + * Set the value, @val, as of @tag associated with the device, @dev + * + * Return: on success, -ve on error + */ +int dev_tag_set_val(struct udevice *dev, enum dm_tag_t tag, ulong val); + +/** + * dev_tag_get_ptr() - get a tag's value as a pointer + * @dev: Device to operate + * @tag: Tag type + * @ptrp: Pointer to tag's value (pointer) + * + * Get a tag's value as a pointer + * + * Return: on success, -ve on error + */ +int dev_tag_get_ptr(struct udevice *dev, enum dm_tag_t tag, void **ptrp); + +/** + * dev_tag_get_val() - get a tag's value as an integer + * @dev: Device to operate + * @tag: Tag type + * @valp: Pointer to tag's value (ulong) + * + * Get a tag's value as an integer + * + * Return: 0 on success, -ve on error + */ +int dev_tag_get_val(struct udevice *dev, enum dm_tag_t tag, ulong *valp); + +/** + * dev_tag_del() - delete a tag + * @dev: Device to operate + * @tag: Tag type + * + * Delete a tag of @tag associated with the device, @dev + * + * Return: 0 on success, -ve on error + */ +int dev_tag_del(struct udevice *dev, enum dm_tag_t tag); + +/** + * dev_tag_del_all() - delete all tags + * @dev: Device to operate + * + * Delete all the tags associated with the device, @dev + * + * Return: 0 on success, -ve on error + */ +int dev_tag_del_all(struct udevice *dev); + +#endif /* _DM_TAG_H */ From patchwork Sun Mar 27 20:26:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1609942 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=YHngAL7h; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KRS8k28fcz9sG6 for ; Mon, 28 Mar 2022 07:28:54 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3B46A83AF9; Sun, 27 Mar 2022 22:28:02 +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="YHngAL7h"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 43BB68398D; Sun, 27 Mar 2022 22:27:49 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) (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 2766F83A8A for ; Sun, 27 Mar 2022 22:27:31 +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-pg1-x534.google.com with SMTP id z128so10689030pgz.2 for ; Sun, 27 Mar 2022 13:27:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0Yzvo8MGTyRU2H+izPK3YGKYCDxpJOZdPHepA/p/L0U=; b=YHngAL7h8PSzqtRrweeudgAlxQEECNcFHjlSK4aAAmtRH4FEOOCtAGt8lvZsAxOYs3 8qRjWV+xMZi2yatRTYj1QXsOgYFfQ4kt4WDETSkhfzPDB/lkum+OhsiqJQ/NW+yZlxJN /t9zquNkz1D0oyTeLODr5bPigfyxxvSDcYD9A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0Yzvo8MGTyRU2H+izPK3YGKYCDxpJOZdPHepA/p/L0U=; b=6vXR5rwjDxu05glkGikv7f7uQYvW9UjDryWvQRSgacArXycBzpfhWuK0pT7TvBpN25 MdRbsVUtGQD7yKDgh6jmZmeDJCkScF/tAs+KUO1ORmYPAO6YIzU5goJtCmdCUeMboF6E W4cZaikBmOrKgV8Q0zhnmIMXTERWfMx2mEPD9vL1MB2LP/GXat9AJdzDJP9uCqfI1sha cDQvB2w69lhXxCT09uiM8Pu4tqs5rXcE2nb//cfnNJrfMHWSCR2KXmLAZ1Q28SL6Ywmk DvieZYkYT87Rzv7F/LFMluhGGkRaN9oKZ/Ks0KfIU38RFykeUg+IMENMLJZckrUAbNfn 5Guw== X-Gm-Message-State: AOAM531et7sXVXWVaieCg+ehDDw2L3CzOePblg9fPsEZhCvTQeT1PLpr KrPlNPHCCuHmQ4MRfGNmac9eTKD4+7PT6A== X-Google-Smtp-Source: ABdhPJzS0VWu8rfTHc/0GbABB4zGYhvbhA1uTAarOjr25hsBiPBYlH6cYFcwnZxDQaJNEOvU500Ebg== X-Received: by 2002:a62:5fc4:0:b0:4fa:7a4b:3853 with SMTP id t187-20020a625fc4000000b004fa7a4b3853mr20354079pfb.77.1648412849186; Sun, 27 Mar 2022 13:27:29 -0700 (PDT) Received: from localhost.localdomain (118-93-105-181.dsl.dyn.ihug.co.nz. [118.93.105.181]) by smtp.gmail.com with ESMTPSA id k3-20020a056a00168300b004f7e60da26csm13915466pfc.182.2022.03.27.13.27.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Mar 2022 13:27:28 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Sean Anderson , =?utf-8?q?Marek_Beh=C3=BAn?= , U-Boot Custodians , Tom Rini , Simon Glass , Alexandru Gagniuc , Marek Vasut , =?utf-8?q?Pali_Roh=C3=A1r?= , Pavel Herrmann , Ricardo Salveti , Stefan Roese Subject: [PATCH 10/10] WIP: dm: core: Add a command to calculate memory usage Date: Sun, 27 Mar 2022 14:26:22 -0600 Message-Id: <20220327202622.3438333-9-sjg@chromium.org> X-Mailer: git-send-email 2.35.1.1021.g381101b075-goog In-Reply-To: <20220327202622.3438333-1-sjg@chromium.org> References: <20220327202622.3438333-1-sjg@chromium.org> MIME-Version: 1.0 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.5 at phobos.denx.de X-Virus-Status: Clean Driver model can use a lot of memory, as it is the core of all drivers and devices in U-Boot. Add a command to show how much is in use, along with the sizes of various data structures. This patch can be used to analyse the impact of various potential changes to driver model for SPL, none of which has been implemented. Most involve shrinking the size of struct udevice, which is a particular problem on 64-bit machines since their pointers are so unnecessarily large in SPL. To try this out, build and run on your board. You should see output for SPL and U-Boot proper, like this: Struct sizes: udevice 90, driver 78, uclass 30, uc_driver 78 Memory: device 11:990, device names 111, uclass a:1e0 Attached type Count Size Cur Tags Save --------------- ----- ----- ----- ----- ----- plat 3 e0 990 914 7c (124) parent_plat 2 40 990 910 80 (128) uclass_plat 1 10 990 90c 84 (132) priv 6 13d 990 920 70 (112) parent_priv 0 0 990 908 88 (136) uclass_priv 3 38 990 914 7c (124) driver_data 0 0 990 908 88 (136) uclass 0 0 Attached total f 2a5 37c (892) tags 0 0 Total size: e15 (3605) With tags: a99 (2713) - singly-linked: 901 (2305) - driver index: 88a (2186) - uclass index: 813 (2067) Drop device name (not SRAM): 111 (273) Signed-off-by: Simon Glass --- cmd/dm.c | 15 ++++++++- common/spl/spl.c | 9 ++++++ drivers/core/device.c | 65 ++++++++++++++++++++++++++++++++++++++ drivers/core/dump.c | 73 +++++++++++++++++++++++++++++++++++++++++++ drivers/core/root.c | 53 +++++++++++++++++++++++++++++++ drivers/core/tag.c | 29 +++++++++++++++++ include/dm/device.h | 6 ++++ include/dm/root.h | 45 ++++++++++++++++++++++++++ include/dm/tag.h | 18 ++++++++++- include/dm/util.h | 9 ++++++ 10 files changed, 320 insertions(+), 2 deletions(-) diff --git a/cmd/dm.c b/cmd/dm.c index 1dd19fe45b5..ec32a13b177 100644 --- a/cmd/dm.c +++ b/cmd/dm.c @@ -64,6 +64,17 @@ static int do_dm_dump_static_driver_info(struct cmd_tbl *cmdtp, int flag, int ar return 0; } +static int do_dm_dump_mem(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct dm_stats mem; + + dm_get_mem(&mem); + dm_dump_mem(&mem); + + return 0; +} + static struct cmd_tbl test_commands[] = { U_BOOT_CMD_MKENT(tree, 0, 1, do_dm_dump_all, "", ""), U_BOOT_CMD_MKENT(uclass, 1, 1, do_dm_dump_uclass, "", ""), @@ -71,6 +82,7 @@ static struct cmd_tbl test_commands[] = { U_BOOT_CMD_MKENT(drivers, 1, 1, do_dm_dump_drivers, "", ""), U_BOOT_CMD_MKENT(compat, 1, 1, do_dm_dump_driver_compat, "", ""), U_BOOT_CMD_MKENT(static, 1, 1, do_dm_dump_static_driver_info, "", ""), + U_BOOT_CMD_MKENT(mem, 1, 1, do_dm_dump_mem, "", ""), }; static __maybe_unused void dm_reloc(void) @@ -114,5 +126,6 @@ U_BOOT_CMD( "dm devres Dump list of device resources for each device\n" "dm drivers Dump list of drivers with uclass and instances\n" "dm compat Dump list of drivers with compatibility strings\n" - "dm static Dump list of drivers with static platform data" + "dm static Dump list of drivers with static platform data\n" + "dm mem Provide a summary of memory usage" ); diff --git a/common/spl/spl.c b/common/spl/spl.c index b452d4feeb2..3182f774f13 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -743,6 +744,14 @@ void board_init_r(gd_t *dummy1, ulong dummy2) } } + /* Dump drive model states to aid analysis */ + if (1) { + struct dm_stats mem; + + dm_get_mem(&mem); + dm_dump_mem(&mem); + } + #if CONFIG_IS_ENABLED(BOARD_INIT) spl_board_init(); #endif diff --git a/drivers/core/device.c b/drivers/core/device.c index 3ab2583df38..5d9dca8a81f 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -680,6 +680,71 @@ void *dev_get_parent_priv(const struct udevice *dev) return dm_priv_to_rw(dev->parent_priv_); } +void *dev_get_attach(const struct udevice *dev, enum dm_tag_t tag) +{ + switch (tag) { + case DM_TAG_PLAT: + return dev_get_plat(dev); + case DM_TAG_PARENT_PLAT: + return dev_get_parent_plat(dev); + case DM_TAG_UC_PLAT: + return dev_get_uclass_plat(dev); + case DM_TAG_PRIV: + return dev_get_priv(dev); + case DM_TAG_PARENT_PRIV: + return dev_get_parent_priv(dev); + case DM_TAG_UC_PRIV: + return dev_get_uclass_priv(dev); + default: + return NULL; + } +} + +int dev_get_attach_size(const struct udevice *dev, enum dm_tag_t tag) +{ + const struct udevice *parent = dev_get_parent(dev); + const struct uclass *uc = dev->uclass; + const struct uclass_driver *uc_drv = uc->uc_drv; + const struct driver *parent_drv = NULL; + int size = 0; + + if (parent) + parent_drv = parent->driver; + + switch (tag) { + case DM_TAG_PLAT: + size = dev->driver->plat_auto; + break; + case DM_TAG_PARENT_PLAT: + if (parent) { + size = parent_drv->per_child_plat_auto; + if (!size) + size = parent->uclass->uc_drv->per_child_plat_auto; + } + break; + case DM_TAG_UC_PLAT: + size = uc_drv->per_device_plat_auto; + break; + case DM_TAG_PRIV: + size = dev->driver->priv_auto; + break; + case DM_TAG_PARENT_PRIV: + if (parent) { + size = parent_drv->per_child_auto; + if (!size) + size = parent->uclass->uc_drv->per_child_auto; + } + break; + case DM_TAG_UC_PRIV: + size = uc_drv->per_device_auto; + break; + default: + break; + } + + return size; +} + static int device_get_device_tail(struct udevice *dev, int ret, struct udevice **devp) { diff --git a/drivers/core/dump.c b/drivers/core/dump.c index f2f9cacc56c..5e51d06787a 100644 --- a/drivers/core/dump.c +++ b/drivers/core/dump.c @@ -176,3 +176,76 @@ void dm_dump_static_driver_info(void) (ulong)map_to_sysmem(entry->plat)); } } + +void dm_dump_mem(struct dm_stats *stats) +{ + int total, total_delta; + int i; + + /* Support SPL printf() */ + printf("Struct sizes: udevice %x, driver %x, uclass %x, uc_driver %x\n", + (int)sizeof(struct udevice), (int)sizeof(struct driver), + (int)sizeof(struct uclass), (int)sizeof(struct uclass_driver)); + printf("Memory: device %x:%x, device names %x, uclass %x:%x\n", + stats->dev_count, stats->dev_size, stats->dev_name_size, + stats->uc_count, stats->uc_size); + printf("\n"); + printf("%-15s %5s %5s %5s %5s %5s\n", "Attached type", "Count", + "Size", "Cur", "Tags", "Save"); + printf("%-15s %5s %5s %5s %5s %5s\n", "---------------", "-----", + "-----", "-----", "-----", "-----"); + total_delta = 0; + for (i = 0; i < DM_TAG_ATTACH_COUNT; i++) { + int cur_size, new_size, delta; + + cur_size = stats->dev_count * sizeof(struct udevice); + new_size = stats->dev_count * (sizeof(struct udevice) - + sizeof(void *)); + /* + * Let's assume we can fit each dmtag_node into 32 bits. We can + * limit the 'tiny tags' feature to SPL with + * CONFIG_SPL_SYS_MALLOC_F_LEN <= 64KB, so needing 14 bits to + * point to anything in that region (with 4-byte alignment). + * So: + * 4 bits for tag + * 14 bits for offset of dev + * 14 bits for offset of data + */ + new_size += stats->attach_count[i] * sizeof(u32); + delta = cur_size - new_size; + total_delta += delta; + printf("%-16s %5x %6x %6x %6x %6x (%d)\n", tag_get_name(i), + stats->attach_count[i], stats->attach_size[i], + cur_size, new_size, delta > 0 ? delta : 0, delta); + } + printf("%-16s %5x %6x\n", "uclass", stats->uc_attach_count, + stats->uc_attach_size); + printf("%-16s %5x %6x %5s %5s %6x (%d)\n", "Attached total", + stats->attach_count_total + stats->uc_attach_count, + stats->attach_size_total + stats->uc_attach_size, "", "", + total_delta > 0 ? total_delta : 0, total_delta); + printf("%-16s %5x %6x\n", "tags", stats->tag_count, stats->tag_size); + printf("\n"); + printf("Total size: %x (%d)\n", stats->total_size, stats->total_size); + printf("\n"); + + total = stats->total_size; + total -= total_delta; + printf("With tags: %x (%d)\n", total, total); + + /* Use singly linked lists in struct udevice (3 nodes in each) */ + total -= sizeof(void *) * 3 * stats->dev_count; + printf("- singly-linked: %x (%d)\n", total, total); + + /* Use an index into the struct_driver list instead of a pointer */ + total = total + stats->dev_count * (1 - sizeof(void *)); + printf("- driver index: %x (%d)\n", total, total); + + /* Same with the uclass */ + total = total + stats->dev_count * (1 - sizeof(void *)); + printf("- uclass index: %x (%d)\n", total, total); + + /* Drop the device name */ + printf("Drop device name (not SRAM): %x (%d)\n", stats->dev_name_size, + stats->dev_name_size); +} diff --git a/drivers/core/root.c b/drivers/core/root.c index e09c12f4d6e..4f83cb2b557 100644 --- a/drivers/core/root.c +++ b/drivers/core/root.c @@ -427,6 +427,59 @@ void dm_get_stats(int *device_countp, int *uclass_countp) *uclass_countp = uclass_get_count(); } +void dev_collect_stats(struct dm_stats *stats, const struct udevice *parent) +{ + const struct udevice *dev; + int i; + + stats->dev_count++; + stats->dev_size += sizeof(struct udevice); + stats->dev_name_size += strlen(parent->name) + 1; + for (i = 0; i < DM_TAG_ATTACH_COUNT; i++) { + int size = dev_get_attach_size(parent, i); + + if (size || + (i == DM_TAG_DRIVER_DATA && parent->driver_data)) { + stats->attach_count[i]++; + stats->attach_size[i] += size; + stats->attach_count_total++; + stats->attach_size_total += size; + } + } + + list_for_each_entry(dev, &parent->child_head, sibling_node) + dev_collect_stats(stats, dev); +} + +void uclass_collect_stats(struct dm_stats *stats) +{ + struct uclass *uc; + + list_for_each_entry(uc, gd->uclass_root, sibling_node) { + int size; + + stats->uc_count++; + stats->uc_size += sizeof(struct uclass); + size = uc->uc_drv->priv_auto; + if (size) { + stats->uc_attach_count++; + stats->uc_attach_size += size; + } + } +} + +void dm_get_mem(struct dm_stats *stats) +{ + memset(stats, '\0', sizeof(*stats)); + dev_collect_stats(stats, gd->dm_root); + uclass_collect_stats(stats); + dev_tag_collect_stats(stats); + + stats->total_size = stats->dev_size + stats->uc_size + + stats->attach_size_total + stats->uc_attach_size + + stats->tag_size; +} + #ifdef CONFIG_ACPIGEN static int root_acpi_get_name(const struct udevice *dev, char *out_name) { diff --git a/drivers/core/tag.c b/drivers/core/tag.c index 6829bcd8806..d8042fa2c5b 100644 --- a/drivers/core/tag.c +++ b/drivers/core/tag.c @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -15,6 +16,24 @@ struct udevice; DECLARE_GLOBAL_DATA_PTR; +static const char *const tag_name[] = { + [DM_TAG_PLAT] = "plat", + [DM_TAG_PARENT_PLAT] = "parent_plat", + [DM_TAG_UC_PLAT] = "uclass_plat", + + [DM_TAG_PRIV] = "priv", + [DM_TAG_PARENT_PRIV] = "parent_priv", + [DM_TAG_UC_PRIV] = "uclass_priv", + [DM_TAG_DRIVER_DATA] = "driver_data", + + [DM_TAG_EFI] = "efi", +}; + +const char *tag_get_name(enum dm_tag_t tag) +{ + return tag_name[tag]; +} + int dev_tag_set_ptr(struct udevice *dev, enum dm_tag_t tag, void *ptr) { struct dmtag_node *node; @@ -137,3 +156,13 @@ int dev_tag_del_all(struct udevice *dev) return -ENOENT; } + +void dev_tag_collect_stats(struct dm_stats *stats) +{ + struct dmtag_node *node; + + list_for_each_entry(node, &gd->dmtag_list, sibling) { + stats->tag_count++; + stats->tag_size += sizeof(struct dmtag_node); + } +} diff --git a/include/dm/device.h b/include/dm/device.h index e0f86f5df9f..d8193900b12 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -11,6 +11,7 @@ #define _DM_DEVICE_H #include +#include #include #include #include @@ -18,6 +19,7 @@ #include #include +struct dm_stats; struct driver_info; /* Driver is active (probed). Cleared when it is removed */ @@ -543,6 +545,10 @@ void *dev_get_parent_priv(const struct udevice *dev); */ void *dev_get_uclass_priv(const struct udevice *dev); +void *dev_get_attach(const struct udevice *dev, enum dm_tag_t tag); + +int dev_get_attach_size(const struct udevice *dev, enum dm_tag_t tag); + /** * dev_get_parent() - Get the parent of a device * diff --git a/include/dm/root.h b/include/dm/root.h index e888fb993c0..382f83c7f5b 100644 --- a/include/dm/root.h +++ b/include/dm/root.h @@ -9,11 +9,49 @@ #ifndef _DM_ROOT_H_ #define _DM_ROOT_H_ +#include + struct udevice; /* Head of the uclass list if CONFIG_OF_PLATDATA_INST is enabled */ extern struct list_head uclass_head; +/** + * struct dm_stats - Information about driver model memory usage + * + * @total_size: All data + * @dev_count: Number of devices + * @dev_size: Size of all devices (just the struct udevice) + * @dev_name_size: Bytes used by device names + * @uc_count: Number of uclasses + * @uc_size: Size of all uclasses (just the struct uclass) + * @tag_count: Number of tags + * @tag_size: Bytes used by all tags + * @uc_attach_count: Number of uclasses with attached data (priv) + * @uc_attach_size: Total size of that attached data + * @attach_count_total: Total number of attached data items for all udevices and + * uclasses + * @attach_size_total: Total number of bytes of attached data + * @attach_count: Number of devices with attached, for each type + * @attach_size: Total number of bytes of attached data, for each type + */ +struct dm_stats { + int total_size; + int dev_count; + int dev_size; + int dev_name_size; + int uc_count; + int uc_size; + int tag_count; + int tag_size; + int uc_attach_count; + int uc_attach_size; + int attach_count_total; + int attach_size_total; + int attach_count[DM_TAG_ATTACH_COUNT]; + int attach_size[DM_TAG_ATTACH_COUNT]; +}; + /** * dm_root() - Return pointer to the top of the driver tree * @@ -141,4 +179,11 @@ static inline int dm_remove_devices_flags(uint flags) { return 0; } */ void dm_get_stats(int *device_countp, int *uclass_countp); +/** + * dm_get_mem() - Get stats on memory usage in driver model + * + * @mem: Place to put the information + */ +void dm_get_mem(struct dm_stats *stats); + #endif diff --git a/include/dm/tag.h b/include/dm/tag.h index 54fc31eb153..3b1ea7576ee 100644 --- a/include/dm/tag.h +++ b/include/dm/tag.h @@ -10,11 +10,23 @@ #include #include +struct dm_stats; struct udevice; enum dm_tag_t { + /* Types of info that can be attached to devices */ + DM_TAG_PLAT, + DM_TAG_PARENT_PLAT, + DM_TAG_UC_PLAT, + + DM_TAG_PRIV, + DM_TAG_PARENT_PRIV, + DM_TAG_UC_PRIV, + DM_TAG_DRIVER_DATA, + DM_TAG_ATTACH_COUNT, + /* EFI_LOADER */ - DM_TAG_EFI = 0, + DM_TAG_EFI = DM_TAG_ATTACH_COUNT, DM_TAG_COUNT, }; @@ -107,4 +119,8 @@ int dev_tag_del(struct udevice *dev, enum dm_tag_t tag); */ int dev_tag_del_all(struct udevice *dev); +const char *tag_get_name(enum dm_tag_t tag); + +void dev_tag_collect_stats(struct dm_stats *stats); + #endif /* _DM_TAG_H */ diff --git a/include/dm/util.h b/include/dm/util.h index 4428f045b72..b346ecfe042 100644 --- a/include/dm/util.h +++ b/include/dm/util.h @@ -6,6 +6,8 @@ #ifndef __DM_UTIL_H #define __DM_UTIL_H +struct dm_stats; + #if CONFIG_IS_ENABLED(DM_WARN) #define dm_warn(fmt...) log(LOGC_DM, LOGL_WARNING, ##fmt) #else @@ -48,6 +50,13 @@ void dm_dump_driver_compat(void); /* Dump out a list of drivers with static platform data */ void dm_dump_static_driver_info(void); +/** + * dm_dump_mem() - Dump stats on memory usage in driver model + * + * @mem: Stats to dump + */ +void dm_dump_mem(struct dm_stats *stats); + #if CONFIG_IS_ENABLED(OF_PLATDATA_INST) && CONFIG_IS_ENABLED(READ_ONLY) void *dm_priv_to_rw(void *priv); #else