From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 3/3] FIT: cache uncompressed data
Date: Thu, 19 Dec 2024 12:16:03 +0100 [thread overview]
Message-ID: <20241219111603.1020442-3-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20241219111603.1020442-1-a.fatoum@pengutronix.de>
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@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
next prev parent reply other threads:[~2024-12-19 11:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-19 11:16 [PATCH 1/3] of: fdt: reserve properties and nodes starting with $ for barebox use Ahmad Fatoum
2024-12-19 11:16 ` [PATCH 2/3] of: fdt: rename /memreserve special node to /$memreserve Ahmad Fatoum
2024-12-19 11:16 ` Ahmad Fatoum [this message]
2024-12-20 8:19 ` [PATCH 1/3] of: fdt: reserve properties and nodes starting with $ for barebox use Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241219111603.1020442-3-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox