From patchwork Sun Aug 15 18:13:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1516940 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=85.214.62.61; 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=WX8ZAmbf; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4Gnlrt706Xz9sX3 for ; Mon, 16 Aug 2021 04:17:50 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EAEB682E4C; Sun, 15 Aug 2021 20:17:27 +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="WX8ZAmbf"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6491B82E4C; Sun, 15 Aug 2021 20:17: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-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) (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 A5C348200B for ; Sun, 15 Aug 2021 20:17:13 +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=marek.vasut@gmail.com Received: by mail-wm1-x335.google.com with SMTP id k4so10195323wms.3 for ; Sun, 15 Aug 2021 11:17:13 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=HyjbR9XyBam7OtPiZDZRn0PlrV6rKfJA19hqytM8Zxs=; b=WX8ZAmbfgjpzDv/xsOrCjOJjnn6EgHSwpyW5tLN6QJqEIPCL/Gf3EOVcc+ZsG0CA6V fDdi+NrqUxuy22+JRHHeL9VV/SnOS18BAO+n2HH9hyt6iXpdklpJ8FmHn88Tpx1ToMKN PS6r3Iw0gneLM540on71jT2dl2Em8UsGGQrDWB6HFv/DkKWWMf0f4Asj901ruIKfH5cv wxIFg4ifhhBou+CS39gDyTmMujX2MElLzR0vCQJTNtbZE3VoIUWhFlPONjjzaQottA// XlZdsHtCqMB/9adTm/CcxOVtEw3ZY3rADEi+bLTR9bZOnS9bW1gXDFN+jo1mvEtP0wX8 T4gQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=HyjbR9XyBam7OtPiZDZRn0PlrV6rKfJA19hqytM8Zxs=; b=HrlVf/iCgTBOia/wypr8SJVJtqndqg7U1ki7vWtHBTFwWIUCwj32sU6hGSLp/NObVn 20TupfH4LIBXkSC82AgwskgVGGaeMxdfGe11QpQDbUK7PyAHrWDYWqj/ea0NzYRPjxmy Gx+IuQGIIVay3wbgYV2F5xoQq2AvwW1/NsbaOtufBO4OMm70ACG6tkYHWbzBM3T0hqeE D3Jn0D7jMwKzEohPmB6JcqZ3XEy5aU6ai3WzgCd2MRRoijN+TJ3B6FoQ5oMqKc6IH365 HGLGnezYuFYFaK4tWP5NOfaVqjZdfzKtaRtQ9b5mY2c7sAnl093ykA0ylyHRnzCjsDPu Rpjg== X-Gm-Message-State: AOAM5300EjnEu7YRaOSWpzGPQ4SYx5mUqkv9BwGKzOF1MZWqqVKz2yWL RpcGtdcsXtEUf3P8PViZ5uQwRTTLjB4F+g== X-Google-Smtp-Source: ABdhPJzyPAz3svUvG22lZ+7HvWznzLGl7inF6s2YpKzIh4ttYShPGaGZ96SQ9RC6u5p7bVTv9ssIYA== X-Received: by 2002:a05:600c:2297:: with SMTP id 23mr12054403wmf.64.1629051433264; Sun, 15 Aug 2021 11:17:13 -0700 (PDT) Received: from tr.lan (ip-89-176-112-137.net.upcbroadband.cz. [89.176.112.137]) by smtp.gmail.com with ESMTPSA id i8sm5920343wrv.70.2021.08.15.11.17.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Aug 2021 11:17:12 -0700 (PDT) From: Marek Vasut X-Google-Original-From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Simon Glass , Simon Goldschmidt , Tom Rini Subject: [PATCH 03/14] lmb: Always compile arch_lmb_reserve() into U-Boot on arm Date: Sun, 15 Aug 2021 20:13:03 +0200 Message-Id: <20210815181314.132330-3-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210815181314.132330-1-marek.vasut+renesas@gmail.com> References: <20210815181314.132330-1-marek.vasut+renesas@gmail.com> 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.103.2 at phobos.denx.de X-Virus-Status: Clean The arch_lmb_reserve() is called by lib/lmb.c lmb_reserve_common() even if CMD_BOOT{I,M,Z} is not enabled. However, the arm32/arm64 variant of arch_lmb_reserve() is only compiled in if CMD_BOOT{I,M,Z} is enabled. This currently does not trigger build error, because there is an empty weak implementation of arch_lmb_reserve(), however that is not the function that should be used on arm32/arm64. Fix this by moving the arch_lmb_reserve() implementation into common code and always compile it in. Signed-off-by: Marek Vasut Cc: Simon Glass Cc: Simon Goldschmidt Cc: Tom Rini Reviewed-by: Tom Rini --- arch/arm/lib/bootm.c | 45 -------------------------------------------- arch/arm/lib/stack.c | 45 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 45 deletions(-) diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c index f60ee3a7e6..dd6a69315a 100644 --- a/arch/arm/lib/bootm.c +++ b/arch/arm/lib/bootm.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -43,50 +42,6 @@ DECLARE_GLOBAL_DATA_PTR; static struct tag *params; -static ulong get_sp(void) -{ - ulong ret; - - asm("mov %0, sp" : "=r"(ret) : ); - return ret; -} - -void arch_lmb_reserve(struct lmb *lmb) -{ - ulong sp, bank_end; - int bank; - - /* - * Booting a (Linux) kernel image - * - * Allocate space for command line and board info - the - * address should be as high as possible within the reach of - * the kernel (see CONFIG_SYS_BOOTMAPSZ settings), but in unused - * memory, which means far enough below the current stack - * pointer. - */ - sp = get_sp(); - debug("## Current stack ends at 0x%08lx ", sp); - - /* adjust sp by 4K to be safe */ - sp -= 4096; - for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) { - if (!gd->bd->bi_dram[bank].size || - sp < gd->bd->bi_dram[bank].start) - continue; - /* Watch out for RAM at end of address space! */ - bank_end = gd->bd->bi_dram[bank].start + - gd->bd->bi_dram[bank].size - 1; - if (sp > bank_end) - continue; - if (bank_end > gd->ram_top) - bank_end = gd->ram_top - 1; - - lmb_reserve(lmb, sp, bank_end - sp + 1); - break; - } -} - __weak void board_quiesce_devices(void) { } diff --git a/arch/arm/lib/stack.c b/arch/arm/lib/stack.c index b03e1cfc80..3f961f4454 100644 --- a/arch/arm/lib/stack.c +++ b/arch/arm/lib/stack.c @@ -12,6 +12,7 @@ */ #include #include +#include #include DECLARE_GLOBAL_DATA_PTR; @@ -33,3 +34,47 @@ int arch_reserve_stacks(void) return 0; } + +static ulong get_sp(void) +{ + ulong ret; + + asm("mov %0, sp" : "=r"(ret) : ); + return ret; +} + +void arch_lmb_reserve(struct lmb *lmb) +{ + ulong sp, bank_end; + int bank; + + /* + * Booting a (Linux) kernel image + * + * Allocate space for command line and board info - the + * address should be as high as possible within the reach of + * the kernel (see CONFIG_SYS_BOOTMAPSZ settings), but in unused + * memory, which means far enough below the current stack + * pointer. + */ + sp = get_sp(); + debug("## Current stack ends at 0x%08lx ", sp); + + /* adjust sp by 4K to be safe */ + sp -= 4096; + for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) { + if (!gd->bd->bi_dram[bank].size || + sp < gd->bd->bi_dram[bank].start) + continue; + /* Watch out for RAM at end of address space! */ + bank_end = gd->bd->bi_dram[bank].start + + gd->bd->bi_dram[bank].size - 1; + if (sp > bank_end) + continue; + if (bank_end > gd->ram_top) + bank_end = gd->ram_top - 1; + + lmb_reserve(lmb, sp, bank_end - sp + 1); + break; + } +}