Skip to contentSkip to conversation

spl: fat: Support full fitImage handling

PATCH In review Marek Vasut 3 participants 4 messages May 31, 2018 – Jul 11, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spl: fat: Support full fitImage handling

Handle the case where the full fitImage support is enabled. In this case, the whole fitImage must be loaded up front as some parts of the fitImage code require memory-mapped access to the entire fitImage.

Cc Pantelis Antoniou <[email protected]>
Cc Simon Glass <[email protected]>
---
 common/spl/spl_fat.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
common/spl/spl_fat.c +12 -1
index 87dd553210..0403016bb4 100644
@@ -70,7 +70,18 @@ int spl_load_image_fat(struct spl_image_info *spl_image,
 	if (err <= 0)
 		goto end;
 
-	if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
+	if (IS_ENABLED(CONFIG_SPL_LOAD_FIT_FULL) &&
+	    image_get_magic(header) == FDT_MAGIC) {
+		err = file_fat_read(filename, (void *)CONFIG_SYS_LOAD_ADDR, 0);
+		if (err <= 0)
+			goto end;
+		err = spl_parse_image_header(spl_image,
+				(struct image_header *)CONFIG_SYS_LOAD_ADDR);
+		if (err == -EAGAIN)
+			return err;
+		if (err == 0)
+			err = 1;
+	} else if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
 	    image_get_magic(header) == FDT_MAGIC) {
 		struct spl_load_info load;
 
Signature · 1 line
2.16.2
#1 lore raw

PATCH 1/1 spl: fat: Support full fitImage handling

Hi Marex,

Quoted 21 lines · Marek Vasut

Handle the case where the full fitImage support is enabled. In this case, the whole fitImage must be loaded up front as some parts of the fitImage code require memory-mapped access to the entire fitImage.

Cc Pantelis Antoniou <[email protected]>
Cc Simon Glass <[email protected]>
---
 common/spl/spl_fat.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
common/spl/spl_fat.c +1 -1
index 87dd553210..0403016bb4 100644
@@ -70,7 +70,18 @@ int spl_load_image_fat(struct spl_image_info *spl_image,
        if (err <= 0)
                goto end;
 
-       if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
+       if (IS_ENABLED(CONFIG_SPL_LOAD_FIT_FULL) &&

common/spl/spl_fat.c int spl_load_image_fat(struct spl_image_info *spl_image, · line 83

Quoted 10 lines
common/spl/spl_fat.c +10 -0
+           image_get_magic(header) == FDT_MAGIC) {
+               err = file_fat_read(filename, (void *)CONFIG_SYS_LOAD_ADDR, 0);
+               if (err <= 0)
+                       goto end;
+               err = spl_parse_image_header(spl_image,
+                               (struct image_header *)CONFIG_SYS_LOAD_ADDR);
+               if (err == -EAGAIN)
+                       return err;
+               if (err == 0)
+                       err = 1;

The error handling here is too confusing.

spl_load_image_fat() has no comment indicating what the return value means. So is 0 success?

spl_parse_image_header() seems to return 0 on success, which is good, but your code appears to turn that into 1. Why?

Can you please add comments and consider moving towards using 0 to mean success everywhere?

Quoted 7 lines
common/spl/spl_fat.c +1 -1
+       } else if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
            image_get_magic(header) == FDT_MAGIC) {
                struct spl_load_info load;
 
--

2.16.2

Regards,
Simon

#2 lore raw

PATCH 1/1 spl: fat: Support full fitImage handling

Quoted 37 lines · Simon Glass

Hi Marex,

Quoted 21 lines · Marek Vasut

Handle the case where the full fitImage support is enabled. In this case, the whole fitImage must be loaded up front as some parts of the fitImage code require memory-mapped access to the entire fitImage.

Cc Pantelis Antoniou <[email protected]>
Cc Simon Glass <[email protected]>
---
 common/spl/spl_fat.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
common/spl/spl_fat.c +1 -1
index 87dd553210..0403016bb4 100644
@@ -70,7 +70,18 @@ int spl_load_image_fat(struct spl_image_info *spl_image,
        if (err <= 0)
                goto end;
 
-       if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
+       if (IS_ENABLED(CONFIG_SPL_LOAD_FIT_FULL) &&

common/spl/spl_fat.c int spl_load_image_fat(struct spl_image_info *spl_image, · line 83

Quoted 10 lines
common/spl/spl_fat.c +10 -0
+           image_get_magic(header) == FDT_MAGIC) {
+               err = file_fat_read(filename, (void *)CONFIG_SYS_LOAD_ADDR, 0);
+               if (err <= 0)
+                       goto end;
+               err = spl_parse_image_header(spl_image,
+                               (struct image_header *)CONFIG_SYS_LOAD_ADDR);
+               if (err == -EAGAIN)
+                       return err;
+               if (err == 0)
+                       err = 1;

The error handling here is too confusing.

Quoted 2 lines

spl_load_image_fat() has no comment indicating what the return value means. So is 0 success?

Yes, 0 is success, EAGAIN is retry, anything else is an error.

The SPL loader expects I think positive return value to indicate success though.

Quoted 17 lines

spl_parse_image_header() seems to return 0 on success, which is good, but your code appears to turn that into 1. Why?

Can you please add comments and consider moving towards using 0 to mean success everywhere?

Quoted 7 lines
common/spl/spl_fat.c +1 -1
+       } else if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
            image_get_magic(header) == FDT_MAGIC) {
                struct spl_load_info load;
 
--

2.16.2

Regards,
Simon

Signature · 2 lines
Best regards,
Marek Vasut
#3 lore raw
In reply to Marek Vasut
Quoted 7 lines · Marek Vasut

Handle the case where the full fitImage support is enabled. In this case, the whole fitImage must be loaded up front as some parts of the fitImage code require memory-mapped access to the entire fitImage.

Cc Pantelis Antoniou <[email protected]>
Cc Simon Glass <[email protected]>

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180711/d4aeab67/attachment.sig>