* [PATCH] ARM: at91: pm: set soc_pm.data.mode in at91_pm_secure_init()
@ 2023-10-20 13:02 thomas.perrot
2023-10-20 14:50 ` Nicolas Ferre
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: thomas.perrot @ 2023-10-20 13:02 UTC (permalink / raw)
To: Russell King, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea
Cc: linux-arm-kernel, linux-kernel, clement.leger, Thomas Perrot
From: Thomas Perrot <thomas.perrot@bootlin.com>
In non secure mode, soc_pm.data.mode is set when entering pm in
at91_pm_begin(). This value is used (not only) to determine if the system
is going into slow clock mode (at91_suspend_entering_slow_clock()). This
function is called from various drivers to check this and act accordingly.
If not set, the driver might enter an incorrect suspend mode. When using
secure suspend mode, at91_pm_begin() is not called and thus
soc_pm.data.mode is not set. Since when using secure suspend, only one
suspend mode is supported, set this value directly in
at91_pm_secure_init().
Signed-off-by: Clément Léger <clement.leger@bootlin.com>
Signed-off-by: Thomas Perrot <thomas.perrot@bootlin.com>
---
arch/arm/mach-at91/pm.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index 1a26af0fabc7..345b91dc6627 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -1103,6 +1103,7 @@ static void __init at91_pm_secure_init(void)
if (res.a0 == 0) {
pr_info("AT91: Secure PM: suspend mode set to %s\n",
pm_modes[suspend_mode].pattern);
+ soc_pm.data.mode = suspend_mode;
return;
}
@@ -1112,6 +1113,7 @@ static void __init at91_pm_secure_init(void)
res = sam_smccc_call(SAMA5_SMC_SIP_GET_SUSPEND_MODE, 0, 0);
if (res.a0 == 0) {
pr_warn("AT91: Secure PM: failed to get default mode\n");
+ soc_pm.data.mode = -1;
return;
}
@@ -1119,6 +1121,7 @@ static void __init at91_pm_secure_init(void)
pm_modes[suspend_mode].pattern);
soc_pm.data.suspend_mode = res.a1;
+ soc_pm.data.mode = soc_pm.data.suspend_mode;
}
static const struct of_device_id atmel_shdwc_ids[] = {
{ .compatible = "atmel,sama5d2-shdwc" },
--
2.41.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ARM: at91: pm: set soc_pm.data.mode in at91_pm_secure_init()
2023-10-20 13:02 [PATCH] ARM: at91: pm: set soc_pm.data.mode in at91_pm_secure_init() thomas.perrot
@ 2023-10-20 14:50 ` Nicolas Ferre
2023-10-23 6:01 ` claudiu beznea
2023-11-20 9:08 ` claudiu beznea
2 siblings, 0 replies; 5+ messages in thread
From: Nicolas Ferre @ 2023-10-20 14:50 UTC (permalink / raw)
To: thomas.perrot, Russell King, Alexandre Belloni, Claudiu Beznea
Cc: linux-arm-kernel, linux-kernel, clement.leger
On 20/10/2023 at 15:02, thomas.perrot@bootlin.com wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>
> From: Thomas Perrot <thomas.perrot@bootlin.com>
>
> In non secure mode, soc_pm.data.mode is set when entering pm in
> at91_pm_begin(). This value is used (not only) to determine if the system
> is going into slow clock mode (at91_suspend_entering_slow_clock()). This
> function is called from various drivers to check this and act accordingly.
> If not set, the driver might enter an incorrect suspend mode. When using
> secure suspend mode, at91_pm_begin() is not called and thus
> soc_pm.data.mode is not set. Since when using secure suspend, only one
> suspend mode is supported, set this value directly in
> at91_pm_secure_init().
>
> Signed-off-by: Clément Léger <clement.leger@bootlin.com>
> Signed-off-by: Thomas Perrot <thomas.perrot@bootlin.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Thanks, best regards,
Nicolas
> ---
> arch/arm/mach-at91/pm.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
> index 1a26af0fabc7..345b91dc6627 100644
> --- a/arch/arm/mach-at91/pm.c
> +++ b/arch/arm/mach-at91/pm.c
> @@ -1103,6 +1103,7 @@ static void __init at91_pm_secure_init(void)
> if (res.a0 == 0) {
> pr_info("AT91: Secure PM: suspend mode set to %s\n",
> pm_modes[suspend_mode].pattern);
> + soc_pm.data.mode = suspend_mode;
> return;
> }
>
> @@ -1112,6 +1113,7 @@ static void __init at91_pm_secure_init(void)
> res = sam_smccc_call(SAMA5_SMC_SIP_GET_SUSPEND_MODE, 0, 0);
> if (res.a0 == 0) {
> pr_warn("AT91: Secure PM: failed to get default mode\n");
> + soc_pm.data.mode = -1;
> return;
> }
>
> @@ -1119,6 +1121,7 @@ static void __init at91_pm_secure_init(void)
> pm_modes[suspend_mode].pattern);
>
> soc_pm.data.suspend_mode = res.a1;
> + soc_pm.data.mode = soc_pm.data.suspend_mode;
> }
> static const struct of_device_id atmel_shdwc_ids[] = {
> { .compatible = "atmel,sama5d2-shdwc" },
> --
> 2.41.0
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ARM: at91: pm: set soc_pm.data.mode in at91_pm_secure_init()
2023-10-20 13:02 [PATCH] ARM: at91: pm: set soc_pm.data.mode in at91_pm_secure_init() thomas.perrot
2023-10-20 14:50 ` Nicolas Ferre
@ 2023-10-23 6:01 ` claudiu beznea
2023-10-23 17:32 ` Thomas Perrot
2023-11-20 9:08 ` claudiu beznea
2 siblings, 1 reply; 5+ messages in thread
From: claudiu beznea @ 2023-10-23 6:01 UTC (permalink / raw)
To: thomas.perrot, Russell King, Nicolas Ferre, Alexandre Belloni
Cc: linux-arm-kernel, linux-kernel, clement.leger
Hi, Thomas,
On 20.10.2023 16:02, thomas.perrot@bootlin.com wrote:
> From: Thomas Perrot <thomas.perrot@bootlin.com>
>
> In non secure mode, soc_pm.data.mode is set when entering pm in
> at91_pm_begin(). This value is used (not only) to determine if the system
> is going into slow clock mode (at91_suspend_entering_slow_clock()). This
> function is called from various drivers to check this and act accordingly.
> If not set, the driver might enter an incorrect suspend mode. When using
> secure suspend mode, at91_pm_begin() is not called and thus
> soc_pm.data.mode is not set. Since when using secure suspend, only one
> suspend mode is supported, set this value directly in
> at91_pm_secure_init().
>
> Signed-off-by: Clément Léger <clement.leger@bootlin.com>
> Signed-off-by: Thomas Perrot <thomas.perrot@bootlin.com>
> ---
> arch/arm/mach-at91/pm.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
> index 1a26af0fabc7..345b91dc6627 100644
> --- a/arch/arm/mach-at91/pm.c
> +++ b/arch/arm/mach-at91/pm.c
> @@ -1103,6 +1103,7 @@ static void __init at91_pm_secure_init(void)
> if (res.a0 == 0) {
> pr_info("AT91: Secure PM: suspend mode set to %s\n",
> pm_modes[suspend_mode].pattern);
> + soc_pm.data.mode = suspend_mode;
> return;
> }
>
> @@ -1112,6 +1113,7 @@ static void __init at91_pm_secure_init(void)
> res = sam_smccc_call(SAMA5_SMC_SIP_GET_SUSPEND_MODE, 0, 0);
> if (res.a0 == 0) {
> pr_warn("AT91: Secure PM: failed to get default mode\n");
> + soc_pm.data.mode = -1;
As this variable's type is unsigned int setting it -1 will make
at91_suspend_entering_slow_clock() return true all the time. Is this what
you intend?
Thank you,
Claudiu Beznea
> return;
> }
>
> @@ -1119,6 +1121,7 @@ static void __init at91_pm_secure_init(void)
> pm_modes[suspend_mode].pattern);
>
> soc_pm.data.suspend_mode = res.a1;
> + soc_pm.data.mode = soc_pm.data.suspend_mode;
> }
> static const struct of_device_id atmel_shdwc_ids[] = {
> { .compatible = "atmel,sama5d2-shdwc" },
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ARM: at91: pm: set soc_pm.data.mode in at91_pm_secure_init()
2023-10-23 6:01 ` claudiu beznea
@ 2023-10-23 17:32 ` Thomas Perrot
0 siblings, 0 replies; 5+ messages in thread
From: Thomas Perrot @ 2023-10-23 17:32 UTC (permalink / raw)
To: claudiu beznea, Russell King, Nicolas Ferre, Alexandre Belloni
Cc: linux-arm-kernel, linux-kernel, clement.leger
[-- Attachment #1: Type: text/plain, Size: 2343 bytes --]
Hello Claudiu,
On Mon, 2023-10-23 at 09:01 +0300, claudiu beznea wrote:
> > Hi, Thomas,
> >
> > > >
> > > > diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
> > > > index 1a26af0fabc7..345b91dc6627 100644
> > > > --- a/arch/arm/mach-at91/pm.c
> > > > +++ b/arch/arm/mach-at91/pm.c
> > > > @@ -1103,6 +1103,7 @@ static void __init
> > > > at91_pm_secure_init(void)
> > > > if (res.a0 == 0) {
> > > > pr_info("AT91: Secure PM: suspend mode set to
> > > > %s\n",
> > > > pm_modes[suspend_mode].pattern);
> > > > + soc_pm.data.mode = suspend_mode;
> > > > return;
> > > > }
> > > >
> > > > @@ -1112,6 +1113,7 @@ static void __init
> > > > at91_pm_secure_init(void)
> > > > res = sam_smccc_call(SAMA5_SMC_SIP_GET_SUSPEND_MODE, 0,
> > > > 0);
> > > > if (res.a0 == 0) {
> > > > pr_warn("AT91: Secure PM: failed to get default
> > > > mode\n");
> > > > + soc_pm.data.mode = -1;
> >
> > As this variable's type is unsigned int setting it -1 will make
> > at91_suspend_entering_slow_clock() return true all the time. Is
> > this
> > what
> > you intend?
> >
Yes, to set it at the same default value, as in at91_pm_begin() [1],
when an unsupported mode is used and can’t get the default value from
the secure monitor.
[1]https://elixir.bootlin.com/linux/latest/source/arch/arm/mach-at91/pm.c#L470
Kind regards,
Thomas Perrot
> > Thank you,
> > Claudiu Beznea
> >
> > > > return;
> > > > }
> > > >
> > > > @@ -1119,6 +1121,7 @@ static void __init
> > > > at91_pm_secure_init(void)
> > > > pm_modes[suspend_mode].pattern);
> > > >
> > > > soc_pm.data.suspend_mode = res.a1;
> > > > + soc_pm.data.mode = soc_pm.data.suspend_mode;
> > > > }
> > > > static const struct of_device_id atmel_shdwc_ids[] = {
> > > > { .compatible = "atmel,sama5d2-shdwc" },
--
Thomas Perrot, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
--
Thomas Perrot, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ARM: at91: pm: set soc_pm.data.mode in at91_pm_secure_init()
2023-10-20 13:02 [PATCH] ARM: at91: pm: set soc_pm.data.mode in at91_pm_secure_init() thomas.perrot
2023-10-20 14:50 ` Nicolas Ferre
2023-10-23 6:01 ` claudiu beznea
@ 2023-11-20 9:08 ` claudiu beznea
2 siblings, 0 replies; 5+ messages in thread
From: claudiu beznea @ 2023-11-20 9:08 UTC (permalink / raw)
To: thomas.perrot, Russell King, Nicolas Ferre, Alexandre Belloni
Cc: linux-arm-kernel, linux-kernel, clement.leger
On 20.10.2023 16:02, thomas.perrot@bootlin.com wrote:
> From: Thomas Perrot <thomas.perrot@bootlin.com>
>
> In non secure mode, soc_pm.data.mode is set when entering pm in
> at91_pm_begin(). This value is used (not only) to determine if the system
> is going into slow clock mode (at91_suspend_entering_slow_clock()). This
> function is called from various drivers to check this and act accordingly.
> If not set, the driver might enter an incorrect suspend mode. When using
> secure suspend mode, at91_pm_begin() is not called and thus
> soc_pm.data.mode is not set. Since when using secure suspend, only one
> suspend mode is supported, set this value directly in
> at91_pm_secure_init().
>
> Signed-off-by: Clément Léger <clement.leger@bootlin.com>
> Signed-off-by: Thomas Perrot <thomas.perrot@bootlin.com>
Applied to at91-soc, thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-11-20 9:08 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-20 13:02 [PATCH] ARM: at91: pm: set soc_pm.data.mode in at91_pm_secure_init() thomas.perrot
2023-10-20 14:50 ` Nicolas Ferre
2023-10-23 6:01 ` claudiu beznea
2023-10-23 17:32 ` Thomas Perrot
2023-11-20 9:08 ` claudiu beznea
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome