u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] board: sifive: Fix a potential build warning in board_fdt_blob_setup()
@ 2021-09-11 14:31 Bin Meng
  2021-09-14  8:21 ` Leo Liang
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Bin Meng @ 2021-09-11 14:31 UTC (permalink / raw)
  To: Zong Li, Leo Yu-Chi Liang, Rick Chen, u-boot

Commit 47d73ba4f4a4 ("board: sifive: overwrite board_fdt_blob_setup in u-boot proper")
added a board-specific implementation of board_fdt_blob_setup() which
takes a pointer as the return value, but it does not return anything
if CONFIG_OF_SEPARATE is not enabled. This will cause a build warning
seen when testing booting S-mode U-Boot directly from QEMU, per the
instructions in [1]:

  board/sifive/unleashed/unleashed.c: In function ‘board_fdt_blob_setup’:
  board/sifive/unleashed/unleashed.c:125:1: warning: control reaches end of non-void function [-Wreturn-type]

Return &_end as the default case.

[1] https://qemu.readthedocs.io/en/latest/system/riscv/sifive_u.html#running-u-boot

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>

---

Changes in v2:
- Correct the commit title

 board/sifive/unleashed/unleashed.c | 4 ++--
 board/sifive/unmatched/unmatched.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/board/sifive/unleashed/unleashed.c b/board/sifive/unleashed/unleashed.c
index 8cd514df30..33baeda986 100644
--- a/board/sifive/unleashed/unleashed.c
+++ b/board/sifive/unleashed/unleashed.c
@@ -119,9 +119,9 @@ void *board_fdt_blob_setup(void)
 	if (IS_ENABLED(CONFIG_OF_SEPARATE)) {
 		if (gd->arch.firmware_fdt_addr)
 			return (ulong *)gd->arch.firmware_fdt_addr;
-		else
-			return (ulong *)&_end;
 	}
+
+	return (ulong *)&_end;
 }
 
 int board_init(void)
diff --git a/board/sifive/unmatched/unmatched.c b/board/sifive/unmatched/unmatched.c
index d90b252bae..8773b660fa 100644
--- a/board/sifive/unmatched/unmatched.c
+++ b/board/sifive/unmatched/unmatched.c
@@ -16,9 +16,9 @@ void *board_fdt_blob_setup(void)
 	if (IS_ENABLED(CONFIG_OF_SEPARATE)) {
 		if (gd->arch.firmware_fdt_addr)
 			return (ulong *)gd->arch.firmware_fdt_addr;
-		else
-			return (ulong *)&_end;
 	}
+
+	return (ulong *)&_end;
 }
 
 int board_init(void)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] board: sifive: Fix a potential build warning in board_fdt_blob_setup()
  2021-09-11 14:31 [PATCH v2] board: sifive: Fix a potential build warning in board_fdt_blob_setup() Bin Meng
@ 2021-09-14  8:21 ` Leo Liang
       [not found] ` <HK0PR03MB299484FCB8C64939BB8F91E6C1DD9@HK0PR03MB2994.apcprd03.prod.outlook.com>
  2021-09-29 13:07 ` Ilias Apalodimas
  2 siblings, 0 replies; 7+ messages in thread
From: Leo Liang @ 2021-09-14  8:21 UTC (permalink / raw)
  To: Bin Meng; +Cc: Zong Li, Rick Chen, u-boot

On Sat, Sep 11, 2021 at 10:31:23PM +0800, Bin Meng wrote:
> Commit 47d73ba4f4a4 ("board: sifive: overwrite board_fdt_blob_setup in u-boot proper")
> added a board-specific implementation of board_fdt_blob_setup() which
> takes a pointer as the return value, but it does not return anything
> if CONFIG_OF_SEPARATE is not enabled. This will cause a build warning
> seen when testing booting S-mode U-Boot directly from QEMU, per the
> instructions in [1]:
>
>   board/sifive/unleashed/unleashed.c: In function ‘board_fdt_blob_setup’:
>   board/sifive/unleashed/unleashed.c:125:1: warning: control reaches end of non-void function [-Wreturn-type]
>
> Return &_end as the default case.
>
> [1] https://qemu.readthedocs.io/en/latest/system/riscv/sifive_u.html#running-u-boot
>
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>

Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
CONFIDENTIALITY NOTICE:

This e-mail (and its attachments) may contain confidential and legally privileged information or information protected from disclosure. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein is strictly prohibited. In this case, please immediately notify the sender by return e-mail, delete the message (and any accompanying documents) and destroy all printed hard copies. Thank you for your cooperation.

Copyright ANDES TECHNOLOGY CORPORATION - All Rights Reserved.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] board: sifive: Fix a potential build warning in board_fdt_blob_setup()
       [not found] ` <HK0PR03MB299484FCB8C64939BB8F91E6C1DD9@HK0PR03MB2994.apcprd03.prod.outlook.com>
@ 2021-09-17  6:52   ` Rick Chen
  2021-10-11  3:13     ` Bin Meng
  0 siblings, 1 reply; 7+ messages in thread
From: Rick Chen @ 2021-09-17  6:52 UTC (permalink / raw)
  To: Bin Meng; +Cc: U-Boot Mailing List, zong.li, Leo Liang, rick

> From: Bin Meng <bmeng.cn@gmail.com>
> Sent: Saturday, September 11, 2021 10:31 PM
> To: Zong Li <zong.li@sifive.com>; Leo Yu-Chi Liang(梁育齊) <ycliang@andestech.com>; Rick Jian-Zhi Chen(陳建志) <rick@andestech.com>; u-boot@lists.denx.de
> Subject: [PATCH v2] board: sifive: Fix a potential build warning in board_fdt_blob_setup()
>
> Commit 47d73ba4f4a4 ("board: sifive: overwrite board_fdt_blob_setup in u-boot proper") added a board-specific implementation of board_fdt_blob_setup() which takes a pointer as the return value, but it does not return anything if CONFIG_OF_SEPARATE is not enabled. This will cause a build warning seen when testing booting S-mode U-Boot directly from QEMU, per the instructions in [1]:
>
>   board/sifive/unleashed/unleashed.c: In function ‘board_fdt_blob_setup’:
>   board/sifive/unleashed/unleashed.c:125:1: warning: control reaches end of non-void function [-Wreturn-type]
>
> Return &_end as the default case.
>
> [1] https://qemu.readthedocs.io/en/latest/system/riscv/sifive_u.html#running-u-boot
>
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
>
> ---
>
> Changes in v2:
> - Correct the commit title
>
>  board/sifive/unleashed/unleashed.c | 4 ++--  board/sifive/unmatched/unmatched.c | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)

Reviewed-by: Rick Chen <rick@andestech.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] board: sifive: Fix a potential build warning in board_fdt_blob_setup()
  2021-09-11 14:31 [PATCH v2] board: sifive: Fix a potential build warning in board_fdt_blob_setup() Bin Meng
  2021-09-14  8:21 ` Leo Liang
       [not found] ` <HK0PR03MB299484FCB8C64939BB8F91E6C1DD9@HK0PR03MB2994.apcprd03.prod.outlook.com>
@ 2021-09-29 13:07 ` Ilias Apalodimas
  2021-09-29 14:03   ` Bin Meng
  2 siblings, 1 reply; 7+ messages in thread
From: Ilias Apalodimas @ 2021-09-29 13:07 UTC (permalink / raw)
  To: Bin Meng; +Cc: Zong Li, Leo Yu-Chi Liang, Rick Chen, u-boot

Hi Bin

There's a similar discussion in a cleanup series I've sent [1]
On Sat, Sep 11, 2021 at 10:31:23PM +0800, Bin Meng wrote:
> Commit 47d73ba4f4a4 ("board: sifive: overwrite board_fdt_blob_setup in u-boot proper")
> added a board-specific implementation of board_fdt_blob_setup() which
> takes a pointer as the return value, but it does not return anything
> if CONFIG_OF_SEPARATE is not enabled. This will cause a build warning
> seen when testing booting S-mode U-Boot directly from QEMU, per the
> instructions in [1]:

It's not only a build warning, you don't even have a DTB to begin with.

> 
>   board/sifive/unleashed/unleashed.c: In function ‘board_fdt_blob_setup’:
>   board/sifive/unleashed/unleashed.c:125:1: warning: control reaches end of non-void function [-Wreturn-type]
> 
> Return &_end as the default case.
> 
> [1] https://qemu.readthedocs.io/en/latest/system/riscv/sifive_u.html#running-u-boot
> 
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> 
> ---
> 
> Changes in v2:
> - Correct the commit title
> 
>  board/sifive/unleashed/unleashed.c | 4 ++--
>  board/sifive/unmatched/unmatched.c | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/board/sifive/unleashed/unleashed.c b/board/sifive/unleashed/unleashed.c
> index 8cd514df30..33baeda986 100644
> --- a/board/sifive/unleashed/unleashed.c
> +++ b/board/sifive/unleashed/unleashed.c
> @@ -119,9 +119,9 @@ void *board_fdt_blob_setup(void)
>  	if (IS_ENABLED(CONFIG_OF_SEPARATE)) {
>  		if (gd->arch.firmware_fdt_addr)
>  			return (ulong *)gd->arch.firmware_fdt_addr;
> -		else
> -			return (ulong *)&_end;
>  	}
> +
> +	return (ulong *)&_end;
>  }
>  
>  int board_init(void)
> diff --git a/board/sifive/unmatched/unmatched.c b/board/sifive/unmatched/unmatched.c
> index d90b252bae..8773b660fa 100644
> --- a/board/sifive/unmatched/unmatched.c
> +++ b/board/sifive/unmatched/unmatched.c
> @@ -16,9 +16,9 @@ void *board_fdt_blob_setup(void)
>  	if (IS_ENABLED(CONFIG_OF_SEPARATE)) {
>  		if (gd->arch.firmware_fdt_addr)
>  			return (ulong *)gd->arch.firmware_fdt_addr;
> -		else
> -			return (ulong *)&_end;
>  	}
> +
> +	return (ulong *)&_end;

is _end correct here? Doesn't the placement depend on CONFIG_SPL_BUILD and
CONFIG_SPL_SEPARATE_BSS?

To sum up the other thread I think the overall approach here is not ideal.
OF_SEPARATE is used in conjunction with SPL in these boards.  What happens
(assuming I didn't miss anything),  is that SPL passes the DTB to OpenSBI,
which in it turn copies to a1 before invoking U-Boot.
But we are better of with stricter rules for DTB.
- OF_SEPARATE means: I'll read the DTB from the U-Boot binary. 
- OF_BOARD: The board will somehow provide it. 

So II think the patch should look something along the lines of:

if (IS_ENABLED(CONFIG_OF_SEPARATE)) {
#ifdef CONFIG_SPL_BUILD
        /* FDT is at end of BSS unless it is in a different memory region */
        if (IS_ENABLED(CONFIG_SPL_SEPARATE_BSS))
                fdt_blob = (void *)&_image_binary_end;
        else
                fdt_blob = (void *)&__bss_end;
#else
        /* FDT is at end of image */
        fdt_blob = (void *)&_end;

} 

if (IS_ENABLED(CONFIG_OF_BOARD)) {
	fdt_blob = (void *)gd->arch.firmware_fdt_addr;
}

>  }
>  
>  int board_init(void)
> -- 
> 2.25.1
> 

[1] https://lore.kernel.org/u-boot/YVRiVFP+sYGZhJiY@apalos.home/

Cheers
/Ilias

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] board: sifive: Fix a potential build warning in board_fdt_blob_setup()
  2021-09-29 13:07 ` Ilias Apalodimas
@ 2021-09-29 14:03   ` Bin Meng
  2021-09-29 14:59     ` Ilias Apalodimas
  0 siblings, 1 reply; 7+ messages in thread
From: Bin Meng @ 2021-09-29 14:03 UTC (permalink / raw)
  To: Ilias Apalodimas
  Cc: Zong Li, Leo Yu-Chi Liang, Rick Chen, U-Boot Mailing List

Hi Ilias,

On Wed, Sep 29, 2021 at 9:07 PM Ilias Apalodimas
<ilias.apalodimas@linaro.org> wrote:
>
> Hi Bin
>
> There's a similar discussion in a cleanup series I've sent [1]
> On Sat, Sep 11, 2021 at 10:31:23PM +0800, Bin Meng wrote:
> > Commit 47d73ba4f4a4 ("board: sifive: overwrite board_fdt_blob_setup in u-boot proper")
> > added a board-specific implementation of board_fdt_blob_setup() which
> > takes a pointer as the return value, but it does not return anything
> > if CONFIG_OF_SEPARATE is not enabled. This will cause a build warning
> > seen when testing booting S-mode U-Boot directly from QEMU, per the
> > instructions in [1]:
>
> It's not only a build warning, you don't even have a DTB to begin with.
>
> >
> >   board/sifive/unleashed/unleashed.c: In function ‘board_fdt_blob_setup’:
> >   board/sifive/unleashed/unleashed.c:125:1: warning: control reaches end of non-void function [-Wreturn-type]
> >
> > Return &_end as the default case.
> >
> > [1] https://qemu.readthedocs.io/en/latest/system/riscv/sifive_u.html#running-u-boot
> >
> > Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> >
> > ---
> >
> > Changes in v2:
> > - Correct the commit title
> >
> >  board/sifive/unleashed/unleashed.c | 4 ++--
> >  board/sifive/unmatched/unmatched.c | 4 ++--
> >  2 files changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/board/sifive/unleashed/unleashed.c b/board/sifive/unleashed/unleashed.c
> > index 8cd514df30..33baeda986 100644
> > --- a/board/sifive/unleashed/unleashed.c
> > +++ b/board/sifive/unleashed/unleashed.c
> > @@ -119,9 +119,9 @@ void *board_fdt_blob_setup(void)
> >       if (IS_ENABLED(CONFIG_OF_SEPARATE)) {
> >               if (gd->arch.firmware_fdt_addr)
> >                       return (ulong *)gd->arch.firmware_fdt_addr;
> > -             else
> > -                     return (ulong *)&_end;
> >       }
> > +
> > +     return (ulong *)&_end;
> >  }
> >
> >  int board_init(void)
> > diff --git a/board/sifive/unmatched/unmatched.c b/board/sifive/unmatched/unmatched.c
> > index d90b252bae..8773b660fa 100644
> > --- a/board/sifive/unmatched/unmatched.c
> > +++ b/board/sifive/unmatched/unmatched.c
> > @@ -16,9 +16,9 @@ void *board_fdt_blob_setup(void)
> >       if (IS_ENABLED(CONFIG_OF_SEPARATE)) {
> >               if (gd->arch.firmware_fdt_addr)
> >                       return (ulong *)gd->arch.firmware_fdt_addr;
> > -             else
> > -                     return (ulong *)&_end;
> >       }
> > +
> > +     return (ulong *)&_end;
>
> is _end correct here? Doesn't the placement depend on CONFIG_SPL_BUILD and
> CONFIG_SPL_SEPARATE_BSS?
>

I will have to leave this to Zong to comment as he introduced this via
commit 47d73ba4f4a4 ("board: sifive: overwrite board_fdt_blob_setup in
u-boot proper").

I don't know what user case that Zong wanted to support on Unleased
and Unmatched.

> To sum up the other thread I think the overall approach here is not ideal.
> OF_SEPARATE is used in conjunction with SPL in these boards.  What happens
> (assuming I didn't miss anything),  is that SPL passes the DTB to OpenSBI,
> which in it turn copies to a1 before invoking U-Boot.
> But we are better of with stricter rules for DTB.
> - OF_SEPARATE means: I'll read the DTB from the U-Boot binary.
> - OF_BOARD: The board will somehow provide it.
>
> So II think the patch should look something along the lines of:
>
> if (IS_ENABLED(CONFIG_OF_SEPARATE)) {
> #ifdef CONFIG_SPL_BUILD
>         /* FDT is at end of BSS unless it is in a different memory region */
>         if (IS_ENABLED(CONFIG_SPL_SEPARATE_BSS))
>                 fdt_blob = (void *)&_image_binary_end;
>         else
>                 fdt_blob = (void *)&__bss_end;
> #else
>         /* FDT is at end of image */
>         fdt_blob = (void *)&_end;
>

Missing #endif here?

> }
>
> if (IS_ENABLED(CONFIG_OF_BOARD)) {
>         fdt_blob = (void *)gd->arch.firmware_fdt_addr;
> }
>
> >  }
> >
> >  int board_init(void)
> > --

Regards,
Bin

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] board: sifive: Fix a potential build warning in board_fdt_blob_setup()
  2021-09-29 14:03   ` Bin Meng
@ 2021-09-29 14:59     ` Ilias Apalodimas
  0 siblings, 0 replies; 7+ messages in thread
From: Ilias Apalodimas @ 2021-09-29 14:59 UTC (permalink / raw)
  To: Bin Meng; +Cc: Zong Li, Leo Yu-Chi Liang, Rick Chen, U-Boot Mailing List

[...]
> > >  int board_init(void)
> > > diff --git a/board/sifive/unmatched/unmatched.c b/board/sifive/unmatched/unmatched.c
> > > index d90b252bae..8773b660fa 100644
> > > --- a/board/sifive/unmatched/unmatched.c
> > > +++ b/board/sifive/unmatched/unmatched.c
> > > @@ -16,9 +16,9 @@ void *board_fdt_blob_setup(void)
> > >       if (IS_ENABLED(CONFIG_OF_SEPARATE)) {
> > >               if (gd->arch.firmware_fdt_addr)
> > >                       return (ulong *)gd->arch.firmware_fdt_addr;
> > > -             else
> > > -                     return (ulong *)&_end;
> > >       }
> > > +
> > > +     return (ulong *)&_end;
> >
> > is _end correct here? Doesn't the placement depend on CONFIG_SPL_BUILD and
> > CONFIG_SPL_SEPARATE_BSS?
> >
> 
> I will have to leave this to Zong to comment as he introduced this via
> commit 47d73ba4f4a4 ("board: sifive: overwrite board_fdt_blob_setup in
> u-boot proper").
> 
> I don't know what user case that Zong wanted to support on Unleased
> and Unmatched.

Okay.  The I think we can fix this correctly.  We can probably use OF_BOARD
in those boards,  as long as the SPL generated DTB is always there and
passed over to OpenSBI.

> 
> > To sum up the other thread I think the overall approach here is not ideal.
> > OF_SEPARATE is used in conjunction with SPL in these boards.  What happens
> > (assuming I didn't miss anything),  is that SPL passes the DTB to OpenSBI,
> > which in it turn copies to a1 before invoking U-Boot.
> > But we are better of with stricter rules for DTB.
> > - OF_SEPARATE means: I'll read the DTB from the U-Boot binary.
> > - OF_BOARD: The board will somehow provide it.
> >
> > So II think the patch should look something along the lines of:
> >
> > if (IS_ENABLED(CONFIG_OF_SEPARATE)) {
> > #ifdef CONFIG_SPL_BUILD
> >         /* FDT is at end of BSS unless it is in a different memory region */
> >         if (IS_ENABLED(CONFIG_SPL_SEPARATE_BSS))
> >                 fdt_blob = (void *)&_image_binary_end;
> >         else
> >                 fdt_blob = (void *)&__bss_end;
> > #else
> >         /* FDT is at end of image */
> >         fdt_blob = (void *)&_end;
> >
> 
> Missing #endif here?o

Yea it wasn't supposed to be real code.

> 
> > }
> >
> > if (IS_ENABLED(CONFIG_OF_BOARD)) {
> >         fdt_blob = (void *)gd->arch.firmware_fdt_addr;
> > }
> >
> > >  }
> > >
> > >  int board_init(void)
> > > --
> 
> Regards,
> Bin

Regards
/Ilias

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] board: sifive: Fix a potential build warning in board_fdt_blob_setup()
  2021-09-17  6:52   ` Rick Chen
@ 2021-10-11  3:13     ` Bin Meng
  0 siblings, 0 replies; 7+ messages in thread
From: Bin Meng @ 2021-10-11  3:13 UTC (permalink / raw)
  To: Rick Chen; +Cc: U-Boot Mailing List, Zong Li, Leo Liang, rick

On Fri, Sep 17, 2021 at 2:52 PM Rick Chen <rickchen36@gmail.com> wrote:
>
> > From: Bin Meng <bmeng.cn@gmail.com>
> > Sent: Saturday, September 11, 2021 10:31 PM
> > To: Zong Li <zong.li@sifive.com>; Leo Yu-Chi Liang(梁育齊) <ycliang@andestech.com>; Rick Jian-Zhi Chen(陳建志) <rick@andestech.com>; u-boot@lists.denx.de
> > Subject: [PATCH v2] board: sifive: Fix a potential build warning in board_fdt_blob_setup()
> >
> > Commit 47d73ba4f4a4 ("board: sifive: overwrite board_fdt_blob_setup in u-boot proper") added a board-specific implementation of board_fdt_blob_setup() which takes a pointer as the return value, but it does not return anything if CONFIG_OF_SEPARATE is not enabled. This will cause a build warning seen when testing booting S-mode U-Boot directly from QEMU, per the instructions in [1]:
> >
> >   board/sifive/unleashed/unleashed.c: In function ‘board_fdt_blob_setup’:
> >   board/sifive/unleashed/unleashed.c:125:1: warning: control reaches end of non-void function [-Wreturn-type]
> >
> > Return &_end as the default case.
> >
> > [1] https://qemu.readthedocs.io/en/latest/system/riscv/sifive_u.html#running-u-boot
> >
> > Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> >
> > ---
> >
> > Changes in v2:
> > - Correct the commit title
> >
> >  board/sifive/unleashed/unleashed.c | 4 ++--  board/sifive/unmatched/unmatched.c | 4 ++--
> >  2 files changed, 4 insertions(+), 4 deletions(-)
>
> Reviewed-by: Rick Chen <rick@andestech.com>

Ping for apply?

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-10-11  3:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-11 14:31 [PATCH v2] board: sifive: Fix a potential build warning in board_fdt_blob_setup() Bin Meng
2021-09-14  8:21 ` Leo Liang
     [not found] ` <HK0PR03MB299484FCB8C64939BB8F91E6C1DD9@HK0PR03MB2994.apcprd03.prod.outlook.com>
2021-09-17  6:52   ` Rick Chen
2021-10-11  3:13     ` Bin Meng
2021-09-29 13:07 ` Ilias Apalodimas
2021-09-29 14:03   ` Bin Meng
2021-09-29 14:59     ` Ilias Apalodimas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).