xlnx-zynqmp: Don't create rpu-cluster if there are no RPUs
PATCH 1/1 xlnx-zynqmp: Don't create rpu-cluster if there are no RPUs
If we aren't going to create any RPUs, then don't create the rpu-cluster unit. This allows us to add an assertion to the cluster object that it contains at least one CPU, which helps to avoid bugs in creating clusters and putting CPUs in them.
---
This is a preparatory patch that is necessary for the series "[PATCH v3 0/4] tcg: support heterogenous CPU clusters" ([email protected])
in order to avoid the xlnx-zcu102 board asserting if started with fewer than 5 CPUs.
hw/arm/xlnx-zynqmp.c | 5 +++++ 1 file changed, 5 insertions(+)
hw/arm/xlnx-zynqmp.c +5 -0
@@ -178,6 +178,11 @@ static void xlnx_zynqmp_create_rpu(XlnxZynqMPState *s, const char *boot_cpu,int i;int num_rpus =MIN (smp_cpus -XLNX_ZYNQMP_NUM_APU_CPUS ,XLNX_ZYNQMP_NUM_RPU_CPUS ); +if (num_rpus ==0 ) { +/* Don't create rpu-cluster object if there's nothing to put in it */ +return ; + } +object_initialize_child (OBJECT (s),"rpu-cluster" , &s->rpu_cluster,sizeof (s->rpu_cluster),TYPE_CPU_CLUSTER , &error_abort,NULL );
Signature · 1 line
2.20.1
Quoted 4 lines · Peter Maydell
If we aren't going to create any RPUs, then don't create the rpu-cluster unit. This allows us to add an assertion to the cluster object that it contains at least one CPU, which helps to avoid bugs in creating clusters and putting CPUs in them.
Quoted 31 lines
Signed-off-by Peter Maydell <[email protected]>---
This is a preparatory patch that is necessary for the series "[PATCH v3 0/4] tcg: support heterogenous CPU clusters" ([email protected])
in order to avoid the xlnx-zcu102 board asserting if started with fewer than 5 CPUs.hw/arm/xlnx-zynqmp.c | 5 +++++ 1 file changed, 5 insertions(+)hw/arm/xlnx-zynqmp.c +5
-0@@ -178,6 +178,11 @@ static void xlnx_zynqmp_create_rpu(XlnxZynqMPState *s, const char *boot_cpu,int i;int num_rpus =MIN (smp_cpus -XLNX_ZYNQMP_NUM_APU_CPUS ,XLNX_ZYNQMP_NUM_RPU_CPUS ); +if (num_rpus ==0 ) { +/* Don't create rpu-cluster object if there's nothing to put in it */ +return ; + } +object_initialize_child (OBJECT (s),"rpu-cluster" , &s->rpu_cluster,sizeof (s->rpu_cluster),TYPE_CPU_CLUSTER , &error_abort,NULL );Signature · 1 line
2.20.1
Hi Peter,
Quoted 21 lines · Peter Maydell
If we aren't going to create any RPUs, then don't create the rpu-cluster unit. This allows us to add an assertion to the cluster object that it contains at least one CPU, which helps to avoid bugs in creating clusters and putting CPUs in them.
Signed-off-by Peter Maydell <[email protected]>---
This is a preparatory patch that is necessary for the series "[PATCH v3 0/4] tcg: support heterogenous CPU clusters" ([email protected])
in order to avoid the xlnx-zcu102 board asserting if started with fewer than 5 CPUs.hw/arm/xlnx-zynqmp.c | 5 +++++ 1 file changed, 5 insertions(+)hw/arm/xlnx-zynqmp.c +0
-0
hw/arm/xlnx-zynqmp.c static void xlnx_zynqmp_create_rpu(XlnxZynqMPState *s, const char *boot_cpu, · line 179
Quoted 2 lines
hw/arm/xlnx-zynqmp.c +0
-0@@ -178,6 +178,11 @@ static void xlnx_zynqmp_create_rpu(XlnxZynqMPState *s, const char *boot_cpu,int i;int num_rpus =MIN (smp_cpus -XLNX_ZYNQMP_NUM_APU_CPUS ,XLNX_ZYNQMP_NUM_RPU_CPUS );
Not related to this patch, but this check seems dangerous, i.e. using "-smp 2" we get num_rpus=-2 which luckyly doesn't enter the for() loop.
hw/arm/xlnx-zynqmp.c static void xlnx_zynqmp_create_rpu(XlnxZynqMPState *s, const char *boot_cpu, · line 181
Quoted 2 lines
hw/arm/xlnx-zynqmp.c +1
-0+if (num_rpus ==0 ) {
With the current codebase, you'd have to check for "num_rpus <= 0", ...
hw/arm/xlnx-zynqmp.c static void xlnx_zynqmp_create_rpu(XlnxZynqMPState *s, const char *boot_cpu,
Quoted 8 lines
hw/arm/xlnx-zynqmp.c +4
-0+/* Don't create rpu-cluster object if there's nothing to put in it */ +return ; + } +object_initialize_child (OBJECT (s),"rpu-cluster" , &s->rpu_cluster,sizeof (s->rpu_cluster),TYPE_CPU_CLUSTER , &error_abort,NULL );
... because the rpu cluster is still created:
aarch64-softmmu/qemu-system-aarch64 -M xlnx-zcu102 -smp 2 -S -monitor stdio
(qemu) info qom-tree
/machine (xlnx-zcu102-machine)
/peripheral (container)
/soc (xlnx,zynqmp)
/rpu-cluster (cpu-cluster)
/apu-cluster (cpu-cluster)
/apu-cpu[1] (cortex-a53-arm-cpu)
/unnamed-gpio-in[1] (irq)
/unnamed-gpio-in[3] (irq)
/unnamed-gpio-in[2] (irq)
/unnamed-gpio-in[0] (irq)
/apu-cpu[0] (cortex-a53-arm-cpu)
/unnamed-gpio-in[1] (irq)
/unnamed-gpio-in[3] (irq)
/unnamed-gpio-in[2] (irq)
/unnamed-gpio-in[0] (irq)What about this instead?
-- >8 --
@@ -451,10 +451,12 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
"RPUs just use -smp 6.");
}- xlnx_zynqmp_create_rpu(s, boot_cpu, &err);
- if (err) {
- error_propagate(errp, err);
- return;
+ if (smp_cpus > XLNX_ZYNQMP_NUM_APU_CPUS) {
+ xlnx_zynqmp_create_rpu(s, boot_cpu, &err);
+ if (err) {
+ error_propagate(errp, err);
+ return;
+ }
}
if (!s->boot_cpu_ptr) {---
Regards,
Phil.
Quoted 32 lines · Philippe Mathieu-Daudé
Hi Peter,
Quoted 21 lines · Peter Maydell
If we aren't going to create any RPUs, then don't create the rpu-cluster unit. This allows us to add an assertion to the cluster object that it contains at least one CPU, which helps to avoid bugs in creating clusters and putting CPUs in them.
Signed-off-by Peter Maydell <[email protected]>---
This is a preparatory patch that is necessary for the series "[PATCH v3 0/4] tcg: support heterogenous CPU clusters" ([email protected])
in order to avoid the xlnx-zcu102 board asserting if started with fewer than 5 CPUs.hw/arm/xlnx-zynqmp.c | 5 +++++ 1 file changed, 5 insertions(+)hw/arm/xlnx-zynqmp.c +0
-0hw/arm/xlnx-zynqmp.c static void xlnx_zynqmp_create_rpu(XlnxZynqMPState *s, const char *boot_cpu, · line 179
Quoted 2 lines
hw/arm/xlnx-zynqmp.c +0
-0@@ -178,6 +178,11 @@ static void xlnx_zynqmp_create_rpu(XlnxZynqMPState *s, const char *boot_cpu,int i;int num_rpus =MIN (smp_cpus -XLNX_ZYNQMP_NUM_APU_CPUS ,XLNX_ZYNQMP_NUM_RPU_CPUS );Not related to this patch, but this check seems dangerous, i.e. using "-smp 2" we get num_rpus=-2 which luckyly doesn't enter the
for()loop.Quoted 1 line
Quoted 3 lines
Quoted 1 line
+ if (
num_rpus== 0) {With the current codebase, you'd have to check for "
num_rpus<= 0", ...
Oops, nice catch.
Quoted 9 lines
What about this instead?
-- >8 --
(quoted diff) +0
-1@@ -451,10 +451,12 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) "RPUs just use -smp 6."); } - xlnx_zynqmp_create_rpu(s, boot_cpu, &err);
Review static void xlnx_zynqmp_realize(DeviceState *dev, · line 461
Quoted 10 lines
(quoted diff) +6
-3- if (err) { - error_propagate(errp, err); - return; + if (smp_cpus > XLNX_ZYNQMP_NUM_APU_CPUS) { + xlnx_zynqmp_create_rpu(s, boot_cpu, &err); + if (err) { + error_propagate(errp, err); + return; + } }
Yeah, that would work too. I think I would just go for using "if (num_rpus <= 0)" in the function, though.
thanks
-- PMM
Quoted 47 lines · Peter Maydell
Quoted 32 lines · Philippe Mathieu-Daudé
Hi Peter,
Quoted 21 lines · Peter Maydell
If we aren't going to create any RPUs, then don't create the rpu-cluster unit. This allows us to add an assertion to the cluster object that it contains at least one CPU, which helps to avoid bugs in creating clusters and putting CPUs in them.
Signed-off-by Peter Maydell <[email protected]>---
This is a preparatory patch that is necessary for the series "[PATCH v3 0/4] tcg: support heterogenous CPU clusters" ([email protected])
in order to avoid the xlnx-zcu102 board asserting if started with fewer than 5 CPUs.hw/arm/xlnx-zynqmp.c | 5 +++++ 1 file changed, 5 insertions(+)hw/arm/xlnx-zynqmp.c +0
-0hw/arm/xlnx-zynqmp.c static void xlnx_zynqmp_create_rpu(XlnxZynqMPState *s, const char *boot_cpu, · line 179
Quoted 2 lines
hw/arm/xlnx-zynqmp.c +0
-0@@ -178,6 +178,11 @@ static void xlnx_zynqmp_create_rpu(XlnxZynqMPState *s, const char *boot_cpu,int i;int num_rpus =MIN (smp_cpus -XLNX_ZYNQMP_NUM_APU_CPUS ,XLNX_ZYNQMP_NUM_RPU_CPUS );Not related to this patch, but this check seems dangerous, i.e. using "-smp 2" we get num_rpus=-2 which luckyly doesn't enter the
for()loop.Quoted 1 line
Quoted 3 lines
Quoted 1 line
+ if (
num_rpus== 0) {With the current codebase, you'd have to check for "
num_rpus<= 0", ...Oops, nice catch.
Quoted 8 lines
What about this instead?
-- >8 --
(quoted diff) +0
-0@@ -451,10 +451,12 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) "RPUs just use -smp 6."); }
Quoted 14 lines
Review static void xlnx_zynqmp_realize(DeviceState *dev, · line 461
Quoted 11 lines
(quoted diff) +6
-4- xlnx_zynqmp_create_rpu(s, boot_cpu, &err); - if (err) { - error_propagate(errp, err); - return; + if (smp_cpus > XLNX_ZYNQMP_NUM_APU_CPUS) { + xlnx_zynqmp_create_rpu(s, boot_cpu, &err); + if (err) { + error_propagate(errp, err); + return; + } }Yeah, that would work too. I think I would just go for using "if (
num_rpus<= 0)" in the function, though.
OK, whichever patch you prefer, you can add:
Regards,
Phil.
Quoted 4 lines
thanks
-- PMM
Quoted 22 lines · Peter Maydell
If we aren't going to create any RPUs, then don't create the rpu-cluster unit. This allows us to add an assertion to the cluster object that it contains at least one CPU, which helps to avoid bugs in creating clusters and putting CPUs in them.
Signed-off-by Peter Maydell <[email protected]>---
This is a preparatory patch that is necessary for the series "[PATCH v3 0/4] tcg: support heterogenous CPU clusters" ([email protected])
in order to avoid the xlnx-zcu102 board asserting if started with fewer than 5 CPUs.hw/arm/xlnx-zynqmp.c | 5 +++++ 1 file changed, 5 insertions(+)hw/arm/xlnx-zynqmp.c +0
-0
hw/arm/xlnx-zynqmp.c static void xlnx_zynqmp_create_rpu(XlnxZynqMPState *s, const char *boot_cpu, · line 184
Quoted 7 lines
hw/arm/xlnx-zynqmp.c +4
-0@@ -178,6 +178,11 @@ static void xlnx_zynqmp_create_rpu(XlnxZynqMPState *s, const char *boot_cpu,int i;int num_rpus =MIN (smp_cpus -XLNX_ZYNQMP_NUM_APU_CPUS ,XLNX_ZYNQMP_NUM_RPU_CPUS ); +if (num_rpus ==0 ) { +/* Don't create rpu-cluster object if there's nothing to put in it */ +return ; + }
Applied to target-arm.next with a fixup to test for "<= 0".
thanks
-- PMM