[PATCH] arm64: xilinx: Guard distro boot variable generation

Michal Simek michal.simek at amd.com
Mon Sep 11 15:27:29 CEST 2023



On 9/5/23 13:30, Michal Simek wrote:
> When distro boot is disabled there is no reason to generate variables for
> it. Also do not update boot_targets variable because it would be unused.
> 
> It is useful for example when standard boot is enabled and distro boot
> is disabled.
> 
> Signed-off-by: Michal Simek <michal.simek at amd.com>
> ---
> 
>   board/xilinx/versal-net/board.c     | 32 ++++++++++++-----
>   board/xilinx/versal/board.c         | 31 +++++++++++-----
>   board/xilinx/zynqmp/zynqmp.c        | 56 +++++++++++++++++------------
>   include/configs/xilinx_versal.h     |  6 ++++
>   include/configs/xilinx_versal_net.h |  6 ++++
>   include/configs/xilinx_zynqmp.h     |  6 ++++
>   6 files changed, 97 insertions(+), 40 deletions(-)
> 
> diff --git a/board/xilinx/versal-net/board.c b/board/xilinx/versal-net/board.c
> index 7ad299f3a231..c18be0c26c99 100644
> --- a/board/xilinx/versal-net/board.c
> +++ b/board/xilinx/versal-net/board.c
> @@ -194,7 +194,7 @@ static u8 versal_net_get_bootmode(void)
>   	return bootmode;
>   }
>   
> -int board_late_init(void)
> +static int boot_targets_setup(void)
>   {
>   	u8 bootmode;
>   	struct udevice *dev;
> @@ -205,14 +205,6 @@ int board_late_init(void)
>   	char *new_targets;
>   	char *env_targets;
>   
> -	if (!(gd->flags & GD_FLG_ENV_DEFAULT)) {
> -		debug("Saved variables - Skipping\n");
> -		return 0;
> -	}
> -
> -	if (!IS_ENABLED(CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG))
> -		return 0;
> -
>   	bootmode = versal_net_get_bootmode();
>   
>   	puts("Bootmode: ");
> @@ -320,6 +312,28 @@ int board_late_init(void)
>   
>   		env_set("boot_targets", new_targets);
>   	}
> +
> +	return 0;
> +}
> +
> +int board_late_init(void)
> +{
> +	int ret;
> +
> +	if (!(gd->flags & GD_FLG_ENV_DEFAULT)) {
> +		debug("Saved variables - Skipping\n");
> +		return 0;
> +	}
> +
> +	if (!IS_ENABLED(CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG))
> +		return 0;
> +
> +	if (IS_ENABLED(CONFIG_DISTRO_DEFAULTS)) {
> +		ret = boot_targets_setup();
> +		if (ret)
> +			return ret;
> +	}
> +
>   	return board_late_init_xilinx();
>   }
>   
> diff --git a/board/xilinx/versal/board.c b/board/xilinx/versal/board.c
> index 982a8b3779f1..e4bdd5d7a38b 100644
> --- a/board/xilinx/versal/board.c
> +++ b/board/xilinx/versal/board.c
> @@ -126,7 +126,7 @@ static u8 versal_get_bootmode(void)
>   	return bootmode;
>   }
>   
> -int board_late_init(void)
> +static int boot_targets_setup(void)
>   {
>   	u8 bootmode;
>   	struct udevice *dev;
> @@ -137,14 +137,6 @@ int board_late_init(void)
>   	char *new_targets;
>   	char *env_targets;
>   
> -	if (!(gd->flags & GD_FLG_ENV_DEFAULT)) {
> -		debug("Saved variables - Skipping\n");
> -		return 0;
> -	}
> -
> -	if (!IS_ENABLED(CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG))
> -		return 0;
> -
>   	bootmode = versal_get_bootmode();
>   
>   	puts("Bootmode: ");
> @@ -247,6 +239,27 @@ int board_late_init(void)
>   		env_set("boot_targets", new_targets);
>   	}
>   
> +	return 0;
> +}
> +
> +int board_late_init(void)
> +{
> +	int ret;
> +
> +	if (!(gd->flags & GD_FLG_ENV_DEFAULT)) {
> +		debug("Saved variables - Skipping\n");
> +		return 0;
> +	}
> +
> +	if (!IS_ENABLED(CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG))
> +		return 0;
> +
> +	if (IS_ENABLED(CONFIG_DISTRO_DEFAULTS)) {
> +		ret = boot_targets_setup();
> +		if (ret)
> +			return ret;
> +	}
> +
>   	return board_late_init_xilinx();
>   }
>   
> diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c
> index 0b6d4e57078b..f16280308483 100644
> --- a/board/xilinx/zynqmp/zynqmp.c
> +++ b/board/xilinx/zynqmp/zynqmp.c
> @@ -384,7 +384,7 @@ static int set_fdtfile(void)
>   	return 0;
>   }
>   
> -int board_late_init(void)
> +static int boot_targets_setup(void)
>   {
>   	u8 bootmode;
>   	struct udevice *dev;
> @@ -394,27 +394,6 @@ int board_late_init(void)
>   	const char *mode = NULL;
>   	char *new_targets;
>   	char *env_targets;
> -	int ret, multiboot;
> -
> -#if defined(CONFIG_USB_ETHER) && !defined(CONFIG_USB_GADGET_DOWNLOAD)
> -	usb_ether_init();
> -#endif
> -
> -	if (!(gd->flags & GD_FLG_ENV_DEFAULT)) {
> -		debug("Saved variables - Skipping\n");
> -		return 0;
> -	}
> -
> -	if (!IS_ENABLED(CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG))
> -		return 0;
> -
> -	ret = set_fdtfile();
> -	if (ret)
> -		return ret;
> -
> -	multiboot = multi_boot();
> -	if (multiboot >= 0)
> -		env_set_hex("multiboot", multiboot);
>   
>   	bootmode = zynqmp_get_bootmode();
>   
> @@ -525,6 +504,39 @@ int board_late_init(void)
>   		free(new_targets);
>   	}
>   
> +	return 0;
> +}
> +
> +int board_late_init(void)
> +{
> +	int ret, multiboot;
> +
> +#if defined(CONFIG_USB_ETHER) && !defined(CONFIG_USB_GADGET_DOWNLOAD)
> +	usb_ether_init();
> +#endif
> +
> +	if (!(gd->flags & GD_FLG_ENV_DEFAULT)) {
> +		debug("Saved variables - Skipping\n");
> +		return 0;
> +	}
> +
> +	if (!IS_ENABLED(CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG))
> +		return 0;
> +
> +	ret = set_fdtfile();
> +	if (ret)
> +		return ret;
> +
> +	multiboot = multi_boot();
> +	if (multiboot >= 0)
> +		env_set_hex("multiboot", multiboot);
> +
> +	if (IS_ENABLED(CONFIG_DISTRO_DEFAULTS)) {
> +		ret = boot_targets_setup();
> +		if (ret)
> +			return ret;
> +	}
> +
>   	reset_reason();
>   
>   	return board_late_init_xilinx();
> diff --git a/include/configs/xilinx_versal.h b/include/configs/xilinx_versal.h
> index 98792aba7cce..b634bb1ab705 100644
> --- a/include/configs/xilinx_versal.h
> +++ b/include/configs/xilinx_versal.h
> @@ -43,6 +43,8 @@
>   	"ramdisk_addr_r=0x02100000\0" \
>   	"script_size_f=0x80000\0"
>   
> +#if defined(CONFIG_DISTRO_DEFAULTS)
> +
>   #if defined(CONFIG_MMC_SDHCI_ZYNQ)
>   # define BOOT_TARGET_DEVICES_MMC(func)	func(MMC, mmc, 0) func(MMC, mmc, 1)
>   #else
> @@ -124,6 +126,10 @@
>   
>   #include <config_distro_bootcmd.h>
>   
> +#else /* CONFIG_DISTRO_DEFAULTS */
> +# define BOOTENV
> +#endif /* CONFIG_DISTRO_DEFAULTS */
> +
>   /* Initial environment variables */
>   #ifndef CFG_EXTRA_ENV_SETTINGS
>   #define CFG_EXTRA_ENV_SETTINGS \
> diff --git a/include/configs/xilinx_versal_net.h b/include/configs/xilinx_versal_net.h
> index e17b44093548..2b441da91a10 100644
> --- a/include/configs/xilinx_versal_net.h
> +++ b/include/configs/xilinx_versal_net.h
> @@ -57,6 +57,8 @@
>   	"ramdisk_addr_r=0x02100000\0" \
>   	"script_size_f=0x80000\0"
>   
> +#if defined(CONFIG_DISTRO_DEFAULTS)
> +
>   #if defined(CONFIG_MMC_SDHCI_ZYNQ)
>   # define BOOT_TARGET_DEVICES_MMC(func)	func(MMC, mmc, 0) func(MMC, mmc, 1)
>   #else
> @@ -125,6 +127,10 @@
>   
>   #include <config_distro_bootcmd.h>
>   
> +#else /* CONFIG_DISTRO_DEFAULTS */
> +# define BOOTENV
> +#endif /* CONFIG_DISTRO_DEFAULTS */
> +
>   /* Initial environment variables */
>   #ifndef CFG_EXTRA_ENV_SETTINGS
>   #define CFG_EXTRA_ENV_SETTINGS \
> diff --git a/include/configs/xilinx_zynqmp.h b/include/configs/xilinx_zynqmp.h
> index 51f0a4253406..c57ab14d1b97 100644
> --- a/include/configs/xilinx_zynqmp.h
> +++ b/include/configs/xilinx_zynqmp.h
> @@ -63,6 +63,8 @@
>   	"stdout=serial,vidconsole\0" \
>   	"stderr=serial,vidconsole\0" \
>   
> +#if defined(CONFIG_DISTRO_DEFAULTS)
> +
>   #if defined(CONFIG_MMC_SDHCI_ZYNQ)
>   # define BOOT_TARGET_DEVICES_MMC(func)	func(MMC, mmc, 0) func(MMC, mmc, 1)
>   #else
> @@ -174,6 +176,10 @@
>   
>   #include <config_distro_bootcmd.h>
>   
> +#else /* CONFIG_DISTRO_DEFAULTS */
> +# define BOOTENV
> +#endif /* CONFIG_DISTRO_DEFAULTS */
> +
>   /* Initial environment variables */
>   #ifndef CFG_EXTRA_ENV_SETTINGS
>   #define CFG_EXTRA_ENV_SETTINGS \

Applied.
M


More information about the U-Boot mailing list