All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tom Rini <trini@konsulko.com>
To: Thomas Richard <thomas.richard@bootlin.com>
Cc: u-boot@lists.denx.de, nm@ti.com, thomas.petazzoni@bootlin.com,
	gregory.clement@bootlin.com, u-kumar1@ti.com
Subject: Re: [PATCH v2 7/8] board: ti: j721e: During resume spl restores TF-A and DM-Firmware
Date: Tue, 7 Nov 2023 13:26:25 -0500	[thread overview]
Message-ID: <20231107182625.GL6601@bill-the-cat> (raw)
In-Reply-To: <20231107161802.855154-8-thomas.richard@bootlin.com>

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

On Tue, Nov 07, 2023 at 05:18:01PM +0100, Thomas Richard wrote:

> During the boot a copy of DM-Firmware is done in a reserved memory
> area before it starts.
> When resuming, R5 SPL uses this copy of DM-Firmware instead of the fit
> image.
> TF-A which saved itself in this same memory area, is restored in
> SRAM by R5 SPL.
> 
> Based on the work of Gregory CLEMENT <gregory.clement@bootlin.com>
> 
> Signed-off-by: Thomas Richard <thomas.richard@bootlin.com>
> Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com>
> 
> ---
> 
> Changes in v2:
> - Check if TF-A is running in DRAM, if yes no need to restore it
> - Remove BL31_START macro, and get TF-A start address from the fit image
> 
>  arch/arm/mach-k3/common.c                 | 48 ++++++++++++++++++++++-
>  arch/arm/mach-k3/include/mach/j721e_spl.h | 28 +++++++++++++
>  arch/arm/mach-k3/sysfw-loader.c           |  9 +++--
>  3 files changed, 81 insertions(+), 4 deletions(-)

One problem here is we aren't updating something under doc/, possibly
doc/board/ti/k3.rst unless you want to start populating something
entirely new under doc/develop/. And then using kernel-doc comments here
and including the code in the rst.  And so this is a global comment to
the series as well, and I'll leave sorting out when/where to introduce
that part up to your discretion.

[snip]
> diff --git a/arch/arm/mach-k3/include/mach/j721e_spl.h b/arch/arm/mach-k3/include/mach/j721e_spl.h
> index e8947917a6..8e0f141ed6 100644
> --- a/arch/arm/mach-k3/include/mach/j721e_spl.h
> +++ b/arch/arm/mach-k3/include/mach/j721e_spl.h
> @@ -42,4 +42,32 @@
>  #define K3_PRIMARY_BOOTMODE		0x0
>  #define K3_BACKUP_BOOTMODE		0x1
>  
> +/* Starting buffer address is 1MB before the stack address in DDR */
> +#define BUFFER_ADDR (CONFIG_SPL_STACK_R_ADDR - SZ_1M)

Assuming this is the full level of configurability we need to
BUFFER_ADDR please add some Kconfig logic to make sure we can't not set
CONFIG_SPL_STACK_R_ADDR. That might take a little trial-and-error and
if we just cannot enforce this via Kconfig, let me know and I'll think
about what we want to do instead next.

> +/* This is actually the whole size of the SRAM */
> +#define BL31_SIZE    0x20000

If this is all of SRAM then is there not already a define?

> +/* This address belongs to a reserved memory region for the point of view of
> + * Linux, U-boot SPL must use the same address to restore TF-A and resume
> + * entry point address
> + */
> +#define LPM_SAVE		0xA5000000
> +#define LPM_BL31_SAVE		LPM_SAVE
> +#define LPM_BL31_RESUME_SAVE	LPM_BL31_SAVE + BL31_SIZE
> +#define LPM_BL31_START_SAVE	LPM_BL31_RESUME_SAVE + __SIZEOF_POINTER__
> +#define LPM_DM_SAVE		LPM_BL31_START_SAVE  + __SIZEOF_POINTER__

Is any of this somewhere in the devicetree as well? I'm not saying "and
so pull it from that!" is a must, but I'd like to at least know "that
would be horrible to do", and fall back to having this needed
co-operation documented somewhere and ideally somewhere / somehow that
getting the values wrong is clear. Debugging resume failures at run-time
is much more painful than build time.

> +/* Check if the copy of TF-A and DM-Firmware in DRAM does not overlap an
> + * over memory section.
> + * The resume address of TF-A is also saved in DRAM.
> + * At build time we don't know the DM-Firmware size, so we keep 512k to
> + * save it.
> + */
> +#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_TARGET_J7200_R5_EVM)
> +#if ((LPM_DM_SAVE + SZ_512K) > BUFFER_ADDR)
> +#error Not enough space to save DM-Firmware, TF-A and context for S2R
> +#endif
> +#endif

This is really the kind of thing I'd like to see enforced via Kconfig if
at all possible. Sometimes yes we just have to CPP and #error, I just
want to know we can't.

-- 
Tom

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

  reply	other threads:[~2023-11-07 18:26 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-07 16:17 [PATCH v2 0/8] Suspend to RAM support for K3 J7200 Thomas Richard
2023-11-07 16:17 ` [PATCH v2 1/8] DO NOT MERGE: arm: dts: k3-j7200-r5-common: Add pmic node for esm Thomas Richard
2023-11-07 16:17 ` [PATCH v2 2/8] configs: j7200_evm_r5: Used reserved memory in DDR for stack Thomas Richard
2023-11-07 18:12   ` Tom Rini
2023-11-07 16:17 ` [PATCH v2 3/8] configs: j7200_evm_r5: Move address used for allocation in the reserved space Thomas Richard
2023-11-07 16:17 ` [PATCH v2 4/8] board: ti: j721e: Add resume detection for J7200 Thomas Richard
2023-11-07 18:16   ` Tom Rini
2023-11-07 16:17 ` [PATCH v2 5/8] ram: k3-ddrss: Add exit retention support Thomas Richard
2023-11-07 16:18 ` [PATCH v2 6/8] board: ti: j721e: Add the missing part of exit retention for k3-ddrss (J7200) Thomas Richard
2023-11-07 18:18   ` Tom Rini
2023-11-09 10:43     ` Thomas Richard
2023-11-09 14:07       ` Tom Rini
2023-11-07 16:18 ` [PATCH v2 7/8] board: ti: j721e: During resume spl restores TF-A and DM-Firmware Thomas Richard
2023-11-07 18:26   ` Tom Rini [this message]
2023-11-08 17:30   ` Andrew Davis
2023-11-09 11:29     ` Thomas Richard
2023-11-09 16:17       ` Andrew Davis
2023-11-07 16:18 ` [PATCH v2 8/8] arm: mach-k3: j7200: Skip fit processing when resuming Thomas Richard
2023-11-07 18:06 ` [PATCH v2 0/8] Suspend to RAM support for K3 J7200 Tom Rini

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=20231107182625.GL6601@bill-the-cat \
    --to=trini@konsulko.com \
    --cc=gregory.clement@bootlin.com \
    --cc=nm@ti.com \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=thomas.richard@bootlin.com \
    --cc=u-boot@lists.denx.de \
    --cc=u-kumar1@ti.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.