public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH 1/3] spl: fit: Discard decompression if not supported
@ 2023-11-03 14:34 Loic Poulain
  2023-11-03 14:34 ` [PATCH 2/3] spl: fit: Add support for LZO compressed images Loic Poulain
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Loic Poulain @ 2023-11-03 14:34 UTC (permalink / raw)
  To: sjg, marex; +Cc: u-boot, abbaraju.manojsai, seanga2, Loic Poulain

And simplify further decompression testing.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
---
 common/spl/spl_fit.c | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)

diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 70d8d5942d..1d42cb1d10 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -208,6 +208,20 @@ static int get_aligned_image_size(struct spl_load_info *info, int data_size,
 	return (data_size + info->bl_len - 1) / info->bl_len;
 }
 
+static inline bool spl_fit_decompression_supported(uint8_t comp)
+{
+	switch (comp) {
+	case IH_COMP_GZIP:
+		return IS_ENABLED(CONFIG_SPL_GZIP);
+	case IH_COMP_LZMA:
+		return IS_ENABLED(CONFIG_SPL_LZMA);
+	case IH_COMP_NONE:
+		return true;
+	}
+
+	return false;
+}
+
 /**
  * load_simple_fit(): load the image described in a certain FIT node
  * @info:	points to information about the device to load data from
@@ -235,7 +249,7 @@ static int load_simple_fit(struct spl_load_info *info, ulong sector,
 	void *src;
 	ulong overhead;
 	int nr_sectors;
-	uint8_t image_comp = -1, type = -1;
+	uint8_t image_comp, type = -1;
 	const void *data;
 	const void *fit = ctx->fit;
 	bool external_data = false;
@@ -248,9 +262,11 @@ static int load_simple_fit(struct spl_load_info *info, ulong sector,
 			debug("%s ", genimg_get_type_name(type));
 	}
 
-	if (spl_decompression_enabled()) {
-		fit_image_get_comp(fit, node, &image_comp);
-		debug("%s ", genimg_get_comp_name(image_comp));
+	fit_image_get_comp(fit, node, &image_comp);
+	if (!spl_fit_decompression_supported(image_comp)) {
+		debug("Discard unsupported compression %s ",
+		      genimg_get_comp_name(image_comp));
+		image_comp = IH_COMP_NONE;
 	}
 
 	if (fit_image_get_load(fit, node, &load_addr)) {
@@ -283,8 +299,7 @@ static int load_simple_fit(struct spl_load_info *info, ulong sector,
 			return 0;
 		}
 
-		if (spl_decompression_enabled() &&
-		    (image_comp == IH_COMP_GZIP || image_comp == IH_COMP_LZMA))
+		if (image_comp != IH_COMP_NONE)
 			src_ptr = map_sysmem(ALIGN(CONFIG_SYS_LOAD_ADDR, ARCH_DMA_MINALIGN), len);
 		else
 			src_ptr = map_sysmem(ALIGN(load_addr, ARCH_DMA_MINALIGN), len);
-- 
2.34.1


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

end of thread, other threads:[~2023-11-04 15:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-03 14:34 [PATCH 1/3] spl: fit: Discard decompression if not supported Loic Poulain
2023-11-03 14:34 ` [PATCH 2/3] spl: fit: Add support for LZO compressed images Loic Poulain
2023-11-04 15:19   ` Sean Anderson
2023-11-03 14:34 ` [PATCH 3/3] spl: fit: Load compressed blob to heap buffer Loic Poulain
2023-11-04 15:13   ` Sean Anderson
2023-11-04 15:10 ` [PATCH 1/3] spl: fit: Discard decompression if not supported Sean Anderson

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