diff mbox series

[kvm-unit-tests] devicetree: Fix the dt_for_each_cpu_node

Message ID 1577444615-26720-1-git-send-email-prime.zeng@hisilicon.com (mailing list archive)
State New, archived
Headers show
Series [kvm-unit-tests] devicetree: Fix the dt_for_each_cpu_node | expand

Commit Message

Zengtao (B) Dec. 27, 2019, 11:03 a.m. UTC
If the /cpus node contains nodes other than /cpus/cpu*, for example:
/cpus/cpu-map/. The test will issue an unexpected assert error as
follow:
[root@localhost]# ./arm-run arm/spinlock-test.flat
qemu-system-aarch64 -nodefaults -machine virt,gic-version=host,accel=kvm
 -cpu host -device virtio-serial-device -device virtconsole,chardev=ctd
-chardev testdev,id=ctd -device pci-testdev -display none -serial stdio
-kernel arm/spinlock-test.flat # -initrd /tmp/tmp.mwPLiF4EWm
lib/arm/setup.c:64: assert failed: ret == 0
        STACK:

In this patch, ignore the non-cpu subnodes instead of return an error.

Signed-off-by: Zeng Tao <prime.zeng@hisilicon.com>
---
 lib/devicetree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andrew Jones Dec. 27, 2019, 11:35 a.m. UTC | #1
On Fri, Dec 27, 2019 at 07:03:35PM +0800, Zeng Tao wrote:
> If the /cpus node contains nodes other than /cpus/cpu*, for example:
> /cpus/cpu-map/. The test will issue an unexpected assert error as
> follow:
> [root@localhost]# ./arm-run arm/spinlock-test.flat
> qemu-system-aarch64 -nodefaults -machine virt,gic-version=host,accel=kvm
>  -cpu host -device virtio-serial-device -device virtconsole,chardev=ctd
> -chardev testdev,id=ctd -device pci-testdev -display none -serial stdio
> -kernel arm/spinlock-test.flat # -initrd /tmp/tmp.mwPLiF4EWm
> lib/arm/setup.c:64: assert failed: ret == 0
>         STACK:
> 
> In this patch, ignore the non-cpu subnodes instead of return an error.
> 
> Signed-off-by: Zeng Tao <prime.zeng@hisilicon.com>
> ---
>  lib/devicetree.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/devicetree.c b/lib/devicetree.c
> index 2b89178..1020324 100644
> --- a/lib/devicetree.c
> +++ b/lib/devicetree.c
> @@ -225,7 +225,7 @@ int dt_for_each_cpu_node(void (*func)(int fdtnode, u64 regval, void *info),
>  
>  		prop = fdt_get_property(fdt, cpu, "device_type", &len);
>  		if (prop == NULL)
> -			return len;
> +			continue;
>  
>  		if (len != 4 || strcmp((char *)prop->data, "cpu"))
>  			continue;
> -- 
> 1.8.3.1
>

Queued to https://github.com/rhdrjones/kvm-unit-tests/commits/arm/queue

I'll send a pull request to Paolo soon.

Thanks,
drew
diff mbox series

Patch

diff --git a/lib/devicetree.c b/lib/devicetree.c
index 2b89178..1020324 100644
--- a/lib/devicetree.c
+++ b/lib/devicetree.c
@@ -225,7 +225,7 @@  int dt_for_each_cpu_node(void (*func)(int fdtnode, u64 regval, void *info),
 
 		prop = fdt_get_property(fdt, cpu, "device_type", &len);
 		if (prop == NULL)
-			return len;
+			continue;
 
 		if (len != 4 || strcmp((char *)prop->data, "cpu"))
 			continue;