lib: sbi: Allow platform to influence cold boot HART selection
PATCH v3 1/3 lib: sbi: Allow platform to influence cold boot HART selection
From: Anup Patel <[email protected]>
We add an optional cold_boot_allowed() platform callback which allows platform support to decide which HARTs can do cold boot initialization.
If this platform callback is not available then any HART can do cold boot initialization.
--- include/sbi/sbi_platform.h | 20 ++++++++++++++++++++ lib/sbi/sbi_init.c | 7 +++++-- 2 files changed, 25 insertions(+), 2 deletions(-)
include/sbi/sbi_platform.h +20 -0
@@ -65,6 +65,9 @@ enum sbi_platform_features {/** Platform functions */ struct sbi_platform_operations { +/* Check if specified HART is allowed to do cold boot */ +bool (*cold_boot_allowed)(u32 hartid); +/* Platform nascent initialization */ int (*nascent_init)(void );
@@ -356,6 +359,23 @@ static inline bool sbi_platform_hart_invalid(const struct sbi_platform *plat,return FALSE; } +/** +* Check whether given HART is allowed to do cold boot +* +* @param plat pointer to struct sbi_platform +* @param hartid HART ID +* +* @return TRUE if HART is allowed to do cold boot and FALSE otherwise +*/ +static inline bool sbi_platform_cold_boot_allowed ( +const struct sbi_platform *plat, +u32 hartid) +{ +if (plat &&sbi_platform_ops (plat)->cold_boot_allowed) +return sbi_platform_ops (plat)->cold_boot_allowed (hartid); +return TRUE; +} +/** * Nascent (very early) initialization for current HART *
lib/sbi/sbi_init.c +5 -2
@@ -498,8 +498,11 @@ void __noreturn sbi_init(struct sbi_scratch *scratch)* HARTs which satisfy above condition. */ -if (next_mode_supported &&atomic_xchg (&coldboot_lottery,1 ) ==0 ) - coldboot = TRUE; +if (sbi_platform_cold_boot_allowed (plat, hartid)) { +if (next_mode_supported && +atomic_xchg (&coldboot_lottery,1 ) ==0 ) + coldboot = TRUE; + }/* * Do platform specific nascent (very early) initialization so
Signature · 1 line
2.25.1
PATCH v3 1/3 lib: sbi: Allow platform to influence cold boot HART selection
From 1f466b9e2945b57adc18d075b45b9ecdb304a38a Mon Sep 17 00:00:00 2001
From: Anup Patel <[email protected]>
Date: Fri, 2 Dec 2022 14:23:22 +0530
Subject: [PATCH v3 2/3] platform: generic: Allow platform_override to select
cold boot HART
We add a generic platform override callback to allow platform specific selection of cold boot HART.
--- platform/generic/include/platform_override.h | 1 + platform/generic/platform.c | 9 +++++++++ 2 files changed, 10 insertions(+)
platform/generic/include/platform_override.h +1 -0
@@ -18,6 +18,7 @@ struct platform_override {const struct fdt_match *match_table;u64 (*features)(const struct fdt_match *match);u64 (*tlbr_flush_limit)(const struct fdt_match *match); +bool (*cold_boot_allowed)(u32 hartid,const struct fdt_match *match);int (*early_init)(bool cold_boot,const struct fdt_match *match);int (*final_init)(bool cold_boot,const struct fdt_match *match);void (*early_exit)(const struct fdt_match *match);
platform/generic/platform.c +9 -0
@@ -122,6 +122,14 @@ fail:wfi (); } +static bool generic_cold_boot_allowed (u32 hartid) +{ +if (generic_plat && generic_plat->cold_boot_allowed) +return generic_plat && generic_plat->cold_boot_allowed ( + hartid, generic_plat_match); +return TRUE; +} +static int generic_nascent_init (void ) {if (platform_has_mlevel_imsic)
@@ -261,6 +269,7 @@ static int generic_console_init(void) }const struct sbi_platform_operations platform_ops = { + .cold_boot_allowed = generic_cold_boot_allowed, .nascent_init = generic_nascent_init, .early_init = generic_early_init, .final_init = generic_final_init,
Signature · 1 line
2.25.1
PATCH v3 3/3 generic/starfive: Add Starfive JH7110 platform implementation
In reply to Wei Liang LimAdd Starfive JH7110 platform implementation
--- platform/generic/Kconfig | 4 ++++ platform/generic/configs/defconfig | 1 + platform/generic/starfive/jh7110.c | 27 +++++++++++++++++++++++++++ platform/generic/starfive/objects.mk | 6 ++++++ 4 files changed, 38 insertions(+) create mode 100644 platform/generic/starfive/jh7110.c create mode 100644 platform/generic/starfive/objects.mk
platform/generic/Kconfig +4 -0
@@ -41,4 +41,8 @@ config PLATFORM_SIFIVE_FU740 depends on FDT_RESET && FDT_I2C default n +config PLATFORM_STARFIVE_JH7110 + bool "StarFive JH7110 support" + default n + endif
platform/generic/configs/defconfig +1 -0
@@ -2,6 +2,7 @@ CONFIG_PLATFORM_ALLWINNER_D1=y CONFIG_PLATFORM_ANDES_AE350=y CONFIG_PLATFORM_SIFIVE_FU540=y CONFIG_PLATFORM_SIFIVE_FU740=y +CONFIG_PLATFORM_STARFIVE_JH7110=y CONFIG_FDT_GPIO=y CONFIG_FDT_GPIO_SIFIVE=y CONFIG_FDT_I2C=y
platform/generic/starfive/jh7110.c new file +27 -0
@@ -0,0 +1,27 @@ +/* +* SPDX-License-Identifier: BSD-2-Clause +* +* Copyright (c) 2022 StarFive +* +* Authors: +* Wei Liang Lim <[email protected]> +*/ + +#include <platform_override.h> +#include <sbi_utils/fdt/fdt_helper.h> + +static bool starfive_cold_boot_allowed (u32 hartid, +const struct fdt_match *match) +{ +return (hartid ==1 ); +} + +static const struct fdt_match starfive_jh7110_match[] = { + { .compatible ="starfive,jh7110" }, + { }, +}; + +const struct platform_override starfive_jh7110 = { + .match_table = starfive_jh7110_match, + .cold_boot_allowed = starfive_cold_boot_allowed, +};
platform/generic/starfive/objects.mk new file +6 -0
@@ -0,0 +1,6 @@ +# +# SPDX-License-Identifier: BSD-2-Clause +# + +carray-platform_override_modules-$(CONFIG_PLATFORM_STARFIVE_JH7110) += starfive_jh7110 +platform-objs-$(CONFIG_PLATFORM_STARFIVE_JH7110) += starfive/jh7110.o
Signature · 1 line
2.25.1
PATCH v3 3/3 generic/starfive: Add Starfive JH7110 platform implementation
Quoted 52 lines · Wei Liang Lim
Add Starfive JH7110 platform implementation
Signed-off-by Wei Liang Lim <[email protected]>Reviewed-by Chee Hong Ang <[email protected]>Reviewed-by Jun Liang Tan <[email protected]>---
platform/generic/Kconfig | 4 ++++ platform/generic/configs/defconfig | 1 + platform/generic/starfive/jh7110.c | 27 +++++++++++++++++++++++++++ platform/generic/starfive/objects.mk | 6 ++++++ 4 files changed, 38 insertions(+)create mode 100644
platform/generic/starfive/jh7110.ccreate mode 100644platform/generic/starfive/objects.mkplatform/generic/Kconfig +4
-0@@ -41,4 +41,8 @@ config PLATFORM_SIFIVE_FU740 depends on FDT_RESET && FDT_I2C default n +config PLATFORM_STARFIVE_JH7110 + bool "StarFive JH7110 support" + default n +endif
platform/generic/configs/defconfig +0
-0@@ -2,6 +2,7 @@ CONFIG_PLATFORM_ALLWINNER_D1=y
CONFIG_PLATFORM_ANDES_AE350=yCONFIG_PLATFORM_SIFIVE_FU540=yCONFIG_PLATFORM_SIFIVE_FU740=y
+CONFIG_PLATFORM_STARFIVE_JH7110=yCONFIG_FDT_GPIO=yCONFIG_FDT_GPIO_SIFIVE=yCONFIG_FDT_I2C=yplatform/generic/starfive/jh7110.c new file +6
-0@@ -0,0 +1,27 @@ +/* +* SPDX-License-Identifier: BSD-2-Clause +* +* Copyright (c) 2022 StarFive +* +* Authors:
platform/generic/starfive/jh7110.c line 16
Quoted 10 lines
platform/generic/starfive/jh7110.c new file +10
-0+* Wei Liang Lim <[email protected]> +*/ + +#include <platform_override.h> +#include <sbi_utils/fdt/fdt_helper.h> + +static bool starfive_cold_boot_allowed (u32 hartid, +const struct fdt_match *match) +{ +return (hartid ==1 );
Why? I thought in an earlier thread it was said this was just a debugging thing and you should fix whatever bug this masks another way.
This at least needs a justification in the source code.
Jess
Quoted 31 lines
platform/generic/starfive/jh7110.c new file +11
-0+} + +static const struct fdt_match starfive_jh7110_match[] = { + { .compatible ="starfive,jh7110" }, + { }, +}; + +const struct platform_override starfive_jh7110 = { + .match_table = starfive_jh7110_match, + .cold_boot_allowed = starfive_cold_boot_allowed, +};platform/generic/starfive/objects.mk new file +6
-0@@ -0,0 +1,6 @@ +# +# SPDX-License-Identifier: BSD-2-Clause +# + +carray-platform_override_modules-$(CONFIG_PLATFORM_STARFIVE_JH7110) += starfive_jh7110 +platform-objs-$(CONFIG_PLATFORM_STARFIVE_JH7110) += starfive/jh7110.oSignature · 7 lines
2.25.1 -- opensbi mailing list opensbi at lists.infradead.org http://lists.infradead.org/mailman/listinfo/opensbi
PATCH v3 3/3 generic/starfive: Add Starfive JH7110 platform implementation
Quoted 81 lines
-----Original Message-----
From: Jessica Clarke <[email protected]>
Sent: Monday, December 12, 2022 1:40 PM
To: WeiLiang Lim <[email protected]>
Cc: opensbi <[email protected]>; Anup Patel <[email protected]>; Cheehong Ang <[email protected]>; JunLiang Tan <[email protected]>
Subject: Re: [PATCH v3 3/3] generic/starfive: Add Starfive JH7110 platform implementationQuoted 52 lines · Wei Liang Lim
Add Starfive JH7110 platform implementation
Signed-off-by Wei Liang Lim <[email protected]>Reviewed-by Chee Hong Ang <[email protected]>Reviewed-by Jun Liang Tan <[email protected]>---
platform/generic/Kconfig | 4 ++++ platform/generic/configs/defconfig | 1 + platform/generic/starfive/jh7110.c | 27 +++++++++++++++++++++++++++ platform/generic/starfive/objects.mk | 6 ++++++ 4 files changed, 38 insertions(+)create mode 100644
platform/generic/starfive/jh7110.ccreate mode 100644platform/generic/starfive/objects.mkplatform/generic/Kconfig index renamed from platform/generic/Kconfig +0
-04b5d2cd..a6e467d 100644
platform/generic/Kconfig +4
-0@@ -41,4 +41,8 @@ config PLATFORM_SIFIVE_FU740 depends on FDT_RESET && FDT_I2C default n +config PLATFORM_STARFIVE_JH7110 + bool "StarFive JH7110 support" + default n +endif
platform/generic/configs/defconfig +0
-0@@ -2,6 +2,7 @@ CONFIG_PLATFORM_ALLWINNER_D1=y
CONFIG_PLATFORM_ANDES_AE350=yCONFIG_PLATFORM_SIFIVE_FU540=yCONFIG_PLATFORM_SIFIVE_FU740=y+CONFIG_PLATFORM_STARFIVE_JH7110=yCONFIG_FDT_GPIO=yCONFIG_FDT_GPIO_SIFIVE=yCONFIG_FDT_I2C=yplatform/generic/starfive/jh7110.c new file +5
-0@@ -0,0 +1,27 @@ +/* +* SPDX-License-Identifier: BSD-2-Clause +* +* Copyright (c) 2022 StarFive +* platform/generic/starfive/jh7110.c line 15
Quoted 10 lines
platform/generic/starfive/jh7110.c new file +10
-0+* Authors: +* Wei Liang Lim <[email protected]> +*/ + +#include <platform_override.h> +#include <sbi_utils/fdt/fdt_helper.h> + +static bool starfive_cold_boot_allowed (u32 hartid, +const struct fdt_match *match) { +return (hartid ==1 );Why? I thought in an earlier thread it was said this was just a debugging thing and you should fix whatever bug this masks another way.
Quoted 3 lines
This at least needs a justification in the source code.
Jess
Hi Jess,
Sorry I did something wrong previously causing some patch being missed out.
Please refer to my latest submission.
In earlier conversation, Anup helped to review and suggested patches to allow platform to influence cold boot HART selection and allow platform_override to select cold boot HART. Together with Anup's patches I have included StarFive platform specific implementation.
Thanks
Quoted 34 lines
Quoted 18 lines
platform/generic/starfive/jh7110.c new file +10
-0+} + +static const struct fdt_match starfive_jh7110_match[] = { + { .compatible ="starfive,jh7110" }, + { }, +}; + +const struct platform_override starfive_jh7110 = { + .match_table = starfive_jh7110_match, + .cold_boot_allowed = starfive_cold_boot_allowed, };platform/generic/starfive/objects.mk new file +0
-0platform/generic/starfive/objects.mk line 4
Quoted 4 lines
platform/generic/starfive/objects.mk new file +4
-0@@ -0,0 +1,6 @@ +# +# SPDX-License-Identifier: BSD-2-Clause # + +carray-platform_override_modules-$(CONFIG_PLATFORM_STARFIVE_JH7110)
platform/generic/starfive/objects.mk line 6
Quoted 2 lines
platform/generic/starfive/objects.mk new file +2
-0++= starfive_jh7110 +platform-objs-$(CONFIG_PLATFORM_STARFIVE_JH7110) +=
starfive/jh7110.oQuoted 8 lines
--
2.25.1--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
PATCH v3 3/3 generic/starfive: Add Starfive JH7110 platform implementation
Quoted 84 lines · WeiLiang Lim
Quoted 84 lines
-----Original Message-----
From: Jessica Clarke <[email protected]>
Sent: Monday, December 12, 2022 1:40 PM
To: WeiLiang Lim <[email protected]>
Cc: opensbi <[email protected]>; Anup Patel <[email protected]>; Cheehong Ang <[email protected]>; JunLiang Tan <[email protected]>
Subject: Re: [PATCH v3 3/3] generic/starfive: Add Starfive JH7110 platform implementationQuoted 52 lines · Wei Liang Lim
Add Starfive JH7110 platform implementation
Signed-off-by Wei Liang Lim <[email protected]>Reviewed-by Chee Hong Ang <[email protected]>Reviewed-by Jun Liang Tan <[email protected]>---
platform/generic/Kconfig | 4 ++++ platform/generic/configs/defconfig | 1 + platform/generic/starfive/jh7110.c | 27 +++++++++++++++++++++++++++ platform/generic/starfive/objects.mk | 6 ++++++ 4 files changed, 38 insertions(+)create mode 100644
platform/generic/starfive/jh7110.ccreate mode 100644platform/generic/starfive/objects.mkplatform/generic/Kconfig index renamed from platform/generic/Kconfig +0
-04b5d2cd..a6e467d 100644
platform/generic/Kconfig +4
-0@@ -41,4 +41,8 @@ config PLATFORM_SIFIVE_FU740 depends on FDT_RESET && FDT_I2C default n +config PLATFORM_STARFIVE_JH7110 + bool "StarFive JH7110 support" + default n +endif
platform/generic/configs/defconfig +0
-0@@ -2,6 +2,7 @@ CONFIG_PLATFORM_ALLWINNER_D1=y
CONFIG_PLATFORM_ANDES_AE350=yCONFIG_PLATFORM_SIFIVE_FU540=yCONFIG_PLATFORM_SIFIVE_FU740=y+CONFIG_PLATFORM_STARFIVE_JH7110=yCONFIG_FDT_GPIO=yCONFIG_FDT_GPIO_SIFIVE=yCONFIG_FDT_I2C=yplatform/generic/starfive/jh7110.c new file +5
-0@@ -0,0 +1,27 @@ +/* +* SPDX-License-Identifier: BSD-2-Clause +* +* Copyright (c) 2022 StarFive +* platform/generic/starfive/jh7110.c line 15
Quoted 10 lines
platform/generic/starfive/jh7110.c new file +10
-0+* Authors: +* Wei Liang Lim <[email protected]> +*/ + +#include <platform_override.h> +#include <sbi_utils/fdt/fdt_helper.h> + +static bool starfive_cold_boot_allowed (u32 hartid, +const struct fdt_match *match) { +return (hartid ==1 );Why? I thought in an earlier thread it was said this was just a debugging thing and you should fix whatever bug this masks another way.
This at least needs a justification in the source code.
Quoted 7 lines
Quoted 1 line
Jess
Hi Jess,
Sorry I did something wrong previously causing some patch being missed out.
Please refer to my latest submission.
In earlier conversation, Anup helped to review and suggested patches to allow platform to influence cold boot HART selection and allowplatform_overrideto select cold boot HART. Together with Anup's patches I have included StarFive platform specific implementation.
But why does the JH110 need this?
Jess
Quoted 34 lines
Quoted 34 lines
Quoted 18 lines
platform/generic/starfive/jh7110.c new file +10
-0+} + +static const struct fdt_match starfive_jh7110_match[] = { + { .compatible ="starfive,jh7110" }, + { }, +}; + +const struct platform_override starfive_jh7110 = { + .match_table = starfive_jh7110_match, + .cold_boot_allowed = starfive_cold_boot_allowed, };platform/generic/starfive/objects.mk new file +0
-0platform/generic/starfive/objects.mk line 4
Quoted 4 lines
platform/generic/starfive/objects.mk new file +4
-0@@ -0,0 +1,6 @@ +# +# SPDX-License-Identifier: BSD-2-Clause # + +carray-platform_override_modules-$(CONFIG_PLATFORM_STARFIVE_JH7110)
platform/generic/starfive/objects.mk line 6
Quoted 2 lines
platform/generic/starfive/objects.mk new file +2
-0++= starfive_jh7110 +platform-objs-$(CONFIG_PLATFORM_STARFIVE_JH7110) +=
starfive/jh7110.oQuoted 8 lines
--
2.25.1--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
PATCH v3 3/3 generic/starfive: Add Starfive JH7110 platform implementation
Quoted 108 lines
-----Original Message-----
From: Jessica Clarke <[email protected]>
Sent: Monday, December 12, 2022 2:05 PM
To: WeiLiang Lim <[email protected]>
Cc: opensbi <[email protected]>; Anup Patel <[email protected]>; Cheehong Ang <[email protected]>; JunLiang Tan <[email protected]>
Subject: Re: [PATCH v3 3/3] generic/starfive: Add Starfive JH7110 platform implementationQuoted 40 lines · WeiLiang Lim
Quoted 40 lines
-----Original Message-----
From: Jessica Clarke <[email protected]>
Sent: Monday, December 12, 2022 1:40 PM
To: WeiLiang Lim <[email protected]>
Cc: opensbi <[email protected]>; Anup Patel <[email protected]>; Cheehong Ang <[email protected]>; JunLiang Tan <[email protected]>
Subject: Re: [PATCH v3 3/3] generic/starfive: Add Starfive JH7110 platform implementationQuoted 23 lines · Wei Liang Lim
Add Starfive JH7110 platform implementation
Signed-off-by Wei Liang Lim <[email protected]>Reviewed-by Chee Hong Ang <[email protected]>Reviewed-by Jun Liang Tan <[email protected]>---
platform/generic/Kconfig | 4 ++++ platform/generic/configs/defconfig | 1 + platform/generic/starfive/jh7110.c | 27 +++++++++++++++++++++++++++ platform/generic/starfive/objects.mk | 6 ++++++ 4 files changed, 38 insertions(+)create mode 100644
platform/generic/starfive/jh7110.ccreate mode 100644platform/generic/starfive/objects.mkplatform/generic/Kconfig +0
-0@@ -41,4 +41,8 @@ config PLATFORM_SIFIVE_FU740 depends on FDT_RESET && FDT_I2C default nQuoted 12 lines
Quoted 4 lines
Quoted 4 lines
platform/generic/Kconfig +4
-0+config PLATFORM_STARFIVE_JH7110 + bool "StarFive JH7110 support" + default n +Quoted 8 lines
Quoted 8 lines
endif
platform/generic/configs/defconfig +0
-0@@ -2,6 +2,7 @@ CONFIG_PLATFORM_ALLWINNER_D1=y
CONFIG_PLATFORM_ANDES_AE350=y
CONFIG_PLATFORM_SIFIVE_FU540=yQuoted 33 lines
Quoted 33 lines
Quoted 17 lines
CONFIG_PLATFORM_SIFIVE_FU740=y
+CONFIG_PLATFORM_STARFIVE_JH7110=yCONFIG_FDT_GPIO=yCONFIG_FDT_GPIO_SIFIVE=yCONFIG_FDT_I2C=yplatform/generic/starfive/jh7110.c new file +5
-0@@ -0,0 +1,27 @@ +/* +* SPDX-License-Identifier: BSD-2-Clause +* +* Copyright (c) 2022 StarFive +* platform/generic/starfive/jh7110.c line 15
Quoted 10 lines
platform/generic/starfive/jh7110.c new file +10
-0+* Authors: +* Wei Liang Lim <[email protected]> +*/ + +#include <platform_override.h> +#include <sbi_utils/fdt/fdt_helper.h> + +static bool starfive_cold_boot_allowed (u32 hartid, +const struct fdt_match *match) { +return (hartid ==1 );Why? I thought in an earlier thread it was said this was just a debugging thing and you should fix whatever bug this masks another way.
This at least needs a justification in the source code.
Quoted 7 lines
Quoted 1 line
Jess
Hi Jess,
Sorry I did something wrong previously causing some patch being missed out. Please refer to my latest submission.
In earlier conversation, Anup helped to review and suggested patches to
Quoted 8 lines
allow platform to influence cold boot HART selection and allow
platform_overrideto select cold boot HART. Together with Anup's patches I have included StarFive platform specific implementation.But why does the JH110 need this?
Jess
Hi Jess,
This is mainly to support our customer request which they need a preferred boot hart in their product application.
For better flexibility, we are planning for a v4 version where user can have the option to specify the preferred boot hart in dts chosen node. If unspecified, it will just use the current default lottery mechanism.
Thanks
Quoted 34 lines
Quoted 34 lines
Quoted 34 lines
Quoted 18 lines
platform/generic/starfive/jh7110.c new file +10
-0+} + +static const struct fdt_match starfive_jh7110_match[] = { + { .compatible ="starfive,jh7110" }, + { }, +}; + +const struct platform_override starfive_jh7110 = { + .match_table = starfive_jh7110_match, + .cold_boot_allowed = starfive_cold_boot_allowed, };platform/generic/starfive/objects.mk new file +0
-0platform/generic/starfive/objects.mk line 4
Quoted 4 lines
platform/generic/starfive/objects.mk new file +4
-0@@ -0,0 +1,6 @@ +# +# SPDX-License-Identifier: BSD-2-Clause # + +carray-platform_override_modules-$(CONFIG_PLATFORM_STARFIVE_JH7110)
platform/generic/starfive/objects.mk line 6
Quoted 2 lines
platform/generic/starfive/objects.mk new file +2
-0++= starfive_jh7110 +platform-objs-$(CONFIG_PLATFORM_STARFIVE_JH7110) +=
starfive/jh7110.oQuoted 8 lines
--
2.25.1--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi