diff mbox

[12/16] target-i386: cpu: attach ICC bus to CPU on its creation

Message ID 1366063976-4909-13-git-send-email-imammedo@redhat.com
State New
Headers show

Commit Message

Igor Mammedov April 15, 2013, 10:12 p.m. UTC
... during startup,  so it would be possible to unplug it later
and set bus_type to TYPE_ICC_BUS for X86CPU type to make device_add
attach hotplugged CPU to ICC bus.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 target-i386/cpu.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Andreas Färber April 22, 2013, 3:02 p.m. UTC | #1
Am 16.04.2013 00:12, schrieb Igor Mammedov:
> ... during startup,  so it would be possible to unplug it later
> and set bus_type to TYPE_ICC_BUS for X86CPU type to make device_add
> attach hotplugged CPU to ICC bus.
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>

Reviewed-by: Andreas Färber <afaerber@suse.de>

But still one question...

> ---
>  target-i386/cpu.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> index 6d6c527..3b5f90b 100644
> --- a/target-i386/cpu.c
> +++ b/target-i386/cpu.c
> @@ -41,6 +41,7 @@
>  #endif
>  
>  #include "sysemu/sysemu.h"
> +#include "hw/i386/icc_bus.h"
>  #ifndef CONFIG_USER_ONLY
>  #include "hw/xen/xen.h"
>  #include "hw/sysbus.h"
> @@ -1609,6 +1610,7 @@ X86CPU *cpu_x86_create(const char *cpu_model, Error **errp)
>      gchar **model_pieces;
>      char *name, *features;
>      Error *error = NULL;
> +    Object *icc_bus = object_resolve_path_type("icc-bus", TYPE_ICC_BUS, NULL);
>  
>      model_pieces = g_strsplit(cpu_model, ",", 2);
>      if (!model_pieces[0]) {
> @@ -1619,6 +1621,10 @@ X86CPU *cpu_x86_create(const char *cpu_model, Error **errp)
>      features = model_pieces[1];
>  
>      cpu = X86_CPU(object_new(TYPE_X86_CPU));
> +    if (icc_bus) {
> +        qdev_set_parent_bus(DEVICE(cpu), BUS(icc_bus));
> +        object_unref(OBJECT(cpu));
> +    }
>      env = &cpu->env;
>      env->cpu_model_str = cpu_model;
>  

You seem to be avoiding making lack of icc-bus an error although you add
it for both PC and q35 PC - which non-ICC use cases are you thinking of?

Andreas

> @@ -2330,6 +2336,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
>  
>      xcc->parent_realize = dc->realize;
>      dc->realize = x86_cpu_realizefn;
> +    dc->bus_type = TYPE_ICC_BUS;
>  
>      xcc->parent_reset = cc->reset;
>      cc->reset = x86_cpu_reset;
>
Igor Mammedov April 22, 2013, 3:20 p.m. UTC | #2
On Mon, 22 Apr 2013 17:02:33 +0200
Andreas Färber <afaerber@suse.de> wrote:

> Am 16.04.2013 00:12, schrieb Igor Mammedov:
> > ... during startup,  so it would be possible to unplug it later
> > and set bus_type to TYPE_ICC_BUS for X86CPU type to make device_add
> > attach hotplugged CPU to ICC bus.
> > 
> > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> 
> Reviewed-by: Andreas Färber <afaerber@suse.de>
> 
> But still one question...
> 
> > ---
> >  target-i386/cpu.c | 7 +++++++
> >  1 file changed, 7 insertions(+)
> > 
> > diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> > index 6d6c527..3b5f90b 100644
> > --- a/target-i386/cpu.c
> > +++ b/target-i386/cpu.c
> > @@ -41,6 +41,7 @@
> >  #endif
> >  
> >  #include "sysemu/sysemu.h"
> > +#include "hw/i386/icc_bus.h"
> >  #ifndef CONFIG_USER_ONLY
> >  #include "hw/xen/xen.h"
> >  #include "hw/sysbus.h"
> > @@ -1609,6 +1610,7 @@ X86CPU *cpu_x86_create(const char *cpu_model, Error
> > **errp) gchar **model_pieces;
> >      char *name, *features;
> >      Error *error = NULL;
> > +    Object *icc_bus = object_resolve_path_type("icc-bus", TYPE_ICC_BUS,
> > NULL); 
> >      model_pieces = g_strsplit(cpu_model, ",", 2);
> >      if (!model_pieces[0]) {
> > @@ -1619,6 +1621,10 @@ X86CPU *cpu_x86_create(const char *cpu_model,
> > Error **errp) features = model_pieces[1];
> >  
> >      cpu = X86_CPU(object_new(TYPE_X86_CPU));
> > +    if (icc_bus) {
> > +        qdev_set_parent_bus(DEVICE(cpu), BUS(icc_bus));
> > +        object_unref(OBJECT(cpu));
> > +    }
> >      env = &cpu->env;
> >      env->cpu_model_str = cpu_model;
> >  
> 
> You seem to be avoiding making lack of icc-bus an error although you add
> it for both PC and q35 PC - which non-ICC use cases are you thinking of?
*-user targets, CPU is bus-less there.

> 
> Andreas
> 
> > @@ -2330,6 +2336,7 @@ static void x86_cpu_common_class_init(ObjectClass
> > *oc, void *data) 
> >      xcc->parent_realize = dc->realize;
> >      dc->realize = x86_cpu_realizefn;
> > +    dc->bus_type = TYPE_ICC_BUS;
> >  
> >      xcc->parent_reset = cc->reset;
> >      cc->reset = x86_cpu_reset;
> > 
> 
>
Andreas Färber April 22, 2013, 3:27 p.m. UTC | #3
Am 22.04.2013 17:20, schrieb Igor Mammedov:
> On Mon, 22 Apr 2013 17:02:33 +0200
> Andreas Färber <afaerber@suse.de> wrote:
> 
>> Am 16.04.2013 00:12, schrieb Igor Mammedov:
>>> ... during startup,  so it would be possible to unplug it later
>>> and set bus_type to TYPE_ICC_BUS for X86CPU type to make device_add
>>> attach hotplugged CPU to ICC bus.
>>>
>>> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
>>
>> Reviewed-by: Andreas Färber <afaerber@suse.de>
>>
>> But still one question...
>>
>>> ---
>>>  target-i386/cpu.c | 7 +++++++
>>>  1 file changed, 7 insertions(+)
>>>
>>> diff --git a/target-i386/cpu.c b/target-i386/cpu.c
>>> index 6d6c527..3b5f90b 100644
>>> --- a/target-i386/cpu.c
>>> +++ b/target-i386/cpu.c
>>> @@ -41,6 +41,7 @@
>>>  #endif
>>>  
>>>  #include "sysemu/sysemu.h"
>>> +#include "hw/i386/icc_bus.h"
>>>  #ifndef CONFIG_USER_ONLY
>>>  #include "hw/xen/xen.h"
>>>  #include "hw/sysbus.h"
>>> @@ -1609,6 +1610,7 @@ X86CPU *cpu_x86_create(const char *cpu_model, Error
>>> **errp) gchar **model_pieces;
>>>      char *name, *features;
>>>      Error *error = NULL;
>>> +    Object *icc_bus = object_resolve_path_type("icc-bus", TYPE_ICC_BUS,
>>> NULL); 
>>>      model_pieces = g_strsplit(cpu_model, ",", 2);
>>>      if (!model_pieces[0]) {
>>> @@ -1619,6 +1621,10 @@ X86CPU *cpu_x86_create(const char *cpu_model,
>>> Error **errp) features = model_pieces[1];
>>>  
>>>      cpu = X86_CPU(object_new(TYPE_X86_CPU));
>>> +    if (icc_bus) {
>>> +        qdev_set_parent_bus(DEVICE(cpu), BUS(icc_bus));
>>> +        object_unref(OBJECT(cpu));
>>> +    }
>>>      env = &cpu->env;
>>>      env->cpu_model_str = cpu_model;
>>>  
>>
>> You seem to be avoiding making lack of icc-bus an error although you add
>> it for both PC and q35 PC - which non-ICC use cases are you thinking of?
> *-user targets, CPU is bus-less there.

Would you be opposed to #ifdef'ing it then? In particular I am asking
because of the NULL error argument to the resolve function - for softmmu
I would prefer to make lack of icc-bus a fatal error.

Andreas
Igor Mammedov April 22, 2013, 7:14 p.m. UTC | #4
On Mon, 22 Apr 2013 17:27:29 +0200
Andreas Färber <afaerber@suse.de> wrote:

> Am 22.04.2013 17:20, schrieb Igor Mammedov:
> > On Mon, 22 Apr 2013 17:02:33 +0200
> > Andreas Färber <afaerber@suse.de> wrote:
> > 
> >> Am 16.04.2013 00:12, schrieb Igor Mammedov:
> >>> ... during startup,  so it would be possible to unplug it later
> >>> and set bus_type to TYPE_ICC_BUS for X86CPU type to make device_add
> >>> attach hotplugged CPU to ICC bus.
> >>>
> >>> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> >>
> >> Reviewed-by: Andreas Färber <afaerber@suse.de>
> >>
> >> But still one question...
> >>
> >>> ---
> >>>  target-i386/cpu.c | 7 +++++++
> >>>  1 file changed, 7 insertions(+)
> >>>
> >>> diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> >>> index 6d6c527..3b5f90b 100644
> >>> --- a/target-i386/cpu.c
> >>> +++ b/target-i386/cpu.c
> >>> @@ -41,6 +41,7 @@
> >>>  #endif
> >>>  
> >>>  #include "sysemu/sysemu.h"
> >>> +#include "hw/i386/icc_bus.h"
> >>>  #ifndef CONFIG_USER_ONLY
> >>>  #include "hw/xen/xen.h"
> >>>  #include "hw/sysbus.h"
> >>> @@ -1609,6 +1610,7 @@ X86CPU *cpu_x86_create(const char *cpu_model,
> >>> Error **errp) gchar **model_pieces;
> >>>      char *name, *features;
> >>>      Error *error = NULL;
> >>> +    Object *icc_bus = object_resolve_path_type("icc-bus", TYPE_ICC_BUS,
> >>> NULL); 
> >>>      model_pieces = g_strsplit(cpu_model, ",", 2);
> >>>      if (!model_pieces[0]) {
> >>> @@ -1619,6 +1621,10 @@ X86CPU *cpu_x86_create(const char *cpu_model,
> >>> Error **errp) features = model_pieces[1];
> >>>  
> >>>      cpu = X86_CPU(object_new(TYPE_X86_CPU));
> >>> +    if (icc_bus) {
> >>> +        qdev_set_parent_bus(DEVICE(cpu), BUS(icc_bus));
> >>> +        object_unref(OBJECT(cpu));
> >>> +    }
> >>>      env = &cpu->env;
> >>>      env->cpu_model_str = cpu_model;
> >>>  
> >>
> >> You seem to be avoiding making lack of icc-bus an error although you add
> >> it for both PC and q35 PC - which non-ICC use cases are you thinking of?
> > *-user targets, CPU is bus-less there.
> 
> Would you be opposed to #ifdef'ing it then? In particular I am asking
> because of the NULL error argument to the resolve function - for softmmu
> I would prefer to make lack of icc-bus a fatal error.
I'm fine with ifdef-ing there, if there is not objections.
I'll look at making it fatal error on softmmu

> 
> Andreas
>
diff mbox

Patch

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 6d6c527..3b5f90b 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -41,6 +41,7 @@ 
 #endif
 
 #include "sysemu/sysemu.h"
+#include "hw/i386/icc_bus.h"
 #ifndef CONFIG_USER_ONLY
 #include "hw/xen/xen.h"
 #include "hw/sysbus.h"
@@ -1609,6 +1610,7 @@  X86CPU *cpu_x86_create(const char *cpu_model, Error **errp)
     gchar **model_pieces;
     char *name, *features;
     Error *error = NULL;
+    Object *icc_bus = object_resolve_path_type("icc-bus", TYPE_ICC_BUS, NULL);
 
     model_pieces = g_strsplit(cpu_model, ",", 2);
     if (!model_pieces[0]) {
@@ -1619,6 +1621,10 @@  X86CPU *cpu_x86_create(const char *cpu_model, Error **errp)
     features = model_pieces[1];
 
     cpu = X86_CPU(object_new(TYPE_X86_CPU));
+    if (icc_bus) {
+        qdev_set_parent_bus(DEVICE(cpu), BUS(icc_bus));
+        object_unref(OBJECT(cpu));
+    }
     env = &cpu->env;
     env->cpu_model_str = cpu_model;
 
@@ -2330,6 +2336,7 @@  static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
 
     xcc->parent_realize = dc->realize;
     dc->realize = x86_cpu_realizefn;
+    dc->bus_type = TYPE_ICC_BUS;
 
     xcc->parent_reset = cc->reset;
     cc->reset = x86_cpu_reset;