[U-Boot] [PATCH 2/2] armv8: ls1043a: Discard the needless cpu nodes

York Sun york.sun at nxp.com
Thu Nov 30 17:41:02 UTC 2017


On 11/29/2017 07:16 PM, Wenbin song wrote:
> Using "cpu_pos_mask()" function to detect the real online cpus,
> and discard the needless cpu nodes on kernel dft.
> 
> Signed-off-by: Wenbin Song <wenbin.song at nxp.com>
> ---
>  arch/arm/cpu/armv8/fsl-layerscape/Kconfig |  4 ++++
>  arch/arm/cpu/armv8/fsl-layerscape/fdt.c   | 32 +++++++++++++++++++++++++++++++
>  2 files changed, 36 insertions(+)
> 
> diff --git a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig
> index 47145a2432..971a98c6cc 100644
> --- a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig
> +++ b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig
> @@ -176,6 +176,10 @@ config HAS_FEATURE_ENHANCED_MSI
>  	bool
>  	default y if ARCH_LS1043A
>  
> +config DISCARD_OFFLINE_CPU_NODES
> +	bool
> +	default y if ARCH_LS1043A
> +
>  menu "Layerscape PPA"
>  config FSL_LS_PPA
>  	bool "FSL Layerscape PPA firmware support"
> diff --git a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
> index 33f3e64848..241f0abe18 100644
> --- a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
> +++ b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
> @@ -44,6 +44,38 @@ void ft_fixup_cpu(void *blob)
>  	int addr_cells;
>  	u64 val, core_id;
>  	size_t *boot_code_size = &(__secondary_boot_code_size);
> +
> +#if defined(CONFIG_DISCARD_OFFLINE_CPU_NODES)
> +	u32 mask = cpu_pos_mask();
> +	int off_prev = -1;
> +	int pos;
> +
> +	off = fdt_path_offset(blob, "/cpus");
> +	if (off < 0) {
> +		puts("couldn't find /cpus node\n");
> +		return;
> +	}
> +
> +	fdt_support_default_count_cells(blob, off, &addr_cells, NULL);
> +
> +	off = fdt_node_offset_by_prop_value(blob, off_prev, "device_type",
> +					    "cpu", 4);
> +	while (off != -FDT_ERR_NOTFOUND) {
> +		reg = (fdt32_t *)fdt_getprop(blob, off, "reg", 0);
> +		if (reg) {
> +			core_id = fdt_read_number(reg, addr_cells);
> +			pos = ((core_id & 0xff00) >> 5) + (core_id & 0xff);
> +			if (!test_bit(pos, &mask)) {
> +				fdt_del_node(blob, off);
> +				off = off_prev;
> +			}
> +		}
> +		off_prev = off;
> +		off = fdt_node_offset_by_prop_value(blob, off_prev,
> +						    "device_type", "cpu", 4);
> +	}
> +#endif
> +
>  #if defined(CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT) && \
>  	defined(CONFIG_SEC_FIRMWARE_ARMV8_PSCI)
>  	int node;
> 

Wenbin,

Using topology registers to identify the existence of cores is correct.
Do you need the new config option to gate the code? It is a correct
operation for all SoCs, isn't it?

York


More information about the U-Boot mailing list