[U-Boot] [PATCH] riscv: cpu: Skip unavailable hart in the get_count() op

Auer, Lukas lukas.auer at aisec.fraunhofer.de
Thu Aug 8 11:22:11 UTC 2019


Hi Bin,

On Thu, 2019-08-08 at 00:52 -0700, Bin Meng wrote:
> We should not count in hart that is marked as not available in the
> device tree in riscv_cpu_get_count().
> 

I think it might make sense to also exclude harts that are not listed
as available in the available_harts mask. So the same logic as in
arch/riscv/lib/smp.c. In this case, the bind function should probably
check the mask as well.

Looks good otherwise!

Reviewed-by: Lukas Auer <lukas.auer at aisec.fraunhofer.de>

Thanks,
Lukas

> Signed-off-by: Bin Meng <bmeng.cn at gmail.com>
> ---
> 
>  drivers/cpu/riscv_cpu.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/cpu/riscv_cpu.c b/drivers/cpu/riscv_cpu.c
> index f77c126..28ad0aa 100644
> --- a/drivers/cpu/riscv_cpu.c
> +++ b/drivers/cpu/riscv_cpu.c
> @@ -46,6 +46,10 @@ static int riscv_cpu_get_count(struct udevice *dev)
>  	ofnode_for_each_subnode(node, dev_ofnode(dev->parent)) {
>  		const char *device_type;
>  
> +		/* skip if hart is marked as not available in the device tree */
> +		if (!ofnode_is_available(node))
> +			continue;
> +
>  		device_type = ofnode_read_string(node, "device_type");
>  		if (!device_type)
>  			continue;


More information about the U-Boot mailing list