[PATCH 3/3] FIT: cache uncompressed data
Ahmad Fatoum
a.fatoum at pengutronix.de
Thu Dec 19 03:16:03 PST 2024
If we decompress the FIT FDT once to check the compatible, it makes
sense to keep the decompressed data around as not to decompress the FIT
again later.
Do this by not directly deleting the uncompressed-data property again and
give it a $ prefix, so FIT images can't provide this data themselves.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
common/image-fit.c | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/common/image-fit.c b/common/image-fit.c
index 9e3dbe9ae054..58ce461623e6 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -576,6 +576,7 @@ static int fit_handle_decompression(struct device_node *image,
int *data_len)
{
const char *compression = NULL;
+ struct property *pp;
void *uc_data;
int ret;
@@ -595,18 +596,21 @@ static int fit_handle_decompression(struct device_node *image,
return -ENOSYS;
}
- ret = uncompress_buf_to_buf(*data, *data_len, &uc_data,
- fit_uncompress_error_fn);
- if (ret < 0) {
- pr_err("%s data couldn't be decompressed\n", compression);
- return ret;
+ pp = of_find_property(image, "$uncompressed-data", NULL);
+ if (!pp) {
+ ret = uncompress_buf_to_buf(*data, *data_len, &uc_data,
+ fit_uncompress_error_fn);
+ if (ret < 0) {
+ pr_err("%s data couldn't be decompressed\n", compression);
+ return ret;
+ }
+
+ /* associate buffer with FIT, so it's not leaked */
+ pp = __of_new_property(image, "$uncompressed-data", uc_data, ret);
}
- *data = uc_data;
- *data_len = ret;
-
- /* associate buffer with FIT, so it's not leaked */
- __of_new_property(image, "uncompressed-data", uc_data, *data_len);
+ *data = of_property_get_value(pp);
+ *data_len = pp->length;
return 0;
}
@@ -762,7 +766,6 @@ static int fit_find_compatible_unit(struct fit_handle *handle,
score = fdt_machine_is_compatible(data, data_len, machine);
- of_delete_property_by_name(image, "uncompressed-data");
next:
if (ret)
pr_warn("skipping malformed configuration: %pOF (%pe)\n",
--
2.39.5
More information about the barebox
mailing list