mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master 1/2] list: fix CONFIG_DEBUG_LIST link failure in PBL
@ 2024-05-15  6:07 Ahmad Fatoum
  2024-05-15  6:07 ` [PATCH master 2/2] pblimage: ls1028a: fix handling of short reads on Ahmad Fatoum
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Ahmad Fatoum @ 2024-05-15  6:07 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

With the addition of PBL handoff data, we now use <linux/list.h> in PBL.
This works fine with CONFIG_DEBUG_LIST disabled, because all functions are
inlined, but when building with the option enabled, references to the
out-of-line sanity checking functions breaks the build.

Fix this by omitting these references when building for PBL.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 include/linux/list.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/list.h b/include/linux/list.h
index 2b3a39ea81e8..e47a8188e807 100644
--- a/include/linux/list.h
+++ b/include/linux/list.h
@@ -36,7 +36,7 @@ static inline void INIT_LIST_HEAD(struct list_head *list)
 	list->prev = list;
 }
 
-#ifdef CONFIG_DEBUG_LIST
+#if defined(CONFIG_DEBUG_LIST) && !defined(__PBL__)
 extern bool __list_add_valid_or_report(struct list_head *new,
 				       struct list_head *prev,
 				       struct list_head *next);
-- 
2.39.2




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

* [PATCH master 2/2] pblimage: ls1028a: fix handling of short reads on
  2024-05-15  6:07 [PATCH master 1/2] list: fix CONFIG_DEBUG_LIST link failure in PBL Ahmad Fatoum
@ 2024-05-15  6:07 ` Ahmad Fatoum
  2024-05-16  7:16 ` [PATCH master 1/2] list: fix CONFIG_DEBUG_LIST link failure in PBL Sascha Hauer
  2024-05-21 11:04 ` Sascha Hauer
  2 siblings, 0 replies; 5+ messages in thread
From: Ahmad Fatoum @ 2024-05-15  6:07 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

Newer toolchains rightly complain:

  scripts/pblimage.c:259:17: error: ignoring return value of ‘read’ declared
       with attribute ‘warn_unused_result’ [-Werror=unused-result]
    259 |                 read(in_fd, mem_buf + 0x1000, image_size);

In the ls1046a case, this doesn't happen, because pbl_fget is used,
which does a number of things:

  - report warnings and exit on read errors
  - fill buffer with 0xff on short reads
  - increment pmem_buf and pbl_size by the number of bytes emitted

All of which, sound like a good idea for the ls1028a as well. Therefore,
initialize pmem_buf and pbl_size to the correct value and use pbl_fget.

This makes the code easier to follow through by making it explicit that
the image's payload is always given a 4K alignment, independent of the
size of the image header.

This change has only been build-tested.

Fixes: d5e5a65c2b64 ("pblimage: Add LS1028a support")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 scripts/pblimage.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/scripts/pblimage.c b/scripts/pblimage.c
index 610d93b36800..a3ed74836883 100644
--- a/scripts/pblimage.c
+++ b/scripts/pblimage.c
@@ -254,10 +254,16 @@ static void pbl_load_image(void)
 		buf32[3] = image_size;
 		buf32[4] = 0x80ff0000;
 		pbl_size += 20;
-		pmem_buf += 20;
 
-		read(in_fd, mem_buf + 0x1000, image_size);
-		pbl_size = 0x1000 + image_size;
+		if (pbl_size > 0x1000) {
+			fprintf(stderr, "Header exceeded maximum size of 4K\n");
+			exit(EXIT_FAILURE);
+		}
+
+		pmem_buf = mem_buf + 0x1000;
+		pbl_size = 0x1000;
+
+		pbl_fget(image_size, in_fd);
 	} else {
 		exit(EXIT_FAILURE);
 	}
-- 
2.39.2




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

* Re: [PATCH master 1/2] list: fix CONFIG_DEBUG_LIST link failure in PBL
  2024-05-15  6:07 [PATCH master 1/2] list: fix CONFIG_DEBUG_LIST link failure in PBL Ahmad Fatoum
  2024-05-15  6:07 ` [PATCH master 2/2] pblimage: ls1028a: fix handling of short reads on Ahmad Fatoum
@ 2024-05-16  7:16 ` Sascha Hauer
  2024-05-17  6:02   ` Ahmad Fatoum
  2024-05-21 11:04 ` Sascha Hauer
  2 siblings, 1 reply; 5+ messages in thread
From: Sascha Hauer @ 2024-05-16  7:16 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Wed, May 15, 2024 at 08:07:57AM +0200, Ahmad Fatoum wrote:
> With the addition of PBL handoff data, we now use <linux/list.h> in PBL.
> This works fine with CONFIG_DEBUG_LIST disabled, because all functions are
> inlined, but when building with the option enabled, references to the
> out-of-line sanity checking functions breaks the build.
> 
> Fix this by omitting these references when building for PBL.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  include/linux/list.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/list.h b/include/linux/list.h
> index 2b3a39ea81e8..e47a8188e807 100644
> --- a/include/linux/list.h
> +++ b/include/linux/list.h
> @@ -36,7 +36,7 @@ static inline void INIT_LIST_HEAD(struct list_head *list)
>  	list->prev = list;
>  }
>  
> -#ifdef CONFIG_DEBUG_LIST
> +#if defined(CONFIG_DEBUG_LIST) && !defined(__PBL__)
>  extern bool __list_add_valid_or_report(struct list_head *new,
>  				       struct list_head *prev,
>  				       struct list_head *next);

What about compiling list_debug.o for PBL as well?

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



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

* Re: [PATCH master 1/2] list: fix CONFIG_DEBUG_LIST link failure in PBL
  2024-05-16  7:16 ` [PATCH master 1/2] list: fix CONFIG_DEBUG_LIST link failure in PBL Sascha Hauer
@ 2024-05-17  6:02   ` Ahmad Fatoum
  0 siblings, 0 replies; 5+ messages in thread
From: Ahmad Fatoum @ 2024-05-17  6:02 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On 16.05.24 09:16, Sascha Hauer wrote:
> On Wed, May 15, 2024 at 08:07:57AM +0200, Ahmad Fatoum wrote:
>> With the addition of PBL handoff data, we now use <linux/list.h> in PBL.
>> This works fine with CONFIG_DEBUG_LIST disabled, because all functions are
>> inlined, but when building with the option enabled, references to the
>> out-of-line sanity checking functions breaks the build.
>>
>> Fix this by omitting these references when building for PBL.
>>
>> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
>> ---
>>  include/linux/list.h | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/include/linux/list.h b/include/linux/list.h
>> index 2b3a39ea81e8..e47a8188e807 100644
>> --- a/include/linux/list.h
>> +++ b/include/linux/list.h
>> @@ -36,7 +36,7 @@ static inline void INIT_LIST_HEAD(struct list_head *list)
>>  	list->prev = list;
>>  }
>>  
>> -#ifdef CONFIG_DEBUG_LIST
>> +#if defined(CONFIG_DEBUG_LIST) && !defined(__PBL__)
>>  extern bool __list_add_valid_or_report(struct list_head *new,
>>  				       struct list_head *prev,
>>  				       struct list_head *next);
> 
> What about compiling list_debug.o for PBL as well?

I'd prefer we use singly linked lists instead, but I want to fix the
build error first.

Thanks,
Ahmad

> 
> Sascha
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




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

* Re: [PATCH master 1/2] list: fix CONFIG_DEBUG_LIST link failure in PBL
  2024-05-15  6:07 [PATCH master 1/2] list: fix CONFIG_DEBUG_LIST link failure in PBL Ahmad Fatoum
  2024-05-15  6:07 ` [PATCH master 2/2] pblimage: ls1028a: fix handling of short reads on Ahmad Fatoum
  2024-05-16  7:16 ` [PATCH master 1/2] list: fix CONFIG_DEBUG_LIST link failure in PBL Sascha Hauer
@ 2024-05-21 11:04 ` Sascha Hauer
  2 siblings, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2024-05-21 11:04 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum


On Wed, 15 May 2024 08:07:57 +0200, Ahmad Fatoum wrote:
> With the addition of PBL handoff data, we now use <linux/list.h> in PBL.
> This works fine with CONFIG_DEBUG_LIST disabled, because all functions are
> inlined, but when building with the option enabled, references to the
> out-of-line sanity checking functions breaks the build.
> 
> Fix this by omitting these references when building for PBL.
> 
> [...]

Applied, thanks!

[1/2] list: fix CONFIG_DEBUG_LIST link failure in PBL
      https://git.pengutronix.de/cgit/barebox/commit/?id=84d8445e0dfb (link may not be stable)
[2/2] pblimage: ls1028a: fix handling of short reads on
      https://git.pengutronix.de/cgit/barebox/commit/?id=27d7f5dcb305 (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




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

end of thread, other threads:[~2024-05-21 11:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-15  6:07 [PATCH master 1/2] list: fix CONFIG_DEBUG_LIST link failure in PBL Ahmad Fatoum
2024-05-15  6:07 ` [PATCH master 2/2] pblimage: ls1028a: fix handling of short reads on Ahmad Fatoum
2024-05-16  7:16 ` [PATCH master 1/2] list: fix CONFIG_DEBUG_LIST link failure in PBL Sascha Hauer
2024-05-17  6:02   ` Ahmad Fatoum
2024-05-21 11:04 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox