Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 52F40C43334 for ; Thu, 30 Jun 2022 13:36:45 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F21C8842D0; Thu, 30 Jun 2022 15:36:42 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com 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=konsulko.com header.i=@konsulko.com header.b="t2NcN5ZA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 00D9B842A2; Thu, 30 Jun 2022 15:36:41 +0200 (CEST) Received: from mail-qk1-x72e.google.com (mail-qk1-x72e.google.com [IPv6:2607:f8b0:4864:20::72e]) (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 24E038432E for ; Thu, 30 Jun 2022 15:36:36 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-qk1-x72e.google.com with SMTP id z12so14404175qki.3 for ; Thu, 30 Jun 2022 06:36:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=HAys1FqVgahYtUNNim9zQ9p+RhSqCSzzn37ZcCXNSwc=; b=t2NcN5ZAGZk6TAikPxziVDcOeZ6I6uf8UlidPI01QobTp17sNMHCMgft67VG9+ZMDw qEbRsTjaLNKCLhCnJEAwL4MYjl7oO1pr1J9kSxrzOnZ+GsufnBB1UftbYRSkpnZS58wT lSgtjC5IGzHHTc1WMDr39H95Edgq9vJM0uBg8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=HAys1FqVgahYtUNNim9zQ9p+RhSqCSzzn37ZcCXNSwc=; b=VgcAK2PXbi9NIb4GF4S1psV0c6z34FQ7iQXNr+LfpScW/l4ltgTQ0+vWzYC2AylB9S HxF9Y7/COooFbb21i7IgMcbpW/lG5MlU0vQcaWkGd4u+taVVk73aSJpS9TBOgoYjd4IJ C/C+ylNcNXjZycjK624XaO60lssIYqPOu3l79+e256HLa9cxQ6uXVpfiBd0UO43PAU7G Dp+qufNIs3gaBnXzaJvvDVjByCNhyeR43wla14+D6HxIyl8FmQziOY73yYNqSgsMcDEC NAh9CnD5IVBlTup+XMV2W111JQHD9eF/vV2Z57ztkDQClak9g91f4nTT/MYB5lNuO6AA lgQQ== X-Gm-Message-State: AJIora/uCUmW17Z63y5JSitSkQKAkmUzWe7fjsK0T71WY0Jp2wBNwTxo XyLFObaV7APjQv5h8rdJSEj24A== X-Google-Smtp-Source: AGRyM1s2ML4cNr12OKHs4l7VInRi9CcXriCDFKkWnpQvcPacj8rFmLGBr3Q1/Fd+/3JHOq/w4a2zaw== X-Received: by 2002:a05:620a:c84:b0:6af:1eaf:1380 with SMTP id q4-20020a05620a0c8400b006af1eaf1380mr6066987qki.249.1656596194735; Thu, 30 Jun 2022 06:36:34 -0700 (PDT) Received: from bill-the-cat (cpe-65-184-195-139.ec.res.rr.com. [65.184.195.139]) by smtp.gmail.com with ESMTPSA id u16-20020a05620a431000b006a7284e5741sm15475017qko.54.2022.06.30.06.36.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jun 2022 06:36:33 -0700 (PDT) Date: Thu, 30 Jun 2022 09:36:31 -0400 From: Tom Rini To: Simon Glass Cc: Marek Vasut , U-Boot Mailing List , Albert ARIBAUD , Fabio Estevam , Peng Fan , Stefano Babic , Thomas Chou Subject: Re: [PATCH] board_init: Do not reserve MALLOC_F area on stack if non-zero MALLOC_F_ADDR Message-ID: <20220630133631.GM1146598@bill-the-cat> References: <20220625175824.128263-1-marex@denx.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="kZxC0s2ORSstvtHP" Content-Disposition: inline In-Reply-To: X-Clacks-Overhead: GNU Terry Pratchett X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean --kZxC0s2ORSstvtHP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jun 30, 2022 at 04:06:22AM -0600, Simon Glass wrote: > Hi Marek, >=20 > On Sat, 25 Jun 2022 at 11:58, Marek Vasut wrote: > > > > In case the MALLOC_F_ADDR is set to non-zero value, the early malloc ar= ea is > > not going to be placed just below stack top, but elsewhere. Do not rese= rve > > MALLOC_F bytes in this case, as that wastes stack space and may even ca= use > > insufficient stack space in SPL. > > > > This functionality is particularly useful on i.MX8M, where the insuffic= ient > > stack space can be triggered. > > > > Signed-off-by: Marek Vasut > > Cc: Albert ARIBAUD > > Cc: Fabio Estevam > > Cc: Peng Fan > > Cc: Simon Glass > > Cc: Stefano Babic > > Cc: Thomas Chou > > Cc: Tom Rini > > --- > > common/init/board_init.c | 2 ++ > > 1 file changed, 2 insertions(+) >=20 > Please can you migrate the option to Kconfig first? I suspect that > will simplify the logic and avoid the #ifndef That was my first reaction as well. But, I'm not so sure after looking at things more. An issue is that CONFIG_MALLOC_F_ADDR should probably be CONFIG_SPL_MALLOC_F_ADDR as it's only used in SPL. But it's also not an either/or around CONFIG_SPL_SYS_MALLOC_F_LEN. It would be good to move to Kconfig (but I also don't see a common default for the handful of SoCs using it), and maybe a !CONFIG_VAL() test instead of ifndef. >=20 > > > > diff --git a/common/init/board_init.c b/common/init/board_init.c > > index eab5ee13953..6a550261778 100644 > > --- a/common/init/board_init.c > > +++ b/common/init/board_init.c > > @@ -78,8 +78,10 @@ __weak void board_init_f_init_stack_protection(void) > > ulong board_init_f_alloc_reserve(ulong top) > > { > > /* Reserve early malloc arena */ > > +#ifndef CONFIG_MALLOC_F_ADDR > > #if CONFIG_VAL(SYS_MALLOC_F_LEN) > > top -=3D CONFIG_VAL(SYS_MALLOC_F_LEN); > > +#endif > > #endif > > /* LAST : reserve GD (rounded up to a multiple of 16 bytes) */ > > top =3D rounddown(top-sizeof(struct global_data), 16); > > -- > > 2.35.1 > > >=20 > Regards, > Simon --=20 Tom --kZxC0s2ORSstvtHP Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmK9ptwACgkQFHw5/5Y0 tyyekAv9H97RWkPZsLhbAo/qx2ksGzYtX5ddH0iCDogg25FdrRVyQZzumqg5ltjN wKOzkwcq6xKq4teMSmSJ7QHLtjXGy7WcQZOgc4xHBEg7ytPBn1jEnc6hlkvzzpGF YFHvCnleuBvQpjIFvOfBHaPJwGt2NLCNikG7mCOK1DNTwyft9XmbybeUYZcmf5xE 4vw1fnekHVSX2c30M1D/fziwLOF6SbfwfykbaD4EYuZcBQizH3/Y/mygtnSbpmgt Hp6AZW+sbpuJ0nxB6jzrLNs8ChYHFYgW7/Dvm85+eJCsCwX9aCxUf9jecKu1puWi s0dvnrZmJ2HFX7FNNCOJnPFyMVa+2tMjYYntm6amdH/nYfLGonkEEMYJMR2kzMqH w6EK4BMEsYcCo17SDrefsOpXIIcM4pzc5ZEnaeJKeGPvaS+k7VSJD4nU06QaqVdB jO74kJRqBRS0UNv+P6WPR9pPPMbSLw5jeWvV96rk/WobuSsIq96+QayLWyIoXCPq tp34NM+c =3/Ge -----END PGP SIGNATURE----- --kZxC0s2ORSstvtHP--