All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mkimage: sunxi_egon: Allow overriding the padding size
@ 2021-10-13  0:21 Samuel Holland
  2021-10-14  0:17 ` Andre Przywara
  0 siblings, 1 reply; 2+ messages in thread
From: Samuel Holland @ 2021-10-13  0:21 UTC (permalink / raw)
  To: u-boot, Jagan Teki, Andre Przywara
  Cc: Samuel Holland, Jernej Skrabec, Simon Glass

Due to a bug in the H3 SoC, where the CPU 0 hotplug flag cannot be
written, resuming CPU 0 requires using the "Super Standby" code path in
the BROM instead of the hotplug path. This path requires jumping to an
eGON image in SRAM.

This resume image, whose single purpose is to jump back to the secure
monitor, only needs to contain a single instruction. Padding the image
to 8 KiB would be wasteful of SRAM. Hook up the -B (block size) option
so users can set the block/padding size.

Signed-off-by: Samuel Holland <samuel@sholland.org>
---

 tools/sunxi_egon.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/tools/sunxi_egon.c b/tools/sunxi_egon.c
index a5299eb6a1..d1398c07fb 100644
--- a/tools/sunxi_egon.c
+++ b/tools/sunxi_egon.c
@@ -10,9 +10,10 @@
 
 /*
  * NAND requires 8K padding. SD/eMMC gets away with 512 bytes,
- * but let's use the larger padding to cover both.
+ * but let's use the larger padding by default to cover both.
  */
 #define PAD_SIZE			8192
+#define PAD_SIZE_MIN			512
 
 static int egon_check_params(struct image_tool_params *params)
 {
@@ -114,10 +115,12 @@ static int egon_check_image_type(uint8_t type)
 static int egon_vrec_header(struct image_tool_params *params,
 			    struct image_type_params *tparams)
 {
+	int pad_size = ALIGN(params->bl_len ?: PAD_SIZE, PAD_SIZE_MIN);
+
 	tparams->hdr = calloc(sizeof(struct boot_file_head), 1);
 
-	/* Return padding to 8K blocks. */
-	return ALIGN(params->file_size, PAD_SIZE) - params->file_size;
+	/* Return padding to complete blocks. */
+	return ALIGN(params->file_size, pad_size) - params->file_size;
 }
 
 U_BOOT_IMAGE_TYPE(
-- 
2.32.0


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

* Re: [PATCH] mkimage: sunxi_egon: Allow overriding the padding size
  2021-10-13  0:21 [PATCH] mkimage: sunxi_egon: Allow overriding the padding size Samuel Holland
@ 2021-10-14  0:17 ` Andre Przywara
  0 siblings, 0 replies; 2+ messages in thread
From: Andre Przywara @ 2021-10-14  0:17 UTC (permalink / raw)
  To: Samuel Holland; +Cc: u-boot, Jagan Teki, Jernej Skrabec, Simon Glass

On Tue, 12 Oct 2021 19:21:27 -0500
Samuel Holland <samuel@sholland.org> wrote:

> Due to a bug in the H3 SoC, where the CPU 0 hotplug flag cannot be
> written, resuming CPU 0 requires using the "Super Standby" code path in
> the BROM instead of the hotplug path. This path requires jumping to an
> eGON image in SRAM.
> 
> This resume image, whose single purpose is to jump back to the secure
> monitor, only needs to contain a single instruction. Padding the image
> to 8 KiB would be wasteful of SRAM. Hook up the -B (block size) option
> so users can set the block/padding size.

I like that one, I always got annoyed about this rather large fixed
padding size, even though the vast majority of users don't need it.

Also the default behaviour is unchanged, so little risk here.

> Signed-off-by: Samuel Holland <samuel@sholland.org>

Reviewed-by: Andre Przywara <andre.przywara@arm.com>

Cheers,
Andre

> ---
> 
>  tools/sunxi_egon.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/sunxi_egon.c b/tools/sunxi_egon.c
> index a5299eb6a1..d1398c07fb 100644
> --- a/tools/sunxi_egon.c
> +++ b/tools/sunxi_egon.c
> @@ -10,9 +10,10 @@
>  
>  /*
>   * NAND requires 8K padding. SD/eMMC gets away with 512 bytes,
> - * but let's use the larger padding to cover both.
> + * but let's use the larger padding by default to cover both.
>   */
>  #define PAD_SIZE			8192
> +#define PAD_SIZE_MIN			512
>  
>  static int egon_check_params(struct image_tool_params *params)
>  {
> @@ -114,10 +115,12 @@ static int egon_check_image_type(uint8_t type)
>  static int egon_vrec_header(struct image_tool_params *params,
>  			    struct image_type_params *tparams)
>  {
> +	int pad_size = ALIGN(params->bl_len ?: PAD_SIZE, PAD_SIZE_MIN);
> +
>  	tparams->hdr = calloc(sizeof(struct boot_file_head), 1);
>  
> -	/* Return padding to 8K blocks. */
> -	return ALIGN(params->file_size, PAD_SIZE) - params->file_size;
> +	/* Return padding to complete blocks. */
> +	return ALIGN(params->file_size, pad_size) - params->file_size;
>  }
>  
>  U_BOOT_IMAGE_TYPE(


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

end of thread, other threads:[~2021-10-14  0:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-13  0:21 [PATCH] mkimage: sunxi_egon: Allow overriding the padding size Samuel Holland
2021-10-14  0:17 ` Andre Przywara

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.