* [Qemu-devel] [PATCH] hw/arm/fsl-imx: move cpus initialization to realize time after smp_cpus check
@ 2019-04-30 8:50 Like Xu
2019-04-30 8:50 ` Like Xu
2019-04-30 9:18 ` Peter Maydell
0 siblings, 2 replies; 6+ messages in thread
From: Like Xu @ 2019-04-30 8:50 UTC (permalink / raw)
To: qemu-arm, qemu-devel
Cc: Peter Maydell, Jean-Christophe Dubois, Andrey Smirnov,
Igor Mammedov
If "smp_cpus> FSL_IMX6_NUM_CPUS" fails in *_realize(), there is no need to
initialize the CPUs in *_init(). So it could be better to create all cpus
after the validity in *_realize(). On the other hand, it makes the usages
of global variable smp_cpus more centrally for maintenance.
Suggested-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Like Xu <like.xu@linux.intel.com>
---
hw/arm/fsl-imx6.c | 13 +++++++------
hw/arm/fsl-imx6ul.c | 12 ++++++------
hw/arm/fsl-imx7.c | 15 +++++++--------
3 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c
index 7b7b97f..14015a1 100644
--- a/hw/arm/fsl-imx6.c
+++ b/hw/arm/fsl-imx6.c
@@ -37,12 +37,6 @@ static void fsl_imx6_init(Object *obj)
char name[NAME_SIZE];
int i;
- for (i = 0; i < MIN(smp_cpus, FSL_IMX6_NUM_CPUS); i++) {
- snprintf(name, NAME_SIZE, "cpu%d", i);
- object_initialize_child(obj, name, &s->cpu[i], sizeof(s->cpu[i]),
- "cortex-a9-" TYPE_ARM_CPU, &error_abort, NULL);
- }
-
sysbus_init_child_obj(obj, "a9mpcore", &s->a9mpcore, sizeof(s->a9mpcore),
TYPE_A9MPCORE_PRIV);
@@ -95,6 +89,7 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
{
FslIMX6State *s = FSL_IMX6(dev);
uint16_t i;
+ char name[NAME_SIZE];
Error *err = NULL;
if (smp_cpus > FSL_IMX6_NUM_CPUS) {
@@ -103,6 +98,12 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
return;
}
+ for (i = 0; i < MIN(smp_cpus, FSL_IMX6_NUM_CPUS); i++) {
+ snprintf(name, NAME_SIZE, "cpu%d", i);
+ object_initialize_child(OBJECT(dev), name, &s->cpu[i],
+ sizeof(s->cpu[i]), "cortex-a9-" TYPE_ARM_CPU, &error_abort, NULL);
+ }
+
for (i = 0; i < smp_cpus; i++) {
/* On uniprocessor, the CBAR is set to 0 */
diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c
index 4b56bfa..7f30eb7 100644
--- a/hw/arm/fsl-imx6ul.c
+++ b/hw/arm/fsl-imx6ul.c
@@ -32,12 +32,6 @@ static void fsl_imx6ul_init(Object *obj)
char name[NAME_SIZE];
int i;
- for (i = 0; i < MIN(smp_cpus, FSL_IMX6UL_NUM_CPUS); i++) {
- snprintf(name, NAME_SIZE, "cpu%d", i);
- object_initialize_child(obj, name, &s->cpu[i], sizeof(s->cpu[i]),
- "cortex-a7-" TYPE_ARM_CPU, &error_abort, NULL);
- }
-
/*
* A7MPCORE
*/
@@ -167,6 +161,12 @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
return;
}
+ for (i = 0; i < MIN(smp_cpus, FSL_IMX6UL_NUM_CPUS); i++) {
+ snprintf(name, NAME_SIZE, "cpu%d", i);
+ object_initialize_child(OBJECT(dev), name, &s->cpu[i],
+ sizeof(s->cpu[i]), "cortex-a7-" TYPE_ARM_CPU, &error_abort, NULL);
+ }
+
for (i = 0; i < smp_cpus; i++) {
Object *o = OBJECT(&s->cpu[i]);
diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c
index 7663ad6..2580348 100644
--- a/hw/arm/fsl-imx7.c
+++ b/hw/arm/fsl-imx7.c
@@ -34,14 +34,6 @@ static void fsl_imx7_init(Object *obj)
char name[NAME_SIZE];
int i;
-
- for (i = 0; i < MIN(smp_cpus, FSL_IMX7_NUM_CPUS); i++) {
- snprintf(name, NAME_SIZE, "cpu%d", i);
- object_initialize_child(obj, name, &s->cpu[i], sizeof(s->cpu[i]),
- ARM_CPU_TYPE_NAME("cortex-a7"), &error_abort,
- NULL);
- }
-
/*
* A7MPCORE
*/
@@ -167,6 +159,13 @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp)
return;
}
+ for (i = 0; i < MIN(smp_cpus, FSL_IMX7_NUM_CPUS); i++) {
+ snprintf(name, NAME_SIZE, "cpu%d", i);
+ object_initialize_child(OBJECT(dev), name, &s->cpu[i],
+ sizeof(s->cpu[i]), ARM_CPU_TYPE_NAME("cortex-a7"),
+ &error_abort, NULL);
+ }
+
for (i = 0; i < smp_cpus; i++) {
o = OBJECT(&s->cpu[i]);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH] hw/arm/fsl-imx: move cpus initialization to realize time after smp_cpus check
2019-04-30 8:50 [Qemu-devel] [PATCH] hw/arm/fsl-imx: move cpus initialization to realize time after smp_cpus check Like Xu
@ 2019-04-30 8:50 ` Like Xu
2019-04-30 9:18 ` Peter Maydell
1 sibling, 0 replies; 6+ messages in thread
From: Like Xu @ 2019-04-30 8:50 UTC (permalink / raw)
To: qemu-arm, qemu-devel
Cc: Andrey Smirnov, Peter Maydell, Igor Mammedov,
Jean-Christophe Dubois
If "smp_cpus> FSL_IMX6_NUM_CPUS" fails in *_realize(), there is no need to
initialize the CPUs in *_init(). So it could be better to create all cpus
after the validity in *_realize(). On the other hand, it makes the usages
of global variable smp_cpus more centrally for maintenance.
Suggested-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Like Xu <like.xu@linux.intel.com>
---
hw/arm/fsl-imx6.c | 13 +++++++------
hw/arm/fsl-imx6ul.c | 12 ++++++------
hw/arm/fsl-imx7.c | 15 +++++++--------
3 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c
index 7b7b97f..14015a1 100644
--- a/hw/arm/fsl-imx6.c
+++ b/hw/arm/fsl-imx6.c
@@ -37,12 +37,6 @@ static void fsl_imx6_init(Object *obj)
char name[NAME_SIZE];
int i;
- for (i = 0; i < MIN(smp_cpus, FSL_IMX6_NUM_CPUS); i++) {
- snprintf(name, NAME_SIZE, "cpu%d", i);
- object_initialize_child(obj, name, &s->cpu[i], sizeof(s->cpu[i]),
- "cortex-a9-" TYPE_ARM_CPU, &error_abort, NULL);
- }
-
sysbus_init_child_obj(obj, "a9mpcore", &s->a9mpcore, sizeof(s->a9mpcore),
TYPE_A9MPCORE_PRIV);
@@ -95,6 +89,7 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
{
FslIMX6State *s = FSL_IMX6(dev);
uint16_t i;
+ char name[NAME_SIZE];
Error *err = NULL;
if (smp_cpus > FSL_IMX6_NUM_CPUS) {
@@ -103,6 +98,12 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
return;
}
+ for (i = 0; i < MIN(smp_cpus, FSL_IMX6_NUM_CPUS); i++) {
+ snprintf(name, NAME_SIZE, "cpu%d", i);
+ object_initialize_child(OBJECT(dev), name, &s->cpu[i],
+ sizeof(s->cpu[i]), "cortex-a9-" TYPE_ARM_CPU, &error_abort, NULL);
+ }
+
for (i = 0; i < smp_cpus; i++) {
/* On uniprocessor, the CBAR is set to 0 */
diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c
index 4b56bfa..7f30eb7 100644
--- a/hw/arm/fsl-imx6ul.c
+++ b/hw/arm/fsl-imx6ul.c
@@ -32,12 +32,6 @@ static void fsl_imx6ul_init(Object *obj)
char name[NAME_SIZE];
int i;
- for (i = 0; i < MIN(smp_cpus, FSL_IMX6UL_NUM_CPUS); i++) {
- snprintf(name, NAME_SIZE, "cpu%d", i);
- object_initialize_child(obj, name, &s->cpu[i], sizeof(s->cpu[i]),
- "cortex-a7-" TYPE_ARM_CPU, &error_abort, NULL);
- }
-
/*
* A7MPCORE
*/
@@ -167,6 +161,12 @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
return;
}
+ for (i = 0; i < MIN(smp_cpus, FSL_IMX6UL_NUM_CPUS); i++) {
+ snprintf(name, NAME_SIZE, "cpu%d", i);
+ object_initialize_child(OBJECT(dev), name, &s->cpu[i],
+ sizeof(s->cpu[i]), "cortex-a7-" TYPE_ARM_CPU, &error_abort, NULL);
+ }
+
for (i = 0; i < smp_cpus; i++) {
Object *o = OBJECT(&s->cpu[i]);
diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c
index 7663ad6..2580348 100644
--- a/hw/arm/fsl-imx7.c
+++ b/hw/arm/fsl-imx7.c
@@ -34,14 +34,6 @@ static void fsl_imx7_init(Object *obj)
char name[NAME_SIZE];
int i;
-
- for (i = 0; i < MIN(smp_cpus, FSL_IMX7_NUM_CPUS); i++) {
- snprintf(name, NAME_SIZE, "cpu%d", i);
- object_initialize_child(obj, name, &s->cpu[i], sizeof(s->cpu[i]),
- ARM_CPU_TYPE_NAME("cortex-a7"), &error_abort,
- NULL);
- }
-
/*
* A7MPCORE
*/
@@ -167,6 +159,13 @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp)
return;
}
+ for (i = 0; i < MIN(smp_cpus, FSL_IMX7_NUM_CPUS); i++) {
+ snprintf(name, NAME_SIZE, "cpu%d", i);
+ object_initialize_child(OBJECT(dev), name, &s->cpu[i],
+ sizeof(s->cpu[i]), ARM_CPU_TYPE_NAME("cortex-a7"),
+ &error_abort, NULL);
+ }
+
for (i = 0; i < smp_cpus; i++) {
o = OBJECT(&s->cpu[i]);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/arm/fsl-imx: move cpus initialization to realize time after smp_cpus check
2019-04-30 8:50 [Qemu-devel] [PATCH] hw/arm/fsl-imx: move cpus initialization to realize time after smp_cpus check Like Xu
2019-04-30 8:50 ` Like Xu
@ 2019-04-30 9:18 ` Peter Maydell
2019-04-30 9:18 ` Peter Maydell
2019-05-02 15:00 ` Igor Mammedov
1 sibling, 2 replies; 6+ messages in thread
From: Peter Maydell @ 2019-04-30 9:18 UTC (permalink / raw)
To: Like Xu
Cc: qemu-arm, QEMU Developers, Jean-Christophe Dubois, Andrey Smirnov,
Igor Mammedov
On Tue, 30 Apr 2019 at 09:52, Like Xu <like.xu@linux.intel.com> wrote:
>
> If "smp_cpus> FSL_IMX6_NUM_CPUS" fails in *_realize(), there is no need to
> initialize the CPUs in *_init(). So it could be better to create all cpus
> after the validity in *_realize(). On the other hand, it makes the usages
> of global variable smp_cpus more centrally for maintenance.
I'm not a great fan of this. I think that where possible
we should init child objects in the parent's init
function, and realize them in the realize function.
There are a few cases where we're forced to do the
child init in realize, but this doesn't seem like one of them.
thanks
-- PMM
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/arm/fsl-imx: move cpus initialization to realize time after smp_cpus check
2019-04-30 9:18 ` Peter Maydell
@ 2019-04-30 9:18 ` Peter Maydell
2019-05-02 15:00 ` Igor Mammedov
1 sibling, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2019-04-30 9:18 UTC (permalink / raw)
To: Like Xu
Cc: Andrey Smirnov, Igor Mammedov, qemu-arm, QEMU Developers,
Jean-Christophe Dubois
On Tue, 30 Apr 2019 at 09:52, Like Xu <like.xu@linux.intel.com> wrote:
>
> If "smp_cpus> FSL_IMX6_NUM_CPUS" fails in *_realize(), there is no need to
> initialize the CPUs in *_init(). So it could be better to create all cpus
> after the validity in *_realize(). On the other hand, it makes the usages
> of global variable smp_cpus more centrally for maintenance.
I'm not a great fan of this. I think that where possible
we should init child objects in the parent's init
function, and realize them in the realize function.
There are a few cases where we're forced to do the
child init in realize, but this doesn't seem like one of them.
thanks
-- PMM
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/arm/fsl-imx: move cpus initialization to realize time after smp_cpus check
2019-04-30 9:18 ` Peter Maydell
2019-04-30 9:18 ` Peter Maydell
@ 2019-05-02 15:00 ` Igor Mammedov
2019-05-02 15:00 ` Igor Mammedov
1 sibling, 1 reply; 6+ messages in thread
From: Igor Mammedov @ 2019-05-02 15:00 UTC (permalink / raw)
To: Peter Maydell
Cc: Like Xu, qemu-arm, QEMU Developers, Jean-Christophe Dubois,
Andrey Smirnov
On Tue, 30 Apr 2019 10:18:37 +0100
Peter Maydell <peter.maydell@linaro.org> wrote:
> On Tue, 30 Apr 2019 at 09:52, Like Xu <like.xu@linux.intel.com> wrote:
> >
> > If "smp_cpus> FSL_IMX6_NUM_CPUS" fails in *_realize(), there is no need to
> > initialize the CPUs in *_init(). So it could be better to create all cpus
> > after the validity in *_realize(). On the other hand, it makes the usages
> > of global variable smp_cpus more centrally for maintenance.
>
> I'm not a great fan of this. I think that where possible
> we should init child objects in the parent's init
> function, and realize them in the realize function.
> There are a few cases where we're forced to do the
> child init in realize, but this doesn't seem like one of them.
well, if it were unconditional then initializing children in initfn would
be fine, however here number of children to initialize depends on global
smp_cpus. In order to get rid of global, we could move iniialization to realize
time or init all FSL_IMX6_NUM_CPUS and realize only smp_cpus at realize time.
>
> thanks
> -- PMM
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/arm/fsl-imx: move cpus initialization to realize time after smp_cpus check
2019-05-02 15:00 ` Igor Mammedov
@ 2019-05-02 15:00 ` Igor Mammedov
0 siblings, 0 replies; 6+ messages in thread
From: Igor Mammedov @ 2019-05-02 15:00 UTC (permalink / raw)
To: Peter Maydell
Cc: Andrey Smirnov, qemu-arm, QEMU Developers, Like Xu,
Jean-Christophe Dubois
On Tue, 30 Apr 2019 10:18:37 +0100
Peter Maydell <peter.maydell@linaro.org> wrote:
> On Tue, 30 Apr 2019 at 09:52, Like Xu <like.xu@linux.intel.com> wrote:
> >
> > If "smp_cpus> FSL_IMX6_NUM_CPUS" fails in *_realize(), there is no need to
> > initialize the CPUs in *_init(). So it could be better to create all cpus
> > after the validity in *_realize(). On the other hand, it makes the usages
> > of global variable smp_cpus more centrally for maintenance.
>
> I'm not a great fan of this. I think that where possible
> we should init child objects in the parent's init
> function, and realize them in the realize function.
> There are a few cases where we're forced to do the
> child init in realize, but this doesn't seem like one of them.
well, if it were unconditional then initializing children in initfn would
be fine, however here number of children to initialize depends on global
smp_cpus. In order to get rid of global, we could move iniialization to realize
time or init all FSL_IMX6_NUM_CPUS and realize only smp_cpus at realize time.
>
> thanks
> -- PMM
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-05-02 15:19 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-30 8:50 [Qemu-devel] [PATCH] hw/arm/fsl-imx: move cpus initialization to realize time after smp_cpus check Like Xu
2019-04-30 8:50 ` Like Xu
2019-04-30 9:18 ` Peter Maydell
2019-04-30 9:18 ` Peter Maydell
2019-05-02 15:00 ` Igor Mammedov
2019-05-02 15:00 ` Igor Mammedov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).