2023-02-04 05:51:26

by Randy Dunlap

[permalink] [raw]
Subject: [PATCH v2] sh: init: use OF_EARLY_FLATTREE for early init

When CONFIG_OF_EARLY_FLATTREE and CONFIG_SH_DEVICE_TREE are not set,
SH3 build fails with a call to early_init_dt_scan(), so in
arch/sh/kernel/setup.c and arch/sh/kernel/head_32.S, use
CONFIG_OF_EARLY_FLATTREE instead of CONFIG_OF_FLATTREE.

Fixes this build error:
../arch/sh/kernel/setup.c: In function 'sh_fdt_init':
../arch/sh/kernel/setup.c:262:26: error: implicit declaration of function 'early_init_dt_scan' [-Werror=implicit-function-declaration]
262 | if (!dt_virt || !early_init_dt_scan(dt_virt)) {

Fixes: 03767daa1387 ("sh: fix build regression with CONFIG_OF && !CONFIG_OF_FLATTREE")
Fixes: eb6b6930a70f ("sh: fix memory corruption of unflattened device tree")
Signed-off-by: Randy Dunlap <[email protected]>
Suggested-by: Rob Herring <[email protected]>
Cc: Frank Rowand <[email protected]>
Cc: [email protected]
Cc: Rich Felker <[email protected]>
Cc: Yoshinori Sato <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Geert Uytterhoeven <[email protected]>
Cc: John Paul Adrian Glaubitz <[email protected]>
Cc: [email protected]
---
v2: use Suggested-by: for Rob.
add more Cc's.

arch/sh/kernel/head_32.S | 6 +++---
arch/sh/kernel/setup.c | 4 ++--
2 files changed, 5 insertions(+), 5 deletions(-)

diff arch/sh/kernel/setup.c arch/sh/kernel/setup.c
diff -- a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -244,7 +244,7 @@ void __init __weak plat_early_device_set
{
}

-#ifdef CONFIG_OF_FLATTREE
+#ifdef CONFIG_OF_EARLY_FLATTREE
void __ref sh_fdt_init(phys_addr_t dt_phys)
{
static int done = 0;
@@ -326,7 +326,7 @@ void __init setup_arch(char **cmdline_p)
/* Let earlyprintk output early console messages */
sh_early_platform_driver_probe("earlyprintk", 1, 1);

-#ifdef CONFIG_OF_FLATTREE
+#ifdef CONFIG_OF_EARLY_FLATTREE
#ifdef CONFIG_USE_BUILTIN_DTB
unflatten_and_copy_device_tree();
#else
diff -- a/arch/sh/kernel/head_32.S b/arch/sh/kernel/head_32.S
--- a/arch/sh/kernel/head_32.S
+++ b/arch/sh/kernel/head_32.S
@@ -64,7 +64,7 @@ ENTRY(_stext)
ldc r0, r6_bank
#endif

-#ifdef CONFIG_OF_FLATTREE
+#ifdef CONFIG_OF_EARLY_FLATTREE
mov r4, r12 ! Store device tree blob pointer in r12
#endif

@@ -315,7 +315,7 @@ ENTRY(_stext)
10:
#endif

-#ifdef CONFIG_OF_FLATTREE
+#ifdef CONFIG_OF_EARLY_FLATTREE
mov.l 8f, r0 ! Make flat device tree available early.
jsr @r0
mov r12, r4
@@ -346,7 +346,7 @@ ENTRY(stack_start)
5: .long start_kernel
6: .long cpu_init
7: .long init_thread_union
-#if defined(CONFIG_OF_FLATTREE)
+#if defined(CONFIG_OF_EARLY_FLATTREE)
8: .long sh_fdt_init
#endif



2023-02-04 07:06:20

by D. Jeff Dionne

[permalink] [raw]
Subject: Re: [PATCH v2] sh: init: use OF_EARLY_FLATTREE for early init

Randy, which SH3 chipset target are you building for? Of course all that stay need to be converted to device tree, but a DT SH3 proof of existence that you build for already will surely cover good swath of the missing drivers.

J.

> On Feb 4, 2023, at 14:51, Randy Dunlap <[email protected]> wrote:
>
> When CONFIG_OF_EARLY_FLATTREE and CONFIG_SH_DEVICE_TREE are not set,
> SH3 build fails with a call to early_init_dt_scan(), so in
> arch/sh/kernel/setup.c and arch/sh/kernel/head_32.S, use
> CONFIG_OF_EARLY_FLATTREE instead of CONFIG_OF_FLATTREE.
>
> Fixes this build error:
> ../arch/sh/kernel/setup.c: In function 'sh_fdt_init':
> ../arch/sh/kernel/setup.c:262:26: error: implicit declaration of function 'early_init_dt_scan' [-Werror=implicit-function-declaration]
> 262 | if (!dt_virt || !early_init_dt_scan(dt_virt)) {
>
> Fixes: 03767daa1387 ("sh: fix build regression with CONFIG_OF && !CONFIG_OF_FLATTREE")
> Fixes: eb6b6930a70f ("sh: fix memory corruption of unflattened device tree")
> Signed-off-by: Randy Dunlap <[email protected]>
> Suggested-by: Rob Herring <[email protected]>
> Cc: Frank Rowand <[email protected]>
> Cc: [email protected]
> Cc: Rich Felker <[email protected]>
> Cc: Yoshinori Sato <[email protected]>
> Cc: Arnd Bergmann <[email protected]>
> Cc: Geert Uytterhoeven <[email protected]>
> Cc: John Paul Adrian Glaubitz <[email protected]>
> Cc: [email protected]
> ---
> v2: use Suggested-by: for Rob.
> add more Cc's.
>
> arch/sh/kernel/head_32.S | 6 +++---
> arch/sh/kernel/setup.c | 4 ++--
> 2 files changed, 5 insertions(+), 5 deletions(-)
>
> diff arch/sh/kernel/setup.c arch/sh/kernel/setup.c
> diff -- a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
> --- a/arch/sh/kernel/setup.c
> +++ b/arch/sh/kernel/setup.c
> @@ -244,7 +244,7 @@ void __init __weak plat_early_device_set
> {
> }
>
> -#ifdef CONFIG_OF_FLATTREE
> +#ifdef CONFIG_OF_EARLY_FLATTREE
> void __ref sh_fdt_init(phys_addr_t dt_phys)
> {
> static int done = 0;
> @@ -326,7 +326,7 @@ void __init setup_arch(char **cmdline_p)
> /* Let earlyprintk output early console messages */
> sh_early_platform_driver_probe("earlyprintk", 1, 1);
>
> -#ifdef CONFIG_OF_FLATTREE
> +#ifdef CONFIG_OF_EARLY_FLATTREE
> #ifdef CONFIG_USE_BUILTIN_DTB
> unflatten_and_copy_device_tree();
> #else
> diff -- a/arch/sh/kernel/head_32.S b/arch/sh/kernel/head_32.S
> --- a/arch/sh/kernel/head_32.S
> +++ b/arch/sh/kernel/head_32.S
> @@ -64,7 +64,7 @@ ENTRY(_stext)
> ldc r0, r6_bank
> #endif
>
> -#ifdef CONFIG_OF_FLATTREE
> +#ifdef CONFIG_OF_EARLY_FLATTREE
> mov r4, r12 ! Store device tree blob pointer in r12
> #endif
>
> @@ -315,7 +315,7 @@ ENTRY(_stext)
> 10:
> #endif
>
> -#ifdef CONFIG_OF_FLATTREE
> +#ifdef CONFIG_OF_EARLY_FLATTREE
> mov.l 8f, r0 ! Make flat device tree available early.
> jsr @r0
> mov r12, r4
> @@ -346,7 +346,7 @@ ENTRY(stack_start)
> 5: .long start_kernel
> 6: .long cpu_init
> 7: .long init_thread_union
> -#if defined(CONFIG_OF_FLATTREE)
> +#if defined(CONFIG_OF_EARLY_FLATTREE)
> 8: .long sh_fdt_init
> #endif
>


2023-02-04 07:13:16

by Randy Dunlap

[permalink] [raw]
Subject: Re: [PATCH v2] sh: init: use OF_EARLY_FLATTREE for early init



On 2/3/23 23:05, D. Jeff Dionne wrote:
> Randy, which SH3 chipset target are you building for? Of course all that stay need to be converted to device tree, but a DT SH3 proof of existence that you build for already will surely cover good swath of the missing drivers.
>

Hi Jeff,
I don't have a specific target. I'm just fixing a build error.

>
>> On Feb 4, 2023, at 14:51, Randy Dunlap <[email protected]> wrote:
>>
>> When CONFIG_OF_EARLY_FLATTREE and CONFIG_SH_DEVICE_TREE are not set,
>> SH3 build fails with a call to early_init_dt_scan(), so in
>> arch/sh/kernel/setup.c and arch/sh/kernel/head_32.S, use
>> CONFIG_OF_EARLY_FLATTREE instead of CONFIG_OF_FLATTREE.
>>
>> Fixes this build error:
>> ../arch/sh/kernel/setup.c: In function 'sh_fdt_init':
>> ../arch/sh/kernel/setup.c:262:26: error: implicit declaration of function 'early_init_dt_scan' [-Werror=implicit-function-declaration]
>> 262 | if (!dt_virt || !early_init_dt_scan(dt_virt)) {
>>
>> Fixes: 03767daa1387 ("sh: fix build regression with CONFIG_OF && !CONFIG_OF_FLATTREE")
>> Fixes: eb6b6930a70f ("sh: fix memory corruption of unflattened device tree")
>> Signed-off-by: Randy Dunlap <[email protected]>
>> Suggested-by: Rob Herring <[email protected]>
>> Cc: Frank Rowand <[email protected]>
>> Cc: [email protected]
>> Cc: Rich Felker <[email protected]>
>> Cc: Yoshinori Sato <[email protected]>
>> Cc: Arnd Bergmann <[email protected]>
>> Cc: Geert Uytterhoeven <[email protected]>
>> Cc: John Paul Adrian Glaubitz <[email protected]>
>> Cc: [email protected]
>> ---
>> v2: use Suggested-by: for Rob.
>> add more Cc's.
>>
>> arch/sh/kernel/head_32.S | 6 +++---
>> arch/sh/kernel/setup.c | 4 ++--
>> 2 files changed, 5 insertions(+), 5 deletions(-)
>>
>> diff arch/sh/kernel/setup.c arch/sh/kernel/setup.c
>> diff -- a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
>> --- a/arch/sh/kernel/setup.c
>> +++ b/arch/sh/kernel/setup.c
>> @@ -244,7 +244,7 @@ void __init __weak plat_early_device_set
>> {
>> }
>>
>> -#ifdef CONFIG_OF_FLATTREE
>> +#ifdef CONFIG_OF_EARLY_FLATTREE
>> void __ref sh_fdt_init(phys_addr_t dt_phys)
>> {
>> static int done = 0;
>> @@ -326,7 +326,7 @@ void __init setup_arch(char **cmdline_p)
>> /* Let earlyprintk output early console messages */
>> sh_early_platform_driver_probe("earlyprintk", 1, 1);
>>
>> -#ifdef CONFIG_OF_FLATTREE
>> +#ifdef CONFIG_OF_EARLY_FLATTREE
>> #ifdef CONFIG_USE_BUILTIN_DTB
>> unflatten_and_copy_device_tree();
>> #else
>> diff -- a/arch/sh/kernel/head_32.S b/arch/sh/kernel/head_32.S
>> --- a/arch/sh/kernel/head_32.S
>> +++ b/arch/sh/kernel/head_32.S
>> @@ -64,7 +64,7 @@ ENTRY(_stext)
>> ldc r0, r6_bank
>> #endif
>>
>> -#ifdef CONFIG_OF_FLATTREE
>> +#ifdef CONFIG_OF_EARLY_FLATTREE
>> mov r4, r12 ! Store device tree blob pointer in r12
>> #endif
>>
>> @@ -315,7 +315,7 @@ ENTRY(_stext)
>> 10:
>> #endif
>>
>> -#ifdef CONFIG_OF_FLATTREE
>> +#ifdef CONFIG_OF_EARLY_FLATTREE
>> mov.l 8f, r0 ! Make flat device tree available early.
>> jsr @r0
>> mov r12, r4
>> @@ -346,7 +346,7 @@ ENTRY(stack_start)
>> 5: .long start_kernel
>> 6: .long cpu_init
>> 7: .long init_thread_union
>> -#if defined(CONFIG_OF_FLATTREE)
>> +#if defined(CONFIG_OF_EARLY_FLATTREE)
>> 8: .long sh_fdt_init
>> #endif
>>
>

--
~Randy