All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sumit Garg <sumit.garg@kernel.org>
To: michael.srba@seznam.cz
Cc: u-boot@lists.denx.de, u-boot-qcom@groups.io,
	Tom Rini <trini@konsulko.com>,
	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>,
	Alexey Charkov <alchark@gmail.com>,
	Ronald Wahl <ronald.wahl@legrand.com>,
	Michael Trimarchi <michael@amarulasolutions.com>
Subject: Re: [PATCH v4 04/11] mach-snapdragon: boot0.h: split out msm8916_boot0.h
Date: Fri, 1 May 2026 15:40:31 +0530	[thread overview]
Message-ID: <afR8F6dVWHz6vrG0@sumit-xelite> (raw)
In-Reply-To: <20260426-qcom_spl-v4-4-8cf4133ff883@seznam.cz>

On Sun, Apr 26, 2026 at 01:26:06AM +0200, michael.srba@seznam.cz wrote:
> From: Michael Srba <Michael.Srba@seznam.cz>
> 
> Prepare for supporting alternative boot0.h per-SoC by splitting out
> the existing msm8916-specific code.
> 
> Signed-off-by: Michael Srba <Michael.Srba@seznam.cz>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> ---
>  arch/arm/mach-snapdragon/include/mach/boot0.h      | 57 ++--------------------
>  .../mach-snapdragon/include/mach/msm8916_boot0.h   | 54 ++++++++++++++++++++
>  2 files changed, 59 insertions(+), 52 deletions(-)
> 
> diff --git a/arch/arm/mach-snapdragon/include/mach/boot0.h b/arch/arm/mach-snapdragon/include/mach/boot0.h
> index 953cccad790..44a764788de 100644
> --- a/arch/arm/mach-snapdragon/include/mach/boot0.h
> +++ b/arch/arm/mach-snapdragon/include/mach/boot0.h
> @@ -1,54 +1,7 @@
>  /* SPDX-License-Identifier: GPL-2.0+ */
> -/*
> - * Workaround for "PSCI bug" on DragonBoard 410c
> - * Copyright (C) 2021 Stephan Gerhold <stephan@gerhold.net>
> - *
> - * Syscall parameters taken from Qualcomm's LK fork (scm.h):
> - * Copyright (c) 2011-2015, The Linux Foundation. All rights reserved.
> - *
> - * The PSCI implementation in the TrustZone/tz firmware on DragonBoard 410c has
> - * a bug that starts all other CPU cores in 32-bit mode unless the TZ syscall
> - * that switches from 32-bit to 64-bit mode is executed at least once.
> - *
> - * Normally this happens inside Qualcomm's LK bootloader which runs in 32-bit
> - * mode and uses the TZ syscall to boot a kernel in 64-bit mode. However, if
> - * U-Boot is installed to the "aboot" partition (replacing LK) the switch to
> - * 64-bit mode never happens since U-Boot is already running in 64-bit mode.
> - *
> - * A workaround for this "PSCI bug" is to execute the TZ syscall when entering
> - * U-Boot. That way PSCI is made aware of the 64-bit switch and starts all other
> - * CPU cores in 64-bit mode as well.
> - */
> -#include <linux/arm-smccc.h>
> -
> -#define ARM_SMCCC_SIP32_FAST_CALL \
> -	ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, ARM_SMCCC_SMC_32, ARM_SMCCC_OWNER_SIP, 0)
> -
> -	/*
> -	 * U-Boot might be started in EL2 or EL3 with custom firmware.
> -	 * In that case, we assume that the workaround is not necessary or is
> -	 * handled already by the alternative firmware. Using the syscall in EL2
> -	 * would demote U-Boot to EL1; in EL3 it would probably just crash.
> -	 */
> -	mrs	x0, CurrentEL
> -	cmp	x0, #(1 << 2)	/* EL1 */
> -	bne	reset
> -
> -	/* Prepare TZ syscall parameters */
> -	mov	x0, #ARM_SMCCC_SIP32_FAST_CALL
> -	movk	x0, #0x10f	/* SCM_SVC_MILESTONE_CMD_ID */
> -	mov	x1, #0x12	/* MAKE_SCM_ARGS(0x2, SMC_PARAM_TYPE_BUFFER_READ) */
> -	adr	x2, el1_system_param
> -	mov	x3, el1_system_param_end - el1_system_param
> -
> -	/* Switch PSCI to 64-bit mode. Resets CPU and returns at el1_elr */
> -	smc	#0
> -
> -	/* Something went wrong, perhaps PSCI is already in 64-bit mode? */
> +#if defined(CONFIG_SPL_BUILD)

Rather than this SPL build check...

>  	b	reset
> -
> -	.align	3
> -el1_system_param:
> -	.quad	0, 0, 0, 0, 0, 0, 0, 0, 0	/* el1_x0-x8 */
> -	.quad	reset				/* el1_elr */
> -el1_system_param_end:
> +#else
> +/* currently only db410c enables boot0.h in u-boot proper */
> +#include "msm8916_boot0.h"

...add a special Kconfig option for msm8916 too like follows:

	BOOT0_MSM8916_PSCI_WORKAROUND

and enable it for db410c special defconfig.

-Sumit

> +#endif
> diff --git a/arch/arm/mach-snapdragon/include/mach/msm8916_boot0.h b/arch/arm/mach-snapdragon/include/mach/msm8916_boot0.h
> new file mode 100644
> index 00000000000..953cccad790
> --- /dev/null
> +++ b/arch/arm/mach-snapdragon/include/mach/msm8916_boot0.h
> @@ -0,0 +1,54 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +/*
> + * Workaround for "PSCI bug" on DragonBoard 410c
> + * Copyright (C) 2021 Stephan Gerhold <stephan@gerhold.net>
> + *
> + * Syscall parameters taken from Qualcomm's LK fork (scm.h):
> + * Copyright (c) 2011-2015, The Linux Foundation. All rights reserved.
> + *
> + * The PSCI implementation in the TrustZone/tz firmware on DragonBoard 410c has
> + * a bug that starts all other CPU cores in 32-bit mode unless the TZ syscall
> + * that switches from 32-bit to 64-bit mode is executed at least once.
> + *
> + * Normally this happens inside Qualcomm's LK bootloader which runs in 32-bit
> + * mode and uses the TZ syscall to boot a kernel in 64-bit mode. However, if
> + * U-Boot is installed to the "aboot" partition (replacing LK) the switch to
> + * 64-bit mode never happens since U-Boot is already running in 64-bit mode.
> + *
> + * A workaround for this "PSCI bug" is to execute the TZ syscall when entering
> + * U-Boot. That way PSCI is made aware of the 64-bit switch and starts all other
> + * CPU cores in 64-bit mode as well.
> + */
> +#include <linux/arm-smccc.h>
> +
> +#define ARM_SMCCC_SIP32_FAST_CALL \
> +	ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, ARM_SMCCC_SMC_32, ARM_SMCCC_OWNER_SIP, 0)
> +
> +	/*
> +	 * U-Boot might be started in EL2 or EL3 with custom firmware.
> +	 * In that case, we assume that the workaround is not necessary or is
> +	 * handled already by the alternative firmware. Using the syscall in EL2
> +	 * would demote U-Boot to EL1; in EL3 it would probably just crash.
> +	 */
> +	mrs	x0, CurrentEL
> +	cmp	x0, #(1 << 2)	/* EL1 */
> +	bne	reset
> +
> +	/* Prepare TZ syscall parameters */
> +	mov	x0, #ARM_SMCCC_SIP32_FAST_CALL
> +	movk	x0, #0x10f	/* SCM_SVC_MILESTONE_CMD_ID */
> +	mov	x1, #0x12	/* MAKE_SCM_ARGS(0x2, SMC_PARAM_TYPE_BUFFER_READ) */
> +	adr	x2, el1_system_param
> +	mov	x3, el1_system_param_end - el1_system_param
> +
> +	/* Switch PSCI to 64-bit mode. Resets CPU and returns at el1_elr */
> +	smc	#0
> +
> +	/* Something went wrong, perhaps PSCI is already in 64-bit mode? */
> +	b	reset
> +
> +	.align	3
> +el1_system_param:
> +	.quad	0, 0, 0, 0, 0, 0, 0, 0, 0	/* el1_x0-x8 */
> +	.quad	reset				/* el1_elr */
> +el1_system_param_end:
> 
> -- 
> 2.53.0
> 

  reply	other threads:[~2026-05-01 12:38 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-25 23:26 [PATCH v4 00/11] Add SPL support for Qualcomm platforms, starting with sdm845 michael.srba
2026-04-25 23:26 ` [PATCH v4 01/11] Makefile: add SPL_REMAKE_ELF_LDSCRIPT feature michael.srba
2026-04-28 18:27   ` Simon Glass
2026-04-25 23:26 ` [PATCH v4 02/11] of_live: support in SPL michael.srba
2026-04-25 23:26 ` [PATCH v4 03/11] drivers: allow clk_stub and spmi " michael.srba
2026-04-29 14:18   ` Simon Glass
2026-04-25 23:26 ` [PATCH v4 04/11] mach-snapdragon: boot0.h: split out msm8916_boot0.h michael.srba
2026-05-01 10:10   ` Sumit Garg [this message]
2026-05-01 13:38     ` Michael Srba
2026-04-25 23:26 ` [PATCH v4 05/11] mach-snapdragon: add u-boot-spl-elf-sdm845.lds michael.srba
2026-04-25 23:26 ` [PATCH v4 06/11] mach-snapdragon: Kconfig: fix duplicate SYS_MALLOC_LEN michael.srba
2026-04-25 23:26 ` [PATCH v4 07/11] mach-snapdragon: Kconfig: changes / additions to support SPL michael.srba
2026-04-29 14:22   ` Simon Glass
2026-05-01  7:31   ` Sumit Garg
2026-04-25 23:26 ` [PATCH v4 08/11] mach-snapdragon: boot0.h: add sdm845_spl_boot0.h michael.srba
2026-04-25 23:26 ` [PATCH v4 09/11] mach-snapdragon: add board_spl.c and split out common code michael.srba
2026-04-25 23:26 ` [PATCH v4 10/11] qualcomm: add defconfig, env and docs for SPL on sdm845 michael.srba
2026-04-25 23:26 ` [PATCH v4 11/11] dts: add u-boot specific sdm845 .dtsi and a .dtsi for shift-axolotl michael.srba
2026-05-01  7:35   ` Sumit Garg
2026-05-01 13:04     ` Michael Srba

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=afR8F6dVWHz6vrG0@sumit-xelite \
    --to=sumit.garg@kernel.org \
    --cc=afd@ti.com \
    --cc=alchark@gmail.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=michael.srba@seznam.cz \
    --cc=michael@amarulasolutions.com \
    --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=ronald.wahl@legrand.com \
    --cc=sjg@chromium.org \
    --cc=sughosh.ganu@arm.com \
    --cc=tien.fong.chee@altera.com \
    --cc=tingting.meng@altera.com \
    --cc=trini@konsulko.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.