From patchwork Thu Apr 8 16:56:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Gagniuc X-Patchwork-Id: 1463920 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=c/0WwoDP; dkim-atps=neutral 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) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FGS930rFjz9sCD for ; Fri, 9 Apr 2021 02:56:37 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 343AA80C64; Thu, 8 Apr 2021 18:56:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="c/0WwoDP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 942AC80C67; Thu, 8 Apr 2021 18:56:21 +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.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ot1-x332.google.com (mail-ot1-x332.google.com [IPv6:2607:f8b0:4864:20::332]) (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 1203780475 for ; Thu, 8 Apr 2021 18:56:18 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=mr.nuke.me@gmail.com Received: by mail-ot1-x332.google.com with SMTP id s11-20020a056830124bb029021bb3524ebeso3014527otp.0 for ; Thu, 08 Apr 2021 09:56:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=vFMov1V8jJBlyw6pwDtUli3Pt7wKqkq40SLxuk1FNzQ=; b=c/0WwoDP2xKjxYXK8B6pNBTyNz+/+JrcsE3WggppZoLey83Lj+jmlPx66XnxT6SreJ 4Ytf+Bp6IW1nVOEoUOmiXeA5nfglS6tC2HFh3Nip12LK5MmAEptdQ5+UVzWSzU8UF/y3 mvqBASYD5aiwgnutGc4fLQesDyOb6iTzZgOagBYRUj9hNfN2IITWd2WtN5xXlzlRdB3N bEvOe/lMW0Pjpwh5oTIrW5JuCMAgwKqNa7ckyjVujqInWr2YClgxc5ryAFqHH6iGVZIS NLX3terT3BLyTbNai9QQnXq/ZlSPgTgVu7fHPQFKvZz1yhTav+gqYAqSxRoYV1FSVQQq +/uA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=vFMov1V8jJBlyw6pwDtUli3Pt7wKqkq40SLxuk1FNzQ=; b=cpljmKgAeRr5gE3TIr0gfxfCV2Vyxv2gJMjyqD9cMVlyMTbBUuv9L4w6bFQoCsEIK2 RCtzptpFQckxmAd+hjKVeWPhsjS2CpRdRVPkQL7oCrjw3fXSAnUjmQCB3M8tL8ifdm2f Kymgt0Cdri/eZI0t6VplCaJA3q4ttG6STk6Ut+1YD4hjCv2mRsVlxf6x0CvHyt0HBwrn 0v2bPV1nziL4KjDzdsJPxuu3UYLIuFzeUaIplbrhPiKXLl5k9izffg8LAs37IZYSBf0Y Go9Fq9kUYRaXC3vf2eZPojd1WxkUrwXotdpRok4Yatbg5BaJt8pz4UMHSs2ESSICLPSl BnNQ== X-Gm-Message-State: AOAM531xIfVxYlKOlNrUomNNvhe8EjUdFbkIUhoz1F9DLcWHCPryAB0N bJOzgaGJyCtGAYwxLIS67RaPno3DyQ59tw== X-Google-Smtp-Source: ABdhPJyJWWXY1/MHoFb4ntE3NB34R7W+fQPG/sytxgzpOv8JD3nLcdsUGia229DQxTrU4o4uF0esng== X-Received: by 2002:a05:6830:4001:: with SMTP id h1mr8164582ots.159.1617900975230; Thu, 08 Apr 2021 09:56:15 -0700 (PDT) Received: from nuclearis2-1.gtech (c-98-195-139-126.hsd1.tx.comcast.net. [98.195.139.126]) by smtp.gmail.com with ESMTPSA id y11sm6501957ots.80.2021.04.08.09.56.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Apr 2021 09:56:14 -0700 (PDT) From: Alexandru Gagniuc To: u-boot@lists.denx.de, sjg@chromium.org, trini@konsulko.com Cc: Alexandru Gagniuc Subject: [PATCH] Revert "spl: Drop bd_info in the data section" Date: Thu, 8 Apr 2021 11:56:11 -0500 Message-Id: <20210408165611.1195887-1-mr.nuke.me@gmail.com> X-Mailer: git-send-email 2.26.3 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.4 at phobos.denx.de X-Virus-Status: Clean This reverts commit 38d6b7ebdaee3e0e8426ef1b9df88bdce8ae2e75. struct global_data contains a pointer to the bd_info structure. This pointer was populated spl_set_bd() to a pre-allocated bd_info in the ".data" section. The referenced commit replaced this mechanism to one that uses malloc(). That new mechanism is only used if SPL_ALLOC_BD=y. which very few boards do. The result is that (struct global_data)->bd is NULL in SPL on most platforms. This breaks falcon mode, since arch_fixup_fdt() tries to access (struct global_data)->bd and set the "/memory" node in the devicetree. The result is that the "/memory" node contains garbage values, causing linux to panic() as it sets up the page table. Instead of trying to fix the mess, potentially causing other issues, revert to the code that worked, while this change is reworked. Signed-off-by: Alexandru Gagniuc --- arch/arm/cpu/armv8/fsl-layerscape/spl.c | 5 +---- common/spl/Kconfig | 9 --------- common/spl/spl.c | 20 ++++++++------------ include/spl.h | 10 +--------- 4 files changed, 10 insertions(+), 34 deletions(-) diff --git a/arch/arm/cpu/armv8/fsl-layerscape/spl.c b/arch/arm/cpu/armv8/fsl-layerscape/spl.c index d5131bcf4b..7d594a9f74 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/spl.c +++ b/arch/arm/cpu/armv8/fsl-layerscape/spl.c @@ -39,9 +39,6 @@ u32 spl_boot_device(void) #ifdef CONFIG_SPL_BUILD -/* Define board data structure */ -static struct bd_info bdata __attribute__ ((section(".data"))); - void spl_board_init(void) { #if defined(CONFIG_NXP_ESBC) && defined(CONFIG_FSL_LSCH2) @@ -78,7 +75,7 @@ void board_init_f(ulong dummy) get_clocks(); preloader_console_init(); - gd->bd = &bdata; + spl_set_bd(); #ifdef CONFIG_SYS_I2C #ifdef CONFIG_SPL_I2C_SUPPORT diff --git a/common/spl/Kconfig b/common/spl/Kconfig index 0711cbf951..75b4f45c01 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -113,15 +113,6 @@ config SPL_FSL_PBL Create boot binary having SPL binary in PBI format concatenated with u-boot binary. -config SPL_ALLOC_BD - bool "Allocate memory for bd_info" - default y if X86 || SANDBOX - help - Some boards don't allocate space for this in their board_init_f() - code. In this case U-Boot can allocate space for gd->bd in the - standard SPL flow (board_init_r()). Enable this option to support - this feature. - endmenu config HANDOFF diff --git a/common/spl/spl.c b/common/spl/spl.c index 556a91ab53..fb37d71959 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -55,6 +55,9 @@ binman_sym_declare(ulong, spl, image_pos); binman_sym_declare(ulong, spl, size); #endif +/* Define board data structure */ +static struct bd_info bdata __attribute__ ((section(".data"))); + /* * Board-specific Platform code can reimplement show_boot_progress () if needed */ @@ -464,19 +467,14 @@ static int spl_common_init(bool setup_malloc) return 0; } -int spl_alloc_bd(void) +void spl_set_bd(void) { /* * NOTE: On some platforms (e.g. x86) bdata may be in flash and not * writeable. */ - if (!gd->bd) { - gd->bd = malloc(sizeof(*gd->bd)); - if (!gd->bd) - return -ENOMEM; - } - - return 0; + if (!gd->bd) + gd->bd = &bdata; } int spl_early_init(void) @@ -626,6 +624,8 @@ void board_init_r(gd_t *dummy1, ulong dummy2) debug(">>" SPL_TPL_PROMPT "board_init_r()\n"); + spl_set_bd(); + #if defined(CONFIG_SYS_SPL_MALLOC_START) mem_malloc_init(CONFIG_SYS_SPL_MALLOC_START, CONFIG_SYS_SPL_MALLOC_SIZE); @@ -635,10 +635,6 @@ void board_init_r(gd_t *dummy1, ulong dummy2) if (spl_init()) hang(); } - if (IS_ENABLED(CONFIG_SPL_ALLOC_BD) && spl_alloc_bd()) { - puts("Cannot alloc bd\n"); - hang(); - } #if !defined(CONFIG_PPC) && !defined(CONFIG_ARCH_MX6) /* * timer_init() does not exist on PPC systems. The timer is initialized diff --git a/include/spl.h b/include/spl.h index 4f6e0e53f5..cee9a42ddb 100644 --- a/include/spl.h +++ b/include/spl.h @@ -357,15 +357,7 @@ u32 spl_mmc_boot_mode(const u32 boot_device); * If not overridden, it is weakly defined in common/spl/spl_mmc.c. */ int spl_mmc_boot_partition(const u32 boot_device); - -/** - * spl_alloc_bd() - Allocate space for bd_info - * - * This sets up the gd->bd pointer by allocating memory for it - * - * @return 0 if OK, -ENOMEM if out of memory - */ -int spl_alloc_bd(void); +void spl_set_bd(void); /** * spl_set_header_raw_uboot() - Set up a standard SPL image structure