All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tom Rini <trini@konsulko.com>
To: Michael Srba <Michael.Srba@seznam.cz>
Cc: u-boot@lists.denx.de, Sumit Garg <sumit.garg@kernel.org>,
	u-boot-qcom@groups.io,
	Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	Simon Glass <sjg@chromium.org>,
	Sughosh Ganu <sughosh.ganu@arm.com>,
	Anshul Dalal <anshuld@ti.com>, Peng Fan <peng.fan@nxp.com>,
	Mattijs Korpershoek <mkorpershoek@kernel.org>,
	Quentin Schulz <quentin.schulz@cherry.de>,
	Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Andrew Davis <afd@ti.com>, Hrushikesh Salunke <h-salunke@ti.com>,
	Dario Binacchi <dario.binacchi@amarulasolutions.com>,
	Ye Li <ye.li@nxp.com>, Andre Przywara <andre.przywara@arm.com>,
	Alif Zakuan Yuslaimi <alif.zakuan.yuslaimi@altera.com>,
	Leo Yu-Chi Liang <ycliang@andestech.com>,
	Andrew Goodbody <andrew.goodbody@linaro.org>,
	Dhruva Gole <d-gole@ti.com>,
	Kaustabh Chakraborty <kauschluss@disroot.org>,
	Jerome Forissier <jerome.forissier@arm.com>,
	Heiko Schocher <hs@nabladev.com>,
	Marek Vasut <marek.vasut+renesas@mailbox.org>,
	Lukasz Majewski <lukma@denx.de>,
	Mateusz Kulikowski <mateusz.kulikowski@gmail.com>,
	Dinesh Maniyam <dinesh.maniyam@altera.com>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Patrice Chotard <patrice.chotard@foss.st.com>,
	Patrick Delaunay <patrick.delaunay@foss.st.com>,
	Michal Simek <michal.simek@amd.com>, Yao Zi <me@ziyao.cc>,
	Peter Korsgaard <peter@korsgaard.com>,
	Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com>,
	Casey Connolly <casey.connolly@linaro.org>,
	Tingting Meng <tingting.meng@altera.com>,
	Tien Fong Chee <tien.fong.chee@altera.com>,
	Alice Guo <alice.guo@nxp.com>, George Chan <gchan9527@gmail.com>,
	Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
Subject: Re: [PATCH 4/5] mach-snapdragon: support building SPL
Date: Wed, 8 Apr 2026 11:44:55 -0600	[thread overview]
Message-ID: <20260408174455.GK41863@bill-the-cat> (raw)
In-Reply-To: <b07ef09d-28f5-408d-b9c1-7524442f0f33@seznam.cz>

[-- Attachment #1: Type: text/plain, Size: 4613 bytes --]

On Wed, Apr 08, 2026 at 07:03:37PM +0200, Michael Srba wrote:
> 
> 
> On 4/6/26 16:27, Tom Rini wrote:
> > On Sat, Apr 04, 2026 at 01:18:19AM +0200, michael.srba@seznam.cz wrote:
> > 
> > > From: Michael Srba <Michael.Srba@seznam.cz>
> > > 
> > > Initially sdm845 support is added, and only usb boot
> > > is supported for the next stage.
> > > 
> > > Signed-off-by: Michael Srba <Michael.Srba@seznam.cz>
> > [snip]
> > > diff --git a/arch/arm/mach-snapdragon/Kconfig b/arch/arm/mach-snapdragon/Kconfig
> > > index 976c0e35fce..938e6ebd8bf 100644
> > > --- a/arch/arm/mach-snapdragon/Kconfig
> > > +++ b/arch/arm/mach-snapdragon/Kconfig
> > > @@ -1,6 +1,24 @@
> > >   if ARCH_SNAPDRAGON
> > > +# SoC specific SRAM addresses
> > > +
> > > +# sdm845
> > > +SDM845_BOOT_IMEM_BASE := 0x14800000
> > > +SDM845_BOOT_IMEM_SIZE := 0x180000
> > > +# we may not be able to use the whole BOOT_IMEM depending on the whitelisted regions hardcoded in PBL
> > > +# (we could technically relocate ourselves after the fact)
> > > +SDM845_BOOT_IMEM_OFFSET := 0x3f000
> > > +SDM845_BOOT_IMEM_USABLE_SIZE := 0xc1000
> > > +# technically the below would work, except the memory from 0x14833000 to 0x1483F000 gets trashed
> > > +# between the ELF getting loaded and XBL_SEC jumping to our code
> > > +#SDM845_BOOT_IMEM_OFFSET := 0x16000
> > > +#SDM845_BOOT_IMEM_USABLE_SIZE := 0xea000
> > > +SDM845_OCIMEM_BASE := 0x14680000
> > > +SDM845_OCIMEM_SIZE := 0x00040000
> > > +SDM845_OCIMEM_END  := $(shell, printf "0x%x\n" "$(dollar)(($(SDM845_OCIMEM_BASE) + $(SDM845_OCIMEM_SIZE) - 1))")
> > I didn't know Kconfig even allowed this. And I *really* don't like it,
> > and I think it's going in the wrong direction with respect to being able
> > to configure a system. If these are configurable, then they need to be
> > "hex" type "config" options, and then used later on. Otherwise they
> > should just be the evaluated value as "default ... if ..." later on,
> > instead.
> This is per-SoC hardware info. The SRAM is physically located at that
> address with that size. The offset/usable size are further restrictions
> imposed by the bootrom, which are relevant for placing the text section
> (the bootrom will copy the ELF segment precisely where the ELF segment
> says it wants to live, as long as that's in a whitelisted region).
> 
> I really don't like the idea of just hardcoding hex values with either
> no explanation of where they come from, or with a comment that may or
> may not reflect the reality since there's no mechanism that would enforce
> that the value was actually computed according to the comment.
> (also the amount and complexity of such comments would be higher since
> comments can't reference nonexistent intermediate variables)
> 
> What I wanted to do here was more along the lines of:
> ```
> config QCOM_BOOT_IMEM_BASE
>     default 0x14800000 if SPL_TARGET_SDM845
> 
> config QCOM_BOOT_IMEM_SIZE
>     default 0x180000 if SPL_TARGET_SDM845
> 
> config QCOM_BOOT_IMEM_OFFSET
>     default 0x3f000 if SPL_TARGET_SDM845
> 
> config QCOM_BOOT_IMEM_USABLE_SIZE
>     default 0xc1000 if SPL_TARGET_SDM845
> ```
> and then
> ```
> config SPL_STACK
>     default SDM845_OCIMEM_START + SDM845_OCIMEM_SIZE
> 
> config SPL_TEXT_BASE
>     default QCOM_BOOT_IMEM_BASE + QCOM_BOOT_IMEM_OFFSET
> 
> config SPL_SYS_MALLOC_F_LEN
>     QCOM_BOOT_IMEM_SIZE / 2
> ```
> 
> The problem with the above is that Kconfig absolutely doesn't support
> doing that. The only way to do arithmetics is to use the preprocessor
> ("macro language"), and the preprocessor obviously doesn't have access
> to the values of symbols, only to preprocessor variables.
> 
> The current form is the only solution I could come up with that avoids
> hardcoding hex values, and from reading kconfig docs and sources I think
> it's also the only solution possible short of patching kconfig to support
> arithmetics.
> 
> If you consider this more ugly than magic hex values (which afaict is
> the only other option, other than patching kconfig of course),
> I can obviously do that, although it does make me very sad, and I'd prefer
> if we can find a solution that avoids hardcoding. What do you think?

Yeah, I'd rather go with "magic" hex values in appropriate headers, and
should probably be in the CFG_SYS namespace (so CFG_SYS_QCOM_... ) for
things that aren't "how do we work out SPL_SYS_MALLOC_F_LEN" which will
just be (matching everyone else really) just the hex value, and
explained in the board doc where things come from.

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2026-04-09 13:01 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-03 23:18 [PATCH 0/5] Add SPL support for Qualcomm platforms, starting with sdm845 michael.srba
2026-04-03 23:18 ` [PATCH 1/5] Makefile: add SPL_REMAKE_ELF_LDSCRIPT feature michael.srba
2026-04-06 15:50   ` Simon Glass
2026-04-06 22:43     ` Michael Srba
2026-04-12 12:04       ` Simon Glass
2026-04-13  6:22         ` Michal Simek
2026-04-03 23:18 ` [PATCH 2/5] of_live: support in SPL michael.srba
2026-04-06 14:20   ` Tom Rini
2026-04-06 15:51   ` Simon Glass
2026-04-06 22:57     ` Michael Srba
2026-04-03 23:18 ` [PATCH 3/5] drivers: allow clk_stub and spmi " michael.srba
2026-04-06 14:21   ` Tom Rini
2026-04-06 15:52   ` Simon Glass
2026-04-03 23:18 ` [PATCH 4/5] mach-snapdragon: support building SPL michael.srba
2026-04-06 14:27   ` Tom Rini
2026-04-08 17:03     ` Michael Srba
2026-04-08 17:44       ` Tom Rini [this message]
2026-04-06 15:47   ` Simon Glass
2026-04-08  8:52   ` Casey Connolly
2026-04-03 23:18 ` [PATCH 5/5] dts: add empty .dtsi for shift-axolotl michael.srba
2026-04-06 15:53   ` Simon Glass
2026-04-06 22:54     ` Michael Srba
2026-04-06 15:48 ` [0/5] Add SPL support for Qualcomm platforms, starting with sdm845 Simon Glass
2026-04-06 23:53   ` Michael Srba
2026-04-07  8:12 ` [PATCH 0/5] " Sumit Garg
2026-04-08 18:16   ` Michael Srba
2026-04-13 10:25     ` Sumit Garg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260408174455.GK41863@bill-the-cat \
    --to=trini@konsulko.com \
    --cc=Michael.Srba@seznam.cz \
    --cc=afd@ti.com \
    --cc=alice.guo@nxp.com \
    --cc=alif.zakuan.yuslaimi@altera.com \
    --cc=andre.przywara@arm.com \
    --cc=andrew.goodbody@linaro.org \
    --cc=anshuld@ti.com \
    --cc=balaji.selvanathan@oss.qualcomm.com \
    --cc=casey.connolly@linaro.org \
    --cc=d-gole@ti.com \
    --cc=dario.binacchi@amarulasolutions.com \
    --cc=dinesh.maniyam@altera.com \
    --cc=gchan9527@gmail.com \
    --cc=h-salunke@ti.com \
    --cc=hs@nabladev.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=jerome.forissier@arm.com \
    --cc=kauschluss@disroot.org \
    --cc=lukma@denx.de \
    --cc=marek.vasut+renesas@mailbox.org \
    --cc=mateusz.kulikowski@gmail.com \
    --cc=me@ziyao.cc \
    --cc=michal.simek@amd.com \
    --cc=mkorpershoek@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=patrice.chotard@foss.st.com \
    --cc=patrick.delaunay@foss.st.com \
    --cc=peng.fan@nxp.com \
    --cc=peter@korsgaard.com \
    --cc=quentin.schulz@cherry.de \
    --cc=rayagonda.kokatanur@broadcom.com \
    --cc=sjg@chromium.org \
    --cc=sughosh.ganu@arm.com \
    --cc=sumit.garg@kernel.org \
    --cc=tien.fong.chee@altera.com \
    --cc=tingting.meng@altera.com \
    --cc=u-boot-qcom@groups.io \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    --cc=ycliang@andestech.com \
    --cc=ye.li@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.