From: Andre Przywara <andre.przywara@arm.com>
To: Sam Edwards <cfsworks@gmail.com>
Cc: u-boot@lists.denx.de, Jagan Teki <jagan@amarulasolutions.com>,
Marc Zyngier <maz@kernel.org>, Chen-Yu Tsai <wens@csie.org>
Subject: Re: [PATCH] sunxi: psci: remove redundant initialization from psci_arch_init
Date: Mon, 14 Aug 2023 21:39:10 +0100 [thread overview]
Message-ID: <20230814213854.408962d5@slackpad.lan> (raw)
In-Reply-To: <20230531201520.15479-1-CFSworks@gmail.com>
On Wed, 31 May 2023 14:15:20 -0600
Sam Edwards <cfsworks@gmail.com> wrote:
Hi,
(CC:ing Marc and Chen-Yu as the original authors)
sorry for the delay, found that mouldering in my Drafts folder.
> The nonsec code overrides/handles these:
> - Setting PMR to 0xFF happens earlier, in _nonsec_init, so this is
> redundant.
> - The NS bit is not yet set: it gets set later in _secure_monitor.
> Trying to clear it here is pointless and misleading.
So superficially this looks alright, but I am still somewhat reluctant
to apply this, see below ...
> Signed-off-by: Sam Edwards <CFSworks@gmail.com>
> ---
> arch/arm/cpu/armv7/sunxi/psci.c | 4 ----
> 1 file changed, 4 deletions(-)
>
> diff --git a/arch/arm/cpu/armv7/sunxi/psci.c b/arch/arm/cpu/armv7/sunxi/psci.c
> index e1d3638b5c..f866025c37 100644
> --- a/arch/arm/cpu/armv7/sunxi/psci.c
> +++ b/arch/arm/cpu/armv7/sunxi/psci.c
> @@ -300,14 +300,10 @@ void __secure psci_arch_init(void)
> /* Set SGI15 priority to 0 */
> writeb(0, GICD_BASE + GICD_IPRIORITYRn + 15);
>
> - /* Be cool with non-secure */
> - writel(0xff, GICC_BASE + GICC_PMR);
> -
> /* Switch FIQEn on */
> setbits_le32(GICC_BASE + GICC_CTLR, BIT(3));
>
> reg = cp15_read_scr();
> reg |= BIT(2); /* Enable FIQ in monitor mode */
> - reg &= ~BIT(0); /* Secure mode */
I am scratching my head on this one: I see it deliberately being done in
the original patch by Marc[1], and wonder why. If I read the code and
the architecture correctly, this routine is called only(?) from the SMC
handler, which means we are in monitor mode, that only exists in secure
state. So the NS bit is irrelevant until we switch to another mode. And
we indeed set the bit later, before dropping back to non-secure. So I
agree that clearing the bit is pointless. Was it put in to be more
robust, for other potential callers of this function, for instance in
the boot path?
Does anyone remember?
Cheers,
Andre
[1]
https://source.denx.de/u-boot/u-boot/-/commit/d5db7024aafc5ea603f3a34f83bb29a1eaa3cbe7#f377950449a5dba076796d9e48fbd21f5d6ac545_0_65
> cp15_write_scr(reg);
> }
next parent reply other threads:[~2023-08-14 20:40 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20230531201520.15479-1-CFSworks@gmail.com>
2023-08-14 20:39 ` Andre Przywara [this message]
2023-08-15 11:13 ` [PATCH] sunxi: psci: remove redundant initialization from psci_arch_init Marc Zyngier
2023-08-25 7:20 ` Chen-Yu Tsai
2023-08-25 18:05 ` Sam Edwards
2023-08-26 10:22 ` Marc Zyngier
2023-08-28 21:49 ` Sam Edwards
2023-08-29 14:30 ` Chen-Yu Tsai
2023-08-29 14:34 ` Chen-Yu Tsai
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=20230814213854.408962d5@slackpad.lan \
--to=andre.przywara@arm.com \
--cc=cfsworks@gmail.com \
--cc=jagan@amarulasolutions.com \
--cc=maz@kernel.org \
--cc=u-boot@lists.denx.de \
--cc=wens@csie.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox