ppc/xics: simplify ICS and ICP creation
v2 cover ppc/xics: simplify ICS and ICP creation
Hello,
The goal behind this series is to simplify the XICS interface by moving back in the machine the way the ICS and ICP objects interact together. It's up to the machine to implement this "fabric" logic by providing a set of handlers of a QOM interface. These handlers are used to grab an ICS or an ICP object and also do irq resends. This idea was suggested by David Gibson.
The patchset is organised as follow. It starts with a preliminary cleanup to get rid of the set_nr_irqs() and set_nr_servers() handlers. It also moves the creation of the ICS and ICP objects from the XICS object to the sPAPR machine. This simplifies the code significantly and prepares ground for future changes.
As the sPAPR machine only makes use of a single ICS, we can store it at the machine level. This lets us remove dependencies on the list of ICS of the XICS object and simplify even more the code for the following changes.
The QOM interface to interact with the ICS and ICP objects is then introduced. These are moved under the machine and cleanups are done accordingly.
Finally, the XICSState classes are removed as they have been deprecated by the QOM interface.
After the initial cleanups, which are rather big, I have tried to keep the each patch small enough to ease the review and to spot any problem. Each should be bisectable. The tree is available here :
https://github.com/legoater/qemu/tree/ppc-2.9
Thanks,
C.
Changes since v1:
- address the full picture.
Cédric Le Goater (22):
ppc/xics: remove set_nr_irqs() handler from XICSStateClass ppc/xics: remove set_nr_servers() handler from XICSStateClass ppc/xics: store the ICS object under the sPAPR machine ppc/xics: add an InterruptStatsProvider interface to ICS and ICP
objects
ppc/xics: introduce a QOM interface to handle ICSs ppc/xics: use the QOM interface under the sPAPR machine ppc/xics: use the QOM interface to get irqs
ppc/xics: use the QOM interface to resend irqs ppc/xics: remove xics_find_source()
ppc/xics: register the reset handler of ICS objects ppc/xics: remove the XICS list of ICS
ppc/xics: extend the QOM interface to handle ICPs ppc/xics: simplify the cpu_setup() handler
ppc/xics: use the QOM interface to grab an ICP ppc/xics: simplify spapr_dt_xics() interface ppc/xics: register the reset handler of ICP objects ppc/xics: move the ICP array under the sPAPR machine ppc/xics: move kernel_xics_fd out of KVMXICSState ppc/xics: move the cpu_setup() handler under the ICPState class ppc/xics: remove the 'xics' backlinks
ppc/xics: export the XICS init routines
ppc/xics: remove the XICSState classes
hw/intc/xics.c | 295 +++++++++++++------------------------------- hw/intc/xics_kvm.c | 154 ++++++----------------- hw/intc/xics_spapr.c | 128 ++++--------------- hw/ppc/spapr.c | 116 +++++++++++++---- hw/ppc/spapr_cpu_core.c | 4 +- hw/ppc/spapr_events.c | 10 +- hw/ppc/spapr_pci.c | 10 +- hw/ppc/spapr_vio.c | 2 +- include/hw/pci-host/spapr.h | 2 +- include/hw/ppc/spapr.h | 5 +- include/hw/ppc/spapr_vio.h | 2 +- include/hw/ppc/xics.h | 93 ++++++-------- 12 files changed, 294 insertions(+), 527 deletions(-)
Signature · 1 line
2.7.4
PATCH v2 1/22 ppc/xics: remove set_nr_irqs() handler from XICSStateClass
Today, the ICS (Interrupt Controller Source) object is created and realized by the init and realize routines of the XICS object, but some of the parameters are only known at the machine level.
These parameters are passed from the sPAPR machine to the ICS object in a rather convoluted way using property handlers and a class handler of the XICS object. The number of irqs required to allocate the IRQ state objects in the ICS realize routine is one of them.
Let's simplify the process by creating the ICS object along with the XICS object at the machine level and link the ICS into the XICS list of ICSs at this level also. In the sPAPR machine, there is only a single ICS but that will change with the PowerNV machine.
Also, QOMify the creation of the objects and get rid of the superfluous code.
---
Changes since v1:
- added a XICS link to the ICS object
hw/intc/xics.c | 51 ++++++++++++++++--------------------------------- hw/intc/xics_kvm.c | 44 ++++++++++-------------------------------- hw/intc/xics_spapr.c | 34 --------------------------------- hw/ppc/spapr.c | 53 +++++++++++++++++++++++++++++++++++---------------- include/hw/ppc/xics.h | 2 -- 5 files changed, 63 insertions(+), 121 deletions(-)
hw/intc/xics.c +16 -35
@@ -151,38 +151,6 @@ static void xics_common_reset(DeviceState *d) } } -static void xics_prop_get_nr_irqs (Object *obj,Visitor *v,const char *name, -void *opaque,Error **errp) -{ -XICSState *xics =XICS_COMMON (obj); -int64_t value = xics->nr_irqs; - -visit_type_int (v, name, &value, errp); -} - -static void xics_prop_set_nr_irqs (Object *obj,Visitor *v,const char *name, -void *opaque,Error **errp) -{ -XICSState *xics =XICS_COMMON (obj); -XICSStateClass *info =XICS_COMMON_GET_CLASS (xics); -Error *error =NULL ; -int64_t value; - -visit_type_int (v, name, &value, &error); -if (error) { -error_propagate (errp, error); -return ; - } -if (xics->nr_irqs) { -error_setg (errp,"Number of interrupts is already set to %u" , - xics->nr_irqs); -return ; - } - -assert (info->set_nr_irqs); - info->set_nr_irqs (xics, value, errp); -} -void xics_set_nr_servers (XICSState *xics,uint32_t nr_servers,const char *typename,Error **errp) {
@@ -241,9 +209,6 @@ static void xics_common_initfn(Object *obj)XICSState *xics =XICS_COMMON (obj);QLIST_INIT (&xics->ics); -object_property_add (obj,"nr_irqs" ,"int" , - xics_prop_get_nr_irqs, xics_prop_set_nr_irqs, -NULL ,NULL ,NULL );object_property_add (obj,"nr_servers" ,"int" , xics_prop_get_nr_servers, xics_prop_set_nr_servers,NULL ,NULL ,NULL );
@@ -737,6 +702,16 @@ static void ics_simple_initfn(Object *obj)static void ics_simple_realize (DeviceState *dev,Error **errp) {ICSState *ics =ICS_SIMPLE (dev); +Object *obj; +Error *err =NULL ; + + obj =object_property_get_link (OBJECT (dev),"xics" , &err); +if (!obj) { +error_setg (errp,"%s: required link 'xics' not found: %s" , + __func__,error_get_pretty (err)); +return ; + } + ics->xics =XICS_COMMON (obj);if (!ics->nr_irqs) {error_setg (errp,"Number of interrupts needs to be greater 0" );
@@ -746,12 +721,18 @@ static void ics_simple_realize(DeviceState *dev, Error **errp) ics->qirqs =qemu_allocate_irqs (ics_simple_set_irq, ics, ics->nr_irqs); } +static Property ics_simple_properties[] = { +DEFINE_PROP_UINT32 ("nr-irqs" , ICSState, nr_irqs,0 ), +DEFINE_PROP_END_OF_LIST (), +}; +static void ics_simple_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass);ICSStateClass *isc =ICS_BASE_CLASS (klass); dc->realize = ics_simple_realize; + dc->props = ics_simple_properties; dc->vmsd = &vmstate_ics_simple; dc->reset = ics_simple_reset; isc->post_load = ics_simple_post_load;
hw/intc/xics_kvm.c +10 -34
86 lines not on this page · raw message
hw/intc/xics_spapr.c +0 -34
@@ -239,18 +239,6 @@ static void rtas_int_on(PowerPCCPU *cpu, sPAPRMachineState *spapr,rtas_st (rets,0 ,RTAS_OUT_SUCCESS ); } -static void xics_spapr_set_nr_irqs (XICSState *xics,uint32_t nr_irqs, -Error **errp) -{ -ICSState *ics =QLIST_FIRST (&xics->ics); - -/* This needs to be deprecated ... */ - xics->nr_irqs = nr_irqs; -if (ics) { - ics->nr_irqs = nr_irqs; - } -} -static void xics_spapr_set_nr_servers (XICSState *xics,uint32_t nr_servers,Error **errp) {
@@ -260,7 +248,6 @@ static void xics_spapr_set_nr_servers(XICSState *xics, uint32_t nr_servers,static void xics_spapr_realize (DeviceState *dev,Error **errp) {XICSState *xics =XICS_SPAPR (dev); -ICSState *ics;Error *error =NULL ;int i;
@@ -282,14 +269,6 @@ static void xics_spapr_realize(DeviceState *dev, Error **errp)spapr_register_hypercall (H_EOI , h_eoi);spapr_register_hypercall (H_IPOLL , h_ipoll); - QLIST_FOREACH(ics, &xics->ics, list) { -object_property_set_bool (OBJECT (ics), true,"realized" , &error); -if (error) { -error_propagate (errp, error); -return ; - } - } -for (i =0 ; i < xics->nr_servers; i++) {object_property_set_bool (OBJECT (&xics->ss[i]), true,"realized" , &error);
@@ -300,24 +279,12 @@ static void xics_spapr_realize(DeviceState *dev, Error **errp) } } -static void xics_spapr_initfn (Object *obj) -{ -XICSState *xics =XICS_SPAPR (obj); -ICSState *ics; - - ics =ICS_SIMPLE (object_new (TYPE_ICS_SIMPLE )); -object_property_add_child (obj,"ics" ,OBJECT (ics),NULL ); - ics->xics = xics; -QLIST_INSERT_HEAD (&xics->ics, ics, list); -} -static void xics_spapr_class_init (ObjectClass *oc,void *data) {DeviceClass *dc =DEVICE_CLASS (oc);XICSStateClass *xsc =XICS_SPAPR_CLASS (oc); dc->realize = xics_spapr_realize; - xsc->set_nr_irqs = xics_spapr_set_nr_irqs; xsc->set_nr_servers = xics_spapr_set_nr_servers; }
@@ -327,7 +294,6 @@ static const TypeInfo xics_spapr_info = { .instance_size = sizeof(XICSState), .class_size = sizeof(XICSStateClass), .class_init = xics_spapr_class_init, - .instance_init = xics_spapr_initfn, };#define ICS_IRQ_FREE (ics, srcno) \
hw/ppc/spapr.c +37 -16
74 lines not on this page · raw message
include/hw/ppc/xics.h +0 -2
@@ -74,7 +74,6 @@ struct XICSStateClass {DeviceClass parent_class;void (*cpu_setup)(XICSState *icp,PowerPCCPU *cpu); -void (*set_nr_irqs)(XICSState *icp,uint32_t nr_irqs,Error **errp);void (*set_nr_servers)(XICSState *icp,uint32_t nr_servers,Error **errp); };
@@ -83,7 +82,6 @@ struct XICSState {SysBusDevice parent_obj;/*< public >*/ uint32_t nr_servers; -uint32_t nr_irqs;ICPState *ss; QLIST_HEAD(, ICSState) ics; };
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v2 01/22] ppc/xics: remove set_nr_irqs() handler from XICSStateClass
Quoted 128 lines · Cédric Le Goater
Today, the ICS (Interrupt Controller Source) object is created and realized by the init and realize routines of the XICS object, but some of the parameters are only known at the machine level.
These parameters are passed from the sPAPR machine to the ICS object in a rather convoluted way using property handlers and a class handler of the XICS object. The number of irqs required to allocate the IRQ state objects in the ICS realize routine is one of them.
Let's simplify the process by creating the ICS object along with the XICS object at the machine level and link the ICS into the XICS list of ICSs at this level also. In the sPAPR machine, there is only a single ICS but that will change with the PowerNV machine.
Also, QOMify the creation of the objects and get rid of the superfluous code.
Signed-off-by Cédric Le Goater <[email protected]>---
Changes since v1:
- added a XICS link to the ICS object
hw/intc/xics.c | 51 ++++++++++++++++--------------------------------- hw/intc/xics_kvm.c | 44 ++++++++++-------------------------------- hw/intc/xics_spapr.c | 34 --------------------------------- hw/ppc/spapr.c | 53 +++++++++++++++++++++++++++++++++++---------------- include/hw/ppc/xics.h | 2 -- 5 files changed, 63 insertions(+), 121 deletions(-)hw/intc/xics.c +16
-35@@ -151,38 +151,6 @@ static void xics_common_reset(DeviceState *d) } } -static void xics_prop_get_nr_irqs (Object *obj,Visitor *v,const char *name, -void *opaque,Error **errp) -{ -XICSState *xics =XICS_COMMON (obj); -int64_t value = xics->nr_irqs; - -visit_type_int (v, name, &value, errp); -} - -static void xics_prop_set_nr_irqs (Object *obj,Visitor *v,const char *name, -void *opaque,Error **errp) -{ -XICSState *xics =XICS_COMMON (obj); -XICSStateClass *info =XICS_COMMON_GET_CLASS (xics); -Error *error =NULL ; -int64_t value; - -visit_type_int (v, name, &value, &error); -if (error) { -error_propagate (errp, error); -return ; - } -if (xics->nr_irqs) { -error_setg (errp,"Number of interrupts is already set to %u" , - xics->nr_irqs); -return ; - } - -assert (info->set_nr_irqs); - info->set_nr_irqs (xics, value, errp); -} -void xics_set_nr_servers (XICSState *xics,uint32_t nr_servers,const char *typename,Error **errp) {@@ -241,9 +209,6 @@ static void xics_common_initfn(Object *obj)XICSState *xics =XICS_COMMON (obj);QLIST_INIT (&xics->ics); -object_property_add (obj,"nr_irqs" ,"int" , - xics_prop_get_nr_irqs, xics_prop_set_nr_irqs, -NULL ,NULL ,NULL );object_property_add (obj,"nr_servers" ,"int" , xics_prop_get_nr_servers, xics_prop_set_nr_servers,NULL ,NULL ,NULL );@@ -737,6 +702,16 @@ static void ics_simple_initfn(Object *obj)static void ics_simple_realize (DeviceState *dev,Error **errp) {ICSState *ics =ICS_SIMPLE (dev); +Object *obj; +Error *err =NULL ; + + obj =object_property_get_link (OBJECT (dev),"xics" , &err); +if (!obj) { +error_setg (errp,"%s: required link 'xics' not found: %s" , + __func__,error_get_pretty (err)); +return ; + } + ics->xics =XICS_COMMON (obj);if (!ics->nr_irqs) {error_setg (errp,"Number of interrupts needs to be greater 0" );@@ -746,12 +721,18 @@ static void ics_simple_realize(DeviceState *dev, Error **errp) ics->qirqs =qemu_allocate_irqs (ics_simple_set_irq, ics, ics->nr_irqs); } +static Property ics_simple_properties[] = { +DEFINE_PROP_UINT32 ("nr-irqs" , ICSState, nr_irqs,0 ), +DEFINE_PROP_END_OF_LIST (), +}; +static void ics_simple_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass);ICSStateClass *isc =ICS_BASE_CLASS (klass); dc->realize = ics_simple_realize; + dc->props = ics_simple_properties; dc->vmsd = &vmstate_ics_simple; dc->reset = ics_simple_reset; isc->post_load = ics_simple_post_load;hw/intc/xics_kvm.c +0
-0@@ -294,6 +294,16 @@ static void ics_kvm_reset(DeviceState *dev)static void ics_kvm_realize (DeviceState *dev,Error **errp) {ICSState *ics =ICS_SIMPLE (dev);
hw/intc/xics_kvm.c static void ics_kvm_reset(DeviceState *dev) · line 306
Quoted 10 lines
hw/intc/xics_kvm.c +10
-0+Object *obj; +Error *err =NULL ; + + obj =object_property_get_link (OBJECT (dev),"xics" , &err); +if (!obj) { +error_setg (errp,"%s: required link 'xics' not found: %s" , + __func__,error_get_pretty (err)); +return ; + } + ics->xics =XICS_COMMON (obj);
Couldn't you have this logic in the base class rather than repeating it in ics simple and ics kvm?
Quoted 258 lines
hw/intc/xics_kvm.c +0
-34if (!ics->nr_irqs) {error_setg (errp,"Number of interrupts needs to be greater 0" );@@ -358,18 +368,6 @@ static void xics_kvm_cpu_setup(XICSState *xics, PowerPCCPU *cpu) ss->cap_irq_xics_enabled = true; } -static void xics_kvm_set_nr_irqs (XICSState *xics,uint32_t nr_irqs, -Error **errp) -{ -ICSState *ics =QLIST_FIRST (&xics->ics); - -/* This needs to be deprecated ... */ - xics->nr_irqs = nr_irqs; -if (ics) { - ics->nr_irqs = nr_irqs; - } -} -static void xics_kvm_set_nr_servers (XICSState *xics,uint32_t nr_servers,Error **errp) {@@ -389,7 +387,6 @@ static void xics_kvm_realize(DeviceState *dev, Error **errp) {KVMXICSState *xicskvm =XICS_SPAPR_KVM (dev);XICSState *xics =XICS_COMMON (dev); -ICSState *ics;int i, rc;Error *error =NULL ;struct kvm_create_device xics_create_device = {@@ -441,14 +438,6 @@ static void xics_kvm_realize(DeviceState *dev, Error **errp) xicskvm->kernel_xics_fd = xics_create_device.fd; - QLIST_FOREACH(ics, &xics->ics, list) { -object_property_set_bool (OBJECT (ics), true,"realized" , &error); -if (error) { -error_propagate (errp, error); - goto fail; - } - } -assert (xics->nr_servers);for (i =0 ; i < xics->nr_servers; i++) { object_property_set_bool(OBJECT(&xics->ss[i]), true, "realized",@@ -472,17 +461,6 @@ fail:kvmppc_define_rtas_kernel_token (0 ,"ibm,int-off" ); } -static void xics_kvm_initfn (Object *obj) -{ -XICSState *xics =XICS_COMMON (obj); -ICSState *ics; - - ics =ICS_SIMPLE (object_new (TYPE_ICS_KVM )); -object_property_add_child (obj,"ics" ,OBJECT (ics),NULL ); - ics->xics = xics; -QLIST_INSERT_HEAD (&xics->ics, ics, list); -} -static void xics_kvm_class_init (ObjectClass *oc,void *data) {DeviceClass *dc =DEVICE_CLASS (oc);@@ -490,7 +468,6 @@ static void xics_kvm_class_init(ObjectClass *oc, void *data) dc->realize = xics_kvm_realize; xsc->cpu_setup = xics_kvm_cpu_setup; - xsc->set_nr_irqs = xics_kvm_set_nr_irqs; xsc->set_nr_servers = xics_kvm_set_nr_servers; }@@ -499,7 +476,6 @@ static const TypeInfo xics_spapr_kvm_info = { .parent = TYPE_XICS_COMMON, .instance_size = sizeof(KVMXICSState), .class_init = xics_kvm_class_init, - .instance_init = xics_kvm_initfn, };static void xics_kvm_register_types (void )hw/intc/xics_spapr.c +0
-34@@ -239,18 +239,6 @@ static void rtas_int_on(PowerPCCPU *cpu, sPAPRMachineState *spapr,rtas_st (rets,0 ,RTAS_OUT_SUCCESS ); } -static void xics_spapr_set_nr_irqs (XICSState *xics,uint32_t nr_irqs, -Error **errp) -{ -ICSState *ics =QLIST_FIRST (&xics->ics); - -/* This needs to be deprecated ... */ - xics->nr_irqs = nr_irqs; -if (ics) { - ics->nr_irqs = nr_irqs; - } -} -static void xics_spapr_set_nr_servers (XICSState *xics,uint32_t nr_servers,Error **errp) {@@ -260,7 +248,6 @@ static void xics_spapr_set_nr_servers(XICSState *xics, uint32_t nr_servers,static void xics_spapr_realize (DeviceState *dev,Error **errp) {XICSState *xics =XICS_SPAPR (dev); -ICSState *ics;Error *error =NULL ;int i;@@ -282,14 +269,6 @@ static void xics_spapr_realize(DeviceState *dev, Error **errp)spapr_register_hypercall (H_EOI , h_eoi);spapr_register_hypercall (H_IPOLL , h_ipoll); - QLIST_FOREACH(ics, &xics->ics, list) { -object_property_set_bool (OBJECT (ics), true,"realized" , &error); -if (error) { -error_propagate (errp, error); -return ; - } - } -for (i =0 ; i < xics->nr_servers; i++) {object_property_set_bool (OBJECT (&xics->ss[i]), true,"realized" , &error);@@ -300,24 +279,12 @@ static void xics_spapr_realize(DeviceState *dev, Error **errp) } } -static void xics_spapr_initfn (Object *obj) -{ -XICSState *xics =XICS_SPAPR (obj); -ICSState *ics; - - ics =ICS_SIMPLE (object_new (TYPE_ICS_SIMPLE )); -object_property_add_child (obj,"ics" ,OBJECT (ics),NULL ); - ics->xics = xics; -QLIST_INSERT_HEAD (&xics->ics, ics, list); -} -static void xics_spapr_class_init (ObjectClass *oc,void *data) {DeviceClass *dc =DEVICE_CLASS (oc);XICSStateClass *xsc =XICS_SPAPR_CLASS (oc); dc->realize = xics_spapr_realize; - xsc->set_nr_irqs = xics_spapr_set_nr_irqs; xsc->set_nr_servers = xics_spapr_set_nr_servers; }@@ -327,7 +294,6 @@ static const TypeInfo xics_spapr_info = { .instance_size = sizeof(XICSState), .class_size = sizeof(XICSStateClass), .class_init = xics_spapr_class_init, - .instance_init = xics_spapr_initfn, };#define ICS_IRQ_FREE (ics, srcno) \hw/ppc/spapr.c +37
-16@@ -95,22 +95,42 @@#define HTAB_SIZE (spapr) (1ULL << ((spapr)->htab_shift)) -static XICSState *try_create_xics (const char *type,int nr_servers, -int nr_irqs,Error **errp) -{ -Error *err =NULL ; -DeviceState *dev; +static XICSState *try_create_xics (const char *type,const char *type_ics, +int nr_servers,int nr_irqs,Error **errp) +{ +Error *err =NULL , *local_err =NULL ; +XICSState *xics; +ICSState *ics =NULL ; + + xics =XICS_COMMON (object_new (type)); +qdev_set_parent_bus (DEVICE (xics),sysbus_get_default ()); +object_property_set_int (OBJECT (xics), nr_servers,"nr_servers" , &err); +object_property_set_bool (OBJECT (xics), true,"realized" , &local_err); +error_propagate (&err, local_err); +if (err) { + goto error; + } - dev =DEVICE (object_new (type)); -qdev_prop_set_uint32 (dev,"nr_servers" , nr_servers); -qdev_prop_set_uint32 (dev,"nr_irqs" , nr_irqs); -object_property_set_bool (OBJECT (dev), true,"realized" , &err); + ics =ICS_SIMPLE (object_new (type_ics)); +object_property_add_child (OBJECT (xics),"ics" ,OBJECT (ics),NULL ); +object_property_set_int (OBJECT (ics), nr_irqs,"nr-irqs" , &err); +object_property_add_const_link (OBJECT (ics),"xics" ,OBJECT (xics),NULL ); +object_property_set_bool (OBJECT (ics), true,"realized" , &local_err); +error_propagate (&err, local_err);if (err) { -error_propagate (errp, err); -object_unparent (OBJECT (dev)); -return NULL ; + goto error; } -return XICS_COMMON (dev); +QLIST_INSERT_HEAD (&xics->ics, ics, list); + +return xics; + +error: +error_propagate (errp, err); +if (ics) { +object_unparent (OBJECT (ics)); + } +object_unparent (OBJECT (xics)); +return NULL ; } static XICSState *xics_system_init(MachineState *machine,@@ -122,8 +142,8 @@ static XICSState *xics_system_init(MachineState *machine,Error *err =NULL ;if (machine_kernel_irqchip_allowed (machine)) { - xics =try_create_xics (TYPE_XICS_SPAPR_KVM , nr_servers, nr_irqs, - &err); + xics =try_create_xics (TYPE_XICS_SPAPR_KVM ,TYPE_ICS_KVM , + nr_servers, nr_irqs, &err); }if (machine_kernel_irqchip_required (machine) && !xics) { error_reportf_err(err,@@ -134,7 +154,8 @@ static XICSState *xics_system_init(MachineState *machine, }if (!xics) { - xics =try_create_xics (TYPE_XICS_SPAPR , nr_servers, nr_irqs, errp); + xics =try_create_xics (TYPE_XICS_SPAPR ,TYPE_ICS_SIMPLE , nr_servers, + nr_irqs, errp); }return xics;include/hw/ppc/xics.h +0
-2@@ -74,7 +74,6 @@ struct XICSStateClass {DeviceClass parent_class;void (*cpu_setup)(XICSState *icp,PowerPCCPU *cpu); -void (*set_nr_irqs)(XICSState *icp,uint32_t nr_irqs,Error **errp);void (*set_nr_servers)(XICSState *icp,uint32_t nr_servers,Error **errp); };@@ -83,7 +82,6 @@ struct XICSState {SysBusDevice parent_obj;/*< public >*/ uint32_t nr_servers; -uint32_t nr_irqs;ICPState *ss; QLIST_HEAD(, ICSState) ics; };
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [Qemu-devel] [PATCH v2 01/22] ppc/xics: remove set_nr_irqs() handler from XICSStateClass
Quoted 134 lines · David Gibson
Quoted 133 lines · Cédric Le Goater
Today, the ICS (Interrupt Controller Source) object is created and realized by the init and realize routines of the XICS object, but some of the parameters are only known at the machine level.
These parameters are passed from the sPAPR machine to the ICS object in a rather convoluted way using property handlers and a class handler of the XICS object. The number of irqs required to allocate the IRQ state objects in the ICS realize routine is one of them.
Let's simplify the process by creating the ICS object along with the XICS object at the machine level and link the ICS into the XICS list of ICSs at this level also. In the sPAPR machine, there is only a single ICS but that will change with the PowerNV machine.
Also, QOMify the creation of the objects and get rid of the superfluous code.
Signed-off-by Cédric Le Goater <[email protected]>---
Changes since v1:
- added a XICS link to the ICS object
hw/intc/xics.c | 51 ++++++++++++++++--------------------------------- hw/intc/xics_kvm.c | 44 ++++++++++-------------------------------- hw/intc/xics_spapr.c | 34 --------------------------------- hw/ppc/spapr.c | 53 +++++++++++++++++++++++++++++++++++---------------- include/hw/ppc/xics.h | 2 -- 5 files changed, 63 insertions(+), 121 deletions(-)hw/intc/xics.c +16
-35@@ -151,38 +151,6 @@ static void xics_common_reset(DeviceState *d) } } -static void xics_prop_get_nr_irqs (Object *obj,Visitor *v,const char *name, -void *opaque,Error **errp) -{ -XICSState *xics =XICS_COMMON (obj); -int64_t value = xics->nr_irqs; - -visit_type_int (v, name, &value, errp); -} - -static void xics_prop_set_nr_irqs (Object *obj,Visitor *v,const char *name, -void *opaque,Error **errp) -{ -XICSState *xics =XICS_COMMON (obj); -XICSStateClass *info =XICS_COMMON_GET_CLASS (xics); -Error *error =NULL ; -int64_t value; - -visit_type_int (v, name, &value, &error); -if (error) { -error_propagate (errp, error); -return ; - } -if (xics->nr_irqs) { -error_setg (errp,"Number of interrupts is already set to %u" , - xics->nr_irqs); -return ; - } - -assert (info->set_nr_irqs); - info->set_nr_irqs (xics, value, errp); -} -void xics_set_nr_servers (XICSState *xics,uint32_t nr_servers,const char *typename,Error **errp) {@@ -241,9 +209,6 @@ static void xics_common_initfn(Object *obj)XICSState *xics =XICS_COMMON (obj);QLIST_INIT (&xics->ics); -object_property_add (obj,"nr_irqs" ,"int" , - xics_prop_get_nr_irqs, xics_prop_set_nr_irqs, -NULL ,NULL ,NULL );object_property_add (obj,"nr_servers" ,"int" , xics_prop_get_nr_servers, xics_prop_set_nr_servers,NULL ,NULL ,NULL );@@ -737,6 +702,16 @@ static void ics_simple_initfn(Object *obj)static void ics_simple_realize (DeviceState *dev,Error **errp) {ICSState *ics =ICS_SIMPLE (dev); +Object *obj; +Error *err =NULL ; + + obj =object_property_get_link (OBJECT (dev),"xics" , &err); +if (!obj) { +error_setg (errp,"%s: required link 'xics' not found: %s" , + __func__,error_get_pretty (err)); +return ; + } + ics->xics =XICS_COMMON (obj);if (!ics->nr_irqs) {error_setg (errp,"Number of interrupts needs to be greater 0" );@@ -746,12 +721,18 @@ static void ics_simple_realize(DeviceState *dev, Error **errp) ics->qirqs =qemu_allocate_irqs (ics_simple_set_irq, ics, ics->nr_irqs); } +static Property ics_simple_properties[] = { +DEFINE_PROP_UINT32 ("nr-irqs" , ICSState, nr_irqs,0 ), +DEFINE_PROP_END_OF_LIST (), +}; +static void ics_simple_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass);ICSStateClass *isc =ICS_BASE_CLASS (klass); dc->realize = ics_simple_realize; + dc->props = ics_simple_properties; dc->vmsd = &vmstate_ics_simple; dc->reset = ics_simple_reset; isc->post_load = ics_simple_post_load;hw/intc/xics_kvm.c +5
-0@@ -294,6 +294,16 @@ static void ics_kvm_reset(DeviceState *dev)static void ics_kvm_realize (DeviceState *dev,Error **errp) {ICSState *ics =ICS_SIMPLE (dev); +Object *obj; +Error *err =NULL ; + + obj =object_property_get_link (OBJECT (dev),"xics" , &err); +if (!obj) {
Quoted 8 lines
hw/intc/xics_kvm.c static void ics_kvm_reset(DeviceState *dev) · line 306
Quoted 5 lines
hw/intc/xics_kvm.c +5
-0+error_setg (errp,"%s: required link 'xics' not found: %s" , + __func__,error_get_pretty (err)); +return ; + } + ics->xics =XICS_COMMON (obj);Couldn't you have this logic in the base class rather than repeating it in ics simple and ics kvm?
Yes we could. But, as I am getting rid of the backlinks at the end of the patchset, the redundancy is not much of a problem.
Thanks,
C.
Quoted 259 lines
Quoted 258 lines
hw/intc/xics_kvm.c +0
-34if (!ics->nr_irqs) {error_setg (errp,"Number of interrupts needs to be greater 0" );@@ -358,18 +368,6 @@ static void xics_kvm_cpu_setup(XICSState *xics, PowerPCCPU *cpu) ss->cap_irq_xics_enabled = true; } -static void xics_kvm_set_nr_irqs (XICSState *xics,uint32_t nr_irqs, -Error **errp) -{ -ICSState *ics =QLIST_FIRST (&xics->ics); - -/* This needs to be deprecated ... */ - xics->nr_irqs = nr_irqs; -if (ics) { - ics->nr_irqs = nr_irqs; - } -} -static void xics_kvm_set_nr_servers (XICSState *xics,uint32_t nr_servers,Error **errp) {@@ -389,7 +387,6 @@ static void xics_kvm_realize(DeviceState *dev, Error **errp) {KVMXICSState *xicskvm =XICS_SPAPR_KVM (dev);XICSState *xics =XICS_COMMON (dev); -ICSState *ics;int i, rc;Error *error =NULL ;struct kvm_create_device xics_create_device = {@@ -441,14 +438,6 @@ static void xics_kvm_realize(DeviceState *dev, Error **errp) xicskvm->kernel_xics_fd = xics_create_device.fd; - QLIST_FOREACH(ics, &xics->ics, list) { -object_property_set_bool (OBJECT (ics), true,"realized" , &error); -if (error) { -error_propagate (errp, error); - goto fail; - } - } -assert (xics->nr_servers);for (i =0 ; i < xics->nr_servers; i++) { object_property_set_bool(OBJECT(&xics->ss[i]), true, "realized",@@ -472,17 +461,6 @@ fail:kvmppc_define_rtas_kernel_token (0 ,"ibm,int-off" ); } -static void xics_kvm_initfn (Object *obj) -{ -XICSState *xics =XICS_COMMON (obj); -ICSState *ics; - - ics =ICS_SIMPLE (object_new (TYPE_ICS_KVM )); -object_property_add_child (obj,"ics" ,OBJECT (ics),NULL ); - ics->xics = xics; -QLIST_INSERT_HEAD (&xics->ics, ics, list); -} -static void xics_kvm_class_init (ObjectClass *oc,void *data) {DeviceClass *dc =DEVICE_CLASS (oc);@@ -490,7 +468,6 @@ static void xics_kvm_class_init(ObjectClass *oc, void *data) dc->realize = xics_kvm_realize; xsc->cpu_setup = xics_kvm_cpu_setup; - xsc->set_nr_irqs = xics_kvm_set_nr_irqs; xsc->set_nr_servers = xics_kvm_set_nr_servers; }@@ -499,7 +476,6 @@ static const TypeInfo xics_spapr_kvm_info = { .parent = TYPE_XICS_COMMON, .instance_size = sizeof(KVMXICSState), .class_init = xics_kvm_class_init, - .instance_init = xics_kvm_initfn, };static void xics_kvm_register_types (void )hw/intc/xics_spapr.c +0
-34@@ -239,18 +239,6 @@ static void rtas_int_on(PowerPCCPU *cpu, sPAPRMachineState *spapr,rtas_st (rets,0 ,RTAS_OUT_SUCCESS ); } -static void xics_spapr_set_nr_irqs (XICSState *xics,uint32_t nr_irqs, -Error **errp) -{ -ICSState *ics =QLIST_FIRST (&xics->ics); - -/* This needs to be deprecated ... */ - xics->nr_irqs = nr_irqs; -if (ics) { - ics->nr_irqs = nr_irqs; - } -} -static void xics_spapr_set_nr_servers (XICSState *xics,uint32_t nr_servers,Error **errp) {@@ -260,7 +248,6 @@ static void xics_spapr_set_nr_servers(XICSState *xics, uint32_t nr_servers,static void xics_spapr_realize (DeviceState *dev,Error **errp) {XICSState *xics =XICS_SPAPR (dev); -ICSState *ics;Error *error =NULL ;int i;@@ -282,14 +269,6 @@ static void xics_spapr_realize(DeviceState *dev, Error **errp)spapr_register_hypercall (H_EOI , h_eoi);spapr_register_hypercall (H_IPOLL , h_ipoll); - QLIST_FOREACH(ics, &xics->ics, list) { -object_property_set_bool (OBJECT (ics), true,"realized" , &error); -if (error) { -error_propagate (errp, error); -return ; - } - } -for (i =0 ; i < xics->nr_servers; i++) {object_property_set_bool (OBJECT (&xics->ss[i]), true,"realized" , &error);@@ -300,24 +279,12 @@ static void xics_spapr_realize(DeviceState *dev, Error **errp) } } -static void xics_spapr_initfn (Object *obj) -{ -XICSState *xics =XICS_SPAPR (obj); -ICSState *ics; - - ics =ICS_SIMPLE (object_new (TYPE_ICS_SIMPLE )); -object_property_add_child (obj,"ics" ,OBJECT (ics),NULL ); - ics->xics = xics; -QLIST_INSERT_HEAD (&xics->ics, ics, list); -} -static void xics_spapr_class_init (ObjectClass *oc,void *data) {DeviceClass *dc =DEVICE_CLASS (oc);XICSStateClass *xsc =XICS_SPAPR_CLASS (oc); dc->realize = xics_spapr_realize; - xsc->set_nr_irqs = xics_spapr_set_nr_irqs; xsc->set_nr_servers = xics_spapr_set_nr_servers; }@@ -327,7 +294,6 @@ static const TypeInfo xics_spapr_info = { .instance_size = sizeof(XICSState), .class_size = sizeof(XICSStateClass), .class_init = xics_spapr_class_init, - .instance_init = xics_spapr_initfn, };#define ICS_IRQ_FREE (ics, srcno) \hw/ppc/spapr.c +37
-16@@ -95,22 +95,42 @@#define HTAB_SIZE (spapr) (1ULL << ((spapr)->htab_shift)) -static XICSState *try_create_xics (const char *type,int nr_servers, -int nr_irqs,Error **errp) -{ -Error *err =NULL ; -DeviceState *dev; +static XICSState *try_create_xics (const char *type,const char *type_ics, +int nr_servers,int nr_irqs,Error **errp) +{ +Error *err =NULL , *local_err =NULL ; +XICSState *xics; +ICSState *ics =NULL ; + + xics =XICS_COMMON (object_new (type)); +qdev_set_parent_bus (DEVICE (xics),sysbus_get_default ()); +object_property_set_int (OBJECT (xics), nr_servers,"nr_servers" , &err); +object_property_set_bool (OBJECT (xics), true,"realized" , &local_err); +error_propagate (&err, local_err); +if (err) { + goto error; + } - dev =DEVICE (object_new (type)); -qdev_prop_set_uint32 (dev,"nr_servers" , nr_servers); -qdev_prop_set_uint32 (dev,"nr_irqs" , nr_irqs); -object_property_set_bool (OBJECT (dev), true,"realized" , &err); + ics =ICS_SIMPLE (object_new (type_ics)); +object_property_add_child (OBJECT (xics),"ics" ,OBJECT (ics),NULL ); +object_property_set_int (OBJECT (ics), nr_irqs,"nr-irqs" , &err); +object_property_add_const_link (OBJECT (ics),"xics" ,OBJECT (xics),NULL ); +object_property_set_bool (OBJECT (ics), true,"realized" , &local_err); +error_propagate (&err, local_err);if (err) { -error_propagate (errp, err); -object_unparent (OBJECT (dev)); -return NULL ; + goto error; } -return XICS_COMMON (dev); +QLIST_INSERT_HEAD (&xics->ics, ics, list); + +return xics; + +error: +error_propagate (errp, err); +if (ics) { +object_unparent (OBJECT (ics)); + } +object_unparent (OBJECT (xics)); +return NULL ; } static XICSState *xics_system_init(MachineState *machine,@@ -122,8 +142,8 @@ static XICSState *xics_system_init(MachineState *machine,Error *err =NULL ;if (machine_kernel_irqchip_allowed (machine)) { - xics =try_create_xics (TYPE_XICS_SPAPR_KVM , nr_servers, nr_irqs, - &err); + xics =try_create_xics (TYPE_XICS_SPAPR_KVM ,TYPE_ICS_KVM , + nr_servers, nr_irqs, &err); }if (machine_kernel_irqchip_required (machine) && !xics) { error_reportf_err(err,@@ -134,7 +154,8 @@ static XICSState *xics_system_init(MachineState *machine, }if (!xics) { - xics =try_create_xics (TYPE_XICS_SPAPR , nr_servers, nr_irqs, errp); + xics =try_create_xics (TYPE_XICS_SPAPR ,TYPE_ICS_SIMPLE , nr_servers, + nr_irqs, errp); }return xics;include/hw/ppc/xics.h +0
-2@@ -74,7 +74,6 @@ struct XICSStateClass {DeviceClass parent_class;void (*cpu_setup)(XICSState *icp,PowerPCCPU *cpu); -void (*set_nr_irqs)(XICSState *icp,uint32_t nr_irqs,Error **errp);void (*set_nr_servers)(XICSState *icp,uint32_t nr_servers,Error **errp); };@@ -83,7 +82,6 @@ struct XICSState {SysBusDevice parent_obj;/*< public >*/ uint32_t nr_servers; -uint32_t nr_irqs;ICPState *ss; QLIST_HEAD(, ICSState) ics; };
PATCH v2 2/22 ppc/xics: remove set_nr_servers() handler from XICSStateClass
In reply to Cédric Le GoaterToday, the ICP (Interrupt Controller Presenter) objects are created by the 'nr_servers' property handler of the XICS object and a class handler. They are realized in the XICS object realize routine.
Let's simplify the process by creating the ICP objects along with the XICS object at the machine level.
---
Changes since v1:
- added a XICS link to the ICS object
- removed xics_set_nr_servers() routine
- removed set_nr_servers() class handler
hw/intc/xics.c | 74 +++++++++++++-------------------------------------- hw/intc/xics_kvm.c | 21 +-------------- hw/intc/xics_spapr.c | 26 ------------------ hw/ppc/spapr.c | 30 ++++++++++++++++----- include/hw/ppc/xics.h | 3 --- 5 files changed, 42 insertions(+), 112 deletions(-)
hw/intc/xics.c +18 -56
@@ -151,67 +151,11 @@ static void xics_common_reset(DeviceState *d) } } -void xics_set_nr_servers (XICSState *xics,uint32_t nr_servers, -const char *typename,Error **errp) -{ -int i; - - xics->nr_servers = nr_servers; - - xics->ss =g_malloc0 (xics->nr_servers *sizeof (ICPState)); -for (i =0 ; i < xics->nr_servers; i++) { -char name[32 ]; -ICPState *icp = &xics->ss[i]; - -object_initialize (icp,sizeof (*icp), typename); -snprintf (name,sizeof (name),"icp[%d]" , i); -object_property_add_child (OBJECT (xics), name,OBJECT (icp), errp); - icp->xics = xics; - } -} - -static void xics_prop_get_nr_servers (Object *obj,Visitor *v, -const char *name,void *opaque, -Error **errp) -{ -XICSState *xics =XICS_COMMON (obj); -int64_t value = xics->nr_servers; - -visit_type_int (v, name, &value, errp); -} - -static void xics_prop_set_nr_servers (Object *obj,Visitor *v, -const char *name,void *opaque, -Error **errp) -{ -XICSState *xics =XICS_COMMON (obj); -XICSStateClass *xsc =XICS_COMMON_GET_CLASS (xics); -Error *error =NULL ; -int64_t value; - -visit_type_int (v, name, &value, &error); -if (error) { -error_propagate (errp, error); -return ; - } -if (xics->nr_servers) { -error_setg (errp,"Number of servers is already set to %u" , - xics->nr_servers); -return ; - } - -assert (xsc->set_nr_servers); - xsc->set_nr_servers (xics, value, errp); -} -static void xics_common_initfn (Object *obj) {XICSState *xics =XICS_COMMON (obj);QLIST_INIT (&xics->ics); -object_property_add (obj,"nr_servers" ,"int" , - xics_prop_get_nr_servers, xics_prop_set_nr_servers, -NULL ,NULL ,NULL ); }static void xics_common_class_init (ObjectClass *oc,void *data)
@@ -450,12 +394,30 @@ static void icp_reset(DeviceState *dev)qemu_set_irq (icp->output,0 ); } +static void icp_realize (DeviceState *dev,Error **errp) +{ +ICPState *icp =ICP (dev); +Object *obj; +Error *err =NULL ; + + obj =object_property_get_link (OBJECT (dev),"xics" , &err); +if (!obj) { +error_setg (errp,"%s: required link 'xics' not found: %s" , + __func__,error_get_pretty (err)); +return ; + } + + icp->xics =XICS_COMMON (obj); +} + +static void icp_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass); dc->reset = icp_reset; dc->vmsd = &vmstate_icp_server; + dc->realize = icp_realize; }static const TypeInfo icp_info = {
hw/intc/xics_kvm.c +1 -20
@@ -368,12 +368,6 @@ static void xics_kvm_cpu_setup(XICSState *xics, PowerPCCPU *cpu) ss->cap_irq_xics_enabled = true; } -static void xics_kvm_set_nr_servers (XICSState *xics,uint32_t nr_servers, -Error **errp) -{ -xics_set_nr_servers (xics, nr_servers,TYPE_KVM_ICP , errp); -} - static void rtas_dummy(PowerPCCPU *cpu, sPAPRMachineState *spapr, uint32_t token, uint32_t nargs, target_ulong args,
@@ -386,9 +380,7 @@ static void rtas_dummy(PowerPCCPU *cpu, sPAPRMachineState *spapr,static void xics_kvm_realize (DeviceState *dev,Error **errp) {KVMXICSState *xicskvm =XICS_SPAPR_KVM (dev); -XICSState *xics =XICS_COMMON (dev); -int i, rc; -Error *error =NULL ; +int rc;struct kvm_create_device xics_create_device = { .type =KVM_DEV_TYPE_XICS , .flags =0 ,
@@ -438,16 +430,6 @@ static void xics_kvm_realize(DeviceState *dev, Error **errp) xicskvm->kernel_xics_fd = xics_create_device.fd; -assert (xics->nr_servers); -for (i =0 ; i < xics->nr_servers; i++) { -object_property_set_bool (OBJECT (&xics->ss[i]), true,"realized" , - &error); -if (error) { -error_propagate (errp, error); - goto fail; - } - } - kvm_kernel_irqchip = true; kvm_msi_via_irqfd_allowed = true; kvm_gsi_direct_mapping = true;
@@ -468,7 +450,6 @@ static void xics_kvm_class_init(ObjectClass *oc, void *data) dc->realize = xics_kvm_realize; xsc->cpu_setup = xics_kvm_cpu_setup; - xsc->set_nr_servers = xics_kvm_set_nr_servers; }static const TypeInfo xics_spapr_kvm_info = {
hw/intc/xics_spapr.c +0 -26
@@ -239,23 +239,8 @@ static void rtas_int_on(PowerPCCPU *cpu, sPAPRMachineState *spapr,rtas_st (rets,0 ,RTAS_OUT_SUCCESS ); } -static void xics_spapr_set_nr_servers (XICSState *xics,uint32_t nr_servers, -Error **errp) -{ -xics_set_nr_servers (xics, nr_servers,TYPE_ICP , errp); -} -static void xics_spapr_realize (DeviceState *dev,Error **errp) { -XICSState *xics =XICS_SPAPR (dev); -Error *error =NULL ; -int i; - -if (!xics->nr_servers) { -error_setg (errp,"Number of servers needs to be greater 0" ); -return ; - } -/* Registration of global state belongs into realize */ spapr_rtas_register (RTAS_IBM_SET_XIVE ,"ibm,set-xive" , rtas_set_xive);spapr_rtas_register (RTAS_IBM_GET_XIVE ,"ibm,get-xive" , rtas_get_xive);
@@ -268,24 +253,13 @@ static void xics_spapr_realize(DeviceState *dev, Error **errp)spapr_register_hypercall (H_XIRR_X , h_xirr_x);spapr_register_hypercall (H_EOI , h_eoi);spapr_register_hypercall (H_IPOLL , h_ipoll); - -for (i =0 ; i < xics->nr_servers; i++) { -object_property_set_bool (OBJECT (&xics->ss[i]), true,"realized" , - &error); -if (error) { -error_propagate (errp, error); -return ; - } - } }static void xics_spapr_class_init (ObjectClass *oc,void *data) {DeviceClass *dc =DEVICE_CLASS (oc); -XICSStateClass *xsc =XICS_SPAPR_CLASS (oc); dc->realize = xics_spapr_realize; - xsc->set_nr_servers = xics_spapr_set_nr_servers; }static const TypeInfo xics_spapr_info = {
hw/ppc/spapr.c +23 -7
@@ -96,17 +96,17 @@#define HTAB_SIZE (spapr) (1ULL << ((spapr)->htab_shift))static XICSState *try_create_xics (const char *type,const char *type_ics, -int nr_servers,int nr_irqs,Error **errp) +const char *type_icp,int nr_servers, +int nr_irqs,Error **errp) {Error *err =NULL , *local_err =NULL ;XICSState *xics;ICSState *ics =NULL ; +int i; xics =XICS_COMMON (object_new (type));qdev_set_parent_bus (DEVICE (xics),sysbus_get_default ()); -object_property_set_int (OBJECT (xics), nr_servers,"nr_servers" , &err); -object_property_set_bool (OBJECT (xics), true,"realized" , &local_err); -error_propagate (&err, local_err); +object_property_set_bool (OBJECT (xics), true,"realized" , &err);if (err) { goto error; }
@@ -122,6 +122,22 @@ static XICSState *try_create_xics(const char *type, const char *type_ics, }QLIST_INSERT_HEAD (&xics->ics, ics, list); + xics->ss =g_malloc0 (nr_servers *sizeof (ICPState)); + xics->nr_servers = nr_servers; + +for (i =0 ; i < nr_servers; i++) { +ICPState *icp = &xics->ss[i]; + +object_initialize (icp,sizeof (*icp), type_icp); +object_property_add_child (OBJECT (xics),"icp[*]" ,OBJECT (icp),NULL ); +object_property_add_const_link (OBJECT (icp),"xics" ,OBJECT (xics),NULL ); +object_property_set_bool (OBJECT (icp), true,"realized" , &err); +if (err) { + goto error; + } +object_unref (OBJECT (icp)); + } +return xics; error:
@@ -143,7 +159,7 @@ static XICSState *xics_system_init(MachineState *machine,if (machine_kernel_irqchip_allowed (machine)) { xics =try_create_xics (TYPE_XICS_SPAPR_KVM ,TYPE_ICS_KVM , - nr_servers, nr_irqs, &err); +TYPE_KVM_ICP , nr_servers, nr_irqs, &err); }if (machine_kernel_irqchip_required (machine) && !xics) { error_reportf_err(err,
@@ -154,8 +170,8 @@ static XICSState *xics_system_init(MachineState *machine, }if (!xics) { - xics =try_create_xics (TYPE_XICS_SPAPR ,TYPE_ICS_SIMPLE , nr_servers, - nr_irqs, errp); + xics =try_create_xics (TYPE_XICS_SPAPR ,TYPE_ICS_SIMPLE ,TYPE_ICP , + nr_servers, nr_irqs, errp); }return xics;
include/hw/ppc/xics.h +0 -3
@@ -74,7 +74,6 @@ struct XICSStateClass {DeviceClass parent_class;void (*cpu_setup)(XICSState *icp,PowerPCCPU *cpu); -void (*set_nr_servers)(XICSState *icp,uint32_t nr_servers,Error **errp); };struct XICSState {
@@ -189,8 +188,6 @@ void spapr_dt_xics(XICSState *xics, void *fdt, uint32_t phandle);void xics_cpu_setup (XICSState *icp,PowerPCCPU *cpu);void xics_cpu_destroy (XICSState *icp,PowerPCCPU *cpu); -void xics_set_nr_servers (XICSState *xics,uint32_t nr_servers, -const char *typename,Error **errp);/* Internal XICS interfaces */ int xics_get_cpu_index_by_dt_id (int cpu_dt_id);
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v2 02/22] ppc/xics: remove set_nr_servers() handler from XICSStateClass
Quoted 8 lines · Cédric Le Goater
Today, the ICP (Interrupt Controller Presenter) objects are created by the '
nr_servers' property handler of the XICS object and a class handler. They are realized in the XICS object realize routine.Let's simplify the process by creating the ICP objects along with the XICS object at the machine level.
Signed-off-by Cédric Le Goater <[email protected]>
Quoted 314 lines
---
Changes since v1:
- added a XICS link to the ICS object
- removedxics_set_nr_servers()routine
- removedset_nr_servers()class handlerhw/intc/xics.c | 74 +++++++++++++-------------------------------------- hw/intc/xics_kvm.c | 21 +-------------- hw/intc/xics_spapr.c | 26 ------------------ hw/ppc/spapr.c | 30 ++++++++++++++++----- include/hw/ppc/xics.h | 3 --- 5 files changed, 42 insertions(+), 112 deletions(-)hw/intc/xics.c +18
-56@@ -151,67 +151,11 @@ static void xics_common_reset(DeviceState *d) } } -void xics_set_nr_servers (XICSState *xics,uint32_t nr_servers, -const char *typename,Error **errp) -{ -int i; - - xics->nr_servers = nr_servers; - - xics->ss =g_malloc0 (xics->nr_servers *sizeof (ICPState)); -for (i =0 ; i < xics->nr_servers; i++) { -char name[32 ]; -ICPState *icp = &xics->ss[i]; - -object_initialize (icp,sizeof (*icp), typename); -snprintf (name,sizeof (name),"icp[%d]" , i); -object_property_add_child (OBJECT (xics), name,OBJECT (icp), errp); - icp->xics = xics; - } -} - -static void xics_prop_get_nr_servers (Object *obj,Visitor *v, -const char *name,void *opaque, -Error **errp) -{ -XICSState *xics =XICS_COMMON (obj); -int64_t value = xics->nr_servers; - -visit_type_int (v, name, &value, errp); -} - -static void xics_prop_set_nr_servers (Object *obj,Visitor *v, -const char *name,void *opaque, -Error **errp) -{ -XICSState *xics =XICS_COMMON (obj); -XICSStateClass *xsc =XICS_COMMON_GET_CLASS (xics); -Error *error =NULL ; -int64_t value; - -visit_type_int (v, name, &value, &error); -if (error) { -error_propagate (errp, error); -return ; - } -if (xics->nr_servers) { -error_setg (errp,"Number of servers is already set to %u" , - xics->nr_servers); -return ; - } - -assert (xsc->set_nr_servers); - xsc->set_nr_servers (xics, value, errp); -} -static void xics_common_initfn (Object *obj) {XICSState *xics =XICS_COMMON (obj);QLIST_INIT (&xics->ics); -object_property_add (obj,"nr_servers" ,"int" , - xics_prop_get_nr_servers, xics_prop_set_nr_servers, -NULL ,NULL ,NULL ); }static void xics_common_class_init (ObjectClass *oc,void *data)@@ -450,12 +394,30 @@ static void icp_reset(DeviceState *dev)qemu_set_irq (icp->output,0 ); } +static void icp_realize (DeviceState *dev,Error **errp) +{ +ICPState *icp =ICP (dev); +Object *obj; +Error *err =NULL ; + + obj =object_property_get_link (OBJECT (dev),"xics" , &err); +if (!obj) { +error_setg (errp,"%s: required link 'xics' not found: %s" , + __func__,error_get_pretty (err)); +return ; + } + + icp->xics =XICS_COMMON (obj); +} + +static void icp_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass); dc->reset = icp_reset; dc->vmsd = &vmstate_icp_server; + dc->realize = icp_realize; }static const TypeInfo icp_info = {hw/intc/xics_kvm.c +1
-20@@ -368,12 +368,6 @@ static void xics_kvm_cpu_setup(XICSState *xics, PowerPCCPU *cpu) ss->cap_irq_xics_enabled = true; } -static void xics_kvm_set_nr_servers (XICSState *xics,uint32_t nr_servers, -Error **errp) -{ -xics_set_nr_servers (xics, nr_servers,TYPE_KVM_ICP , errp); -} - static void rtas_dummy(PowerPCCPU *cpu, sPAPRMachineState *spapr, uint32_t token, uint32_t nargs, target_ulong args,@@ -386,9 +380,7 @@ static void rtas_dummy(PowerPCCPU *cpu, sPAPRMachineState *spapr,static void xics_kvm_realize (DeviceState *dev,Error **errp) {KVMXICSState *xicskvm =XICS_SPAPR_KVM (dev); -XICSState *xics =XICS_COMMON (dev); -int i, rc; -Error *error =NULL ; +int rc;struct kvm_create_device xics_create_device = { .type =KVM_DEV_TYPE_XICS , .flags =0 ,@@ -438,16 +430,6 @@ static void xics_kvm_realize(DeviceState *dev, Error **errp) xicskvm->kernel_xics_fd = xics_create_device.fd; -assert (xics->nr_servers); -for (i =0 ; i < xics->nr_servers; i++) { -object_property_set_bool (OBJECT (&xics->ss[i]), true,"realized" , - &error); -if (error) { -error_propagate (errp, error); - goto fail; - } - } - kvm_kernel_irqchip = true; kvm_msi_via_irqfd_allowed = true; kvm_gsi_direct_mapping = true;@@ -468,7 +450,6 @@ static void xics_kvm_class_init(ObjectClass *oc, void *data) dc->realize = xics_kvm_realize; xsc->cpu_setup = xics_kvm_cpu_setup; - xsc->set_nr_servers = xics_kvm_set_nr_servers; }static const TypeInfo xics_spapr_kvm_info = {hw/intc/xics_spapr.c +0
-26@@ -239,23 +239,8 @@ static void rtas_int_on(PowerPCCPU *cpu, sPAPRMachineState *spapr,rtas_st (rets,0 ,RTAS_OUT_SUCCESS ); } -static void xics_spapr_set_nr_servers (XICSState *xics,uint32_t nr_servers, -Error **errp) -{ -xics_set_nr_servers (xics, nr_servers,TYPE_ICP , errp); -} -static void xics_spapr_realize (DeviceState *dev,Error **errp) { -XICSState *xics =XICS_SPAPR (dev); -Error *error =NULL ; -int i; - -if (!xics->nr_servers) { -error_setg (errp,"Number of servers needs to be greater 0" ); -return ; - } -/* Registration of global state belongs into realize */ spapr_rtas_register (RTAS_IBM_SET_XIVE ,"ibm,set-xive" , rtas_set_xive);spapr_rtas_register (RTAS_IBM_GET_XIVE ,"ibm,get-xive" , rtas_get_xive);@@ -268,24 +253,13 @@ static void xics_spapr_realize(DeviceState *dev, Error **errp)spapr_register_hypercall (H_XIRR_X , h_xirr_x);spapr_register_hypercall (H_EOI , h_eoi);spapr_register_hypercall (H_IPOLL , h_ipoll); - -for (i =0 ; i < xics->nr_servers; i++) { -object_property_set_bool (OBJECT (&xics->ss[i]), true,"realized" , - &error); -if (error) { -error_propagate (errp, error); -return ; - } - } }static void xics_spapr_class_init (ObjectClass *oc,void *data) {DeviceClass *dc =DEVICE_CLASS (oc); -XICSStateClass *xsc =XICS_SPAPR_CLASS (oc); dc->realize = xics_spapr_realize; - xsc->set_nr_servers = xics_spapr_set_nr_servers; }static const TypeInfo xics_spapr_info = {hw/ppc/spapr.c +23
-7@@ -96,17 +96,17 @@#define HTAB_SIZE (spapr) (1ULL << ((spapr)->htab_shift))static XICSState *try_create_xics (const char *type,const char *type_ics, -int nr_servers,int nr_irqs,Error **errp) +const char *type_icp,int nr_servers, +int nr_irqs,Error **errp) {Error *err =NULL , *local_err =NULL ;XICSState *xics;ICSState *ics =NULL ; +int i; xics =XICS_COMMON (object_new (type));qdev_set_parent_bus (DEVICE (xics),sysbus_get_default ()); -object_property_set_int (OBJECT (xics), nr_servers,"nr_servers" , &err); -object_property_set_bool (OBJECT (xics), true,"realized" , &local_err); -error_propagate (&err, local_err); +object_property_set_bool (OBJECT (xics), true,"realized" , &err);if (err) { goto error; }@@ -122,6 +122,22 @@ static XICSState *try_create_xics(const char *type, const char *type_ics, }QLIST_INSERT_HEAD (&xics->ics, ics, list); + xics->ss =g_malloc0 (nr_servers *sizeof (ICPState)); + xics->nr_servers = nr_servers; + +for (i =0 ; i < nr_servers; i++) { +ICPState *icp = &xics->ss[i]; + +object_initialize (icp,sizeof (*icp), type_icp); +object_property_add_child (OBJECT (xics),"icp[*]" ,OBJECT (icp),NULL ); +object_property_add_const_link (OBJECT (icp),"xics" ,OBJECT (xics),NULL ); +object_property_set_bool (OBJECT (icp), true,"realized" , &err); +if (err) { + goto error; + } +object_unref (OBJECT (icp)); + } +return xics; error:@@ -143,7 +159,7 @@ static XICSState *xics_system_init(MachineState *machine,if (machine_kernel_irqchip_allowed (machine)) { xics =try_create_xics (TYPE_XICS_SPAPR_KVM ,TYPE_ICS_KVM , - nr_servers, nr_irqs, &err); +TYPE_KVM_ICP , nr_servers, nr_irqs, &err); }if (machine_kernel_irqchip_required (machine) && !xics) { error_reportf_err(err,@@ -154,8 +170,8 @@ static XICSState *xics_system_init(MachineState *machine, }if (!xics) { - xics =try_create_xics (TYPE_XICS_SPAPR ,TYPE_ICS_SIMPLE , nr_servers, - nr_irqs, errp); + xics =try_create_xics (TYPE_XICS_SPAPR ,TYPE_ICS_SIMPLE ,TYPE_ICP , + nr_servers, nr_irqs, errp); }return xics;include/hw/ppc/xics.h +0
-3@@ -74,7 +74,6 @@ struct XICSStateClass {DeviceClass parent_class;void (*cpu_setup)(XICSState *icp,PowerPCCPU *cpu); -void (*set_nr_servers)(XICSState *icp,uint32_t nr_servers,Error **errp); };struct XICSState {@@ -189,8 +188,6 @@ void spapr_dt_xics(XICSState *xics, void *fdt, uint32_t phandle);void xics_cpu_setup (XICSState *icp,PowerPCCPU *cpu);void xics_cpu_destroy (XICSState *icp,PowerPCCPU *cpu); -void xics_set_nr_servers (XICSState *xics,uint32_t nr_servers, -const char *typename,Error **errp);/* Internal XICS interfaces */ int xics_get_cpu_index_by_dt_id (int cpu_dt_id);
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
PATCH v2 3/22 ppc/xics: store the ICS object under the sPAPR machine
In reply to Cédric Le GoaterA list of ICS objects was introduced under the XICS object for the PowerNV machine, but, for the sPAPR machine, it brings extra complexity as there is only a single ICS. To simplify the code, let's add the ICS pointer under the sPAPR machine and try to reduce the use of this list where possible.
Also, change the xics_spapr_*() routines to use an ICS object instead of an XICSState and change their name to reflect that these are specific to the sPAPR ICS object.
--- hw/intc/xics_spapr.c | 22 +++++++++------------- hw/ppc/spapr.c | 29 ++++++++++++++++------------- hw/ppc/spapr_events.c | 4 ++-- hw/ppc/spapr_pci.c | 8 ++++---- hw/ppc/spapr_vio.c | 2 +- include/hw/ppc/spapr.h | 1 + include/hw/ppc/xics.h | 6 +++--- 7 files changed, 36 insertions(+), 36 deletions(-)
hw/intc/xics_spapr.c +9 -13
@@ -118,7 +118,7 @@ static void rtas_set_xive(PowerPCCPU *cpu, sPAPRMachineState *spapr, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { - ICSState *ics = QLIST_FIRST(&spapr->xics->ics); + ICSState *ics = spapr->ics;uint32_t nr, srcno, server, priority;if ((nargs !=3 ) || (nret !=1 )) {
@@ -151,7 +151,7 @@ static void rtas_get_xive(PowerPCCPU *cpu, sPAPRMachineState *spapr, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { - ICSState *ics = QLIST_FIRST(&spapr->xics->ics); + ICSState *ics = spapr->ics;uint32_t nr, srcno;if ((nargs !=1 ) || (nret !=3 )) {
@@ -181,7 +181,7 @@ static void rtas_int_off(PowerPCCPU *cpu, sPAPRMachineState *spapr, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { - ICSState *ics = QLIST_FIRST(&spapr->xics->ics); + ICSState *ics = spapr->ics;uint32_t nr, srcno;if ((nargs !=1 ) || (nret !=1 )) {
@@ -212,7 +212,7 @@ static void rtas_int_on(PowerPCCPU *cpu, sPAPRMachineState *spapr, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { - ICSState *ics = QLIST_FIRST(&spapr->xics->ics); + ICSState *ics = spapr->ics;uint32_t nr, srcno;if ((nargs !=1 ) || (nret !=1 )) {
@@ -294,9 +294,8 @@ static int ics_find_free_block(ICSState *ics, int num, int alignnum)return -1 ; } -int xics_spapr_alloc (XICSState *xics,int irq_hint,bool lsi,Error **errp) +int spapr_ics_alloc (ICSState *ics,int irq_hint,bool lsi,Error **errp) { -ICSState *ics =QLIST_FIRST (&xics->ics);int irq;if (!ics) {
@@ -327,10 +326,9 @@ int xics_spapr_alloc(XICSState *xics, int irq_hint, bool lsi, Error **errp)* Allocate block of consecutive IRQs, and return the number of the first IRQ in * the block. If align==true, aligns the first IRQ number to num. */ -int xics_spapr_alloc_block (XICSState *xics,int num,bool lsi,bool align, -Error **errp) +int spapr_ics_alloc_block (ICSState *ics,int num,bool lsi, +bool align,Error **errp) { -ICSState *ics =QLIST_FIRST (&xics->ics);int i, first =-1 ;if (!ics) {
@@ -380,11 +378,9 @@ static void ics_free(ICSState *ics, int srcno, int num) } } -void xics_spapr_free (XICSState *xics,int irq,int num) +void spapr_ics_free (ICSState *ics,int irq,int num) { -ICSState *ics =xics_find_source (xics, irq); - -if (ics) { +if (ics_valid_irq (ics, irq)) {trace_xics_ics_free (0 , irq, num);ics_free (ics, irq - ics->offset, num); }
hw/ppc/spapr.c +16 -13
@@ -95,13 +95,13 @@#define HTAB_SIZE (spapr) (1ULL << ((spapr)->htab_shift)) -static XICSState *try_create_xics (const char *type,const char *type_ics, +static XICSState *try_create_xics (sPAPRMachineState *spapr, +const char *type,const char *type_ics,const char *type_icp,int nr_servers,int nr_irqs,Error **errp) {Error *err =NULL , *local_err =NULL ;XICSState *xics; -ICSState *ics =NULL ;int i; xics =XICS_COMMON (object_new (type));
@@ -111,16 +111,17 @@ static XICSState *try_create_xics(const char *type, const char *type_ics, goto error; } - ics =ICS_SIMPLE (object_new (type_ics)); -object_property_add_child (OBJECT (xics),"ics" ,OBJECT (ics),NULL ); -object_property_set_int (OBJECT (ics), nr_irqs,"nr-irqs" , &err); -object_property_add_const_link (OBJECT (ics),"xics" ,OBJECT (xics),NULL ); -object_property_set_bool (OBJECT (ics), true,"realized" , &local_err); + spapr->ics =ICS_SIMPLE (object_new (type_ics)); +object_property_add_child (OBJECT (spapr),"ics" ,OBJECT (spapr->ics),NULL ); +object_property_set_int (OBJECT (spapr->ics), nr_irqs,"nr-irqs" , &err); +object_property_add_const_link (OBJECT (spapr->ics),"xics" ,OBJECT (xics), +NULL ); +object_property_set_bool (OBJECT (spapr->ics), true,"realized" , &local_err);error_propagate (&err, local_err);if (err) { goto error; } -QLIST_INSERT_HEAD (&xics->ics, ics, list); +QLIST_INSERT_HEAD (&xics->ics, spapr->ics, list); xics->ss =g_malloc0 (nr_servers *sizeof (ICPState)); xics->nr_servers = nr_servers;
@@ -142,8 +143,8 @@ static XICSState *try_create_xics(const char *type, const char *type_ics, error:error_propagate (errp, err); -if (ics) { -object_unparent (OBJECT (ics)); +if (spapr->ics) { +object_unparent (OBJECT (spapr->ics)); }object_unparent (OBJECT (xics));return NULL ;
@@ -158,7 +159,8 @@ static XICSState *xics_system_init(MachineState *machine,Error *err =NULL ;if (machine_kernel_irqchip_allowed (machine)) { - xics =try_create_xics (TYPE_XICS_SPAPR_KVM ,TYPE_ICS_KVM , + xics =try_create_xics (SPAPR_MACHINE (machine), +TYPE_XICS_SPAPR_KVM ,TYPE_ICS_KVM ,TYPE_KVM_ICP , nr_servers, nr_irqs, &err); }if (machine_kernel_irqchip_required (machine) && !xics) {
@@ -170,8 +172,9 @@ static XICSState *xics_system_init(MachineState *machine, }if (!xics) { - xics =try_create_xics (TYPE_XICS_SPAPR ,TYPE_ICS_SIMPLE ,TYPE_ICP , - nr_servers, nr_irqs, errp); + xics =try_create_xics (SPAPR_MACHINE (machine), +TYPE_XICS_SPAPR ,TYPE_ICS_SIMPLE , +TYPE_ICP , nr_servers, nr_irqs, errp); }return xics;
hw/ppc/spapr_events.c +2 -2
@@ -752,7 +752,7 @@ void spapr_events_init(sPAPRMachineState *spapr) spapr->event_sources =spapr_event_sources_new ();spapr_event_sources_register (spapr->event_sources,EVENT_CLASS_EPOW , -xics_spapr_alloc (spapr->xics,0 , false, +spapr_ics_alloc (spapr->ics,0 , false, &error_fatal));/* NOTE: if machine supports modern/dedicated hotplug event source,
@@ -765,7 +765,7 @@ void spapr_events_init(sPAPRMachineState *spapr)*/ if (spapr->use_hotplug_event_source) {spapr_event_sources_register (spapr->event_sources,EVENT_CLASS_HOT_PLUG , -xics_spapr_alloc (spapr->xics,0 , false, +spapr_ics_alloc (spapr->ics,0 , false, &error_fatal)); }
hw/ppc/spapr_pci.c +4 -4
@@ -325,7 +325,7 @@ static void rtas_ibm_change_msi(PowerPCCPU *cpu, sPAPRMachineState *spapr,return ; } -xics_spapr_free (spapr->xics, msi->first_irq, msi->num); +spapr_ics_free (spapr->ics, msi->first_irq, msi->num);if (msi_present (pdev)) {spapr_msi_setmsg (pdev,0 , false,0 ,0 ); }
@@ -363,7 +363,7 @@ static void rtas_ibm_change_msi(PowerPCCPU *cpu, sPAPRMachineState *spapr, }/* Allocate MSIs */ - irq =xics_spapr_alloc_block (spapr->xics, req_num, false, + irq =spapr_ics_alloc_block (spapr->ics, req_num, false, ret_intr_type ==RTAS_TYPE_MSI , &err);if (err) { error_reportf_err(err, "Can't allocate MSIs for device %x: ",
@@ -374,7 +374,7 @@ static void rtas_ibm_change_msi(PowerPCCPU *cpu, sPAPRMachineState *spapr,/* Release previous MSIs */ if (msi) { -xics_spapr_free (spapr->xics, msi->first_irq, msi->num); +spapr_ics_free (spapr->ics, msi->first_irq, msi->num);g_hash_table_remove (phb->msi, &config_addr); }
@@ -1485,7 +1485,7 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp)uint32_t irq;Error *local_err =NULL ; - irq =xics_spapr_alloc_block (spapr->xics,1 , true, false, &local_err); + irq =spapr_ics_alloc_block (spapr->ics,1 , true, false, &local_err);if (local_err) {error_propagate (errp, local_err);error_prepend (errp,"can't allocate LSIs: " );
hw/ppc/spapr_vio.c +1 -1
@@ -454,7 +454,7 @@ static void spapr_vio_busdev_realize(DeviceState *qdev, Error **errp) dev->qdev.id = id; } - dev->irq =xics_spapr_alloc (spapr->xics, dev->irq, false, &local_err); + dev->irq =spapr_ics_alloc (spapr->ics, dev->irq, false, &local_err);if (local_err) {error_propagate (errp, local_err);return ;
include/hw/ppc/spapr.h +1 -0
@@ -59,6 +59,7 @@ struct sPAPRMachineState { QLIST_HEAD(, sPAPRPHBState) phbs;struct sPAPRNVRAM *nvram;XICSState *xics; +ICSState *ics;DeviceState *rtc;void *htab;
include/hw/ppc/xics.h +3 -3
@@ -180,10 +180,10 @@ struct ICSIRQState {#define XICS_IRQS_SPAPR 1024qemu_irq xics_get_qirq (XICSState *icp,int irq); -int xics_spapr_alloc (XICSState *icp,int irq_hint,bool lsi,Error **errp); -int xics_spapr_alloc_block (XICSState *icp,int num,bool lsi,bool align, +int spapr_ics_alloc (ICSState *ics,int irq_hint,bool lsi,Error **errp); +int spapr_ics_alloc_block (ICSState *ics,int num,bool lsi,bool align,Error **errp); -void xics_spapr_free (XICSState *icp,int irq,int num); +void spapr_ics_free (ICSState *ics,int irq,int num);void spapr_dt_xics (XICSState *xics,void *fdt,uint32_t phandle);void xics_cpu_setup (XICSState *icp,PowerPCCPU *cpu);
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v2 03/22] ppc/xics: store the ICS object under the sPAPR machine
Quoted 11 lines · Cédric Le Goater
A list of ICS objects was introduced under the XICS object for the PowerNV machine, but, for the sPAPR machine, it brings extra complexity as there is only a single ICS. To simplify the code, let's add the ICS pointer under the sPAPR machine and try to reduce the use of this list where possible.
Also, change the xics_spapr_*() routines to use an ICS object instead of an XICSState and change their name to reflect that these are specific to the sPAPR ICS object.
Signed-off-by Cédric Le Goater <[email protected]>
Looks good apart from a minor point noted below.
Quoted 95 lines
--- hw/intc/xics_spapr.c | 22 +++++++++------------- hw/ppc/spapr.c | 29 ++++++++++++++++------------- hw/ppc/spapr_events.c | 4 ++-- hw/ppc/spapr_pci.c | 8 ++++---- hw/ppc/spapr_vio.c | 2 +- include/hw/ppc/spapr.h | 1 + include/hw/ppc/xics.h | 6 +++--- 7 files changed, 36 insertions(+), 36 deletions(-)hw/intc/xics_spapr.c +9
-13@@ -118,7 +118,7 @@ static void rtas_set_xive(PowerPCCPU *cpu, sPAPRMachineState *spapr, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { - ICSState *ics = QLIST_FIRST(&spapr->xics->ics); + ICSState *ics = spapr->ics;uint32_t nr, srcno, server, priority;if ((nargs !=3 ) || (nret !=1 )) {@@ -151,7 +151,7 @@ static void rtas_get_xive(PowerPCCPU *cpu, sPAPRMachineState *spapr, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { - ICSState *ics = QLIST_FIRST(&spapr->xics->ics); + ICSState *ics = spapr->ics;uint32_t nr, srcno;if ((nargs !=1 ) || (nret !=3 )) {@@ -181,7 +181,7 @@ static void rtas_int_off(PowerPCCPU *cpu, sPAPRMachineState *spapr, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { - ICSState *ics = QLIST_FIRST(&spapr->xics->ics); + ICSState *ics = spapr->ics;uint32_t nr, srcno;if ((nargs !=1 ) || (nret !=1 )) {@@ -212,7 +212,7 @@ static void rtas_int_on(PowerPCCPU *cpu, sPAPRMachineState *spapr, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { - ICSState *ics = QLIST_FIRST(&spapr->xics->ics); + ICSState *ics = spapr->ics;uint32_t nr, srcno;if ((nargs !=1 ) || (nret !=1 )) {@@ -294,9 +294,8 @@ static int ics_find_free_block(ICSState *ics, int num, int alignnum)return -1 ; } -int xics_spapr_alloc (XICSState *xics,int irq_hint,bool lsi,Error **errp) +int spapr_ics_alloc (ICSState *ics,int irq_hint,bool lsi,Error **errp) { -ICSState *ics =QLIST_FIRST (&xics->ics);int irq;if (!ics) {@@ -327,10 +326,9 @@ int xics_spapr_alloc(XICSState *xics, int irq_hint, bool lsi, Error **errp)* Allocate block of consecutive IRQs, and return the number of the first IRQ in * the block. If align==true, aligns the first IRQ number to num. */ -int xics_spapr_alloc_block (XICSState *xics,int num,bool lsi,bool align, -Error **errp) +int spapr_ics_alloc_block (ICSState *ics,int num,bool lsi, +bool align,Error **errp) { -ICSState *ics =QLIST_FIRST (&xics->ics);int i, first =-1 ;if (!ics) {@@ -380,11 +378,9 @@ static void ics_free(ICSState *ics, int srcno, int num) } } -void xics_spapr_free (XICSState *xics,int irq,int num) +void spapr_ics_free (ICSState *ics,int irq,int num) { -ICSState *ics =xics_find_source (xics, irq); - -if (ics) { +if (ics_valid_irq (ics, irq)) {trace_xics_ics_free (0 , irq, num);ics_free (ics, irq - ics->offset, num); }hw/ppc/spapr.c +0
-0@@ -95,13 +95,13 @@#define HTAB_SIZE (spapr) (1ULL << ((spapr)->htab_shift))
hw/ppc/spapr.c line 104
Quoted 10 lines
hw/ppc/spapr.c +2
-2-static XICSState *try_create_xics (const char *type,const char *type_ics, +static XICSState *try_create_xics (sPAPRMachineState *spapr, +const char *type,const char *type_ics,const char *type_icp,int nr_servers,int nr_irqs,Error **errp) {Error *err =NULL , *local_err =NULL ;XICSState *xics; -ICSState *ics =NULL ;
I'd prefer to keep this local and just update spapr->ics at the end of the function. It won't really make a difference, since if the xics doesn't initialize nothing will work, but currently if this fails it could leave spapr->ics with a bogus but non-NULL pointer, which isn't good practice.
Quoted 165 lines
hw/ppc/spapr.c +14
-11int i; xics =XICS_COMMON (object_new (type));@@ -111,16 +111,17 @@ static XICSState *try_create_xics(const char *type, const char *type_ics, goto error; } - ics =ICS_SIMPLE (object_new (type_ics)); -object_property_add_child (OBJECT (xics),"ics" ,OBJECT (ics),NULL ); -object_property_set_int (OBJECT (ics), nr_irqs,"nr-irqs" , &err); -object_property_add_const_link (OBJECT (ics),"xics" ,OBJECT (xics),NULL ); -object_property_set_bool (OBJECT (ics), true,"realized" , &local_err); + spapr->ics =ICS_SIMPLE (object_new (type_ics)); +object_property_add_child (OBJECT (spapr),"ics" ,OBJECT (spapr->ics),NULL ); +object_property_set_int (OBJECT (spapr->ics), nr_irqs,"nr-irqs" , &err); +object_property_add_const_link (OBJECT (spapr->ics),"xics" ,OBJECT (xics), +NULL ); +object_property_set_bool (OBJECT (spapr->ics), true,"realized" , &local_err);error_propagate (&err, local_err);if (err) { goto error; } -QLIST_INSERT_HEAD (&xics->ics, ics, list); +QLIST_INSERT_HEAD (&xics->ics, spapr->ics, list); xics->ss =g_malloc0 (nr_servers *sizeof (ICPState)); xics->nr_servers = nr_servers;@@ -142,8 +143,8 @@ static XICSState *try_create_xics(const char *type, const char *type_ics, error:error_propagate (errp, err); -if (ics) { -object_unparent (OBJECT (ics)); +if (spapr->ics) { +object_unparent (OBJECT (spapr->ics)); }object_unparent (OBJECT (xics));return NULL ;@@ -158,7 +159,8 @@ static XICSState *xics_system_init(MachineState *machine,Error *err =NULL ;if (machine_kernel_irqchip_allowed (machine)) { - xics =try_create_xics (TYPE_XICS_SPAPR_KVM ,TYPE_ICS_KVM , + xics =try_create_xics (SPAPR_MACHINE (machine), +TYPE_XICS_SPAPR_KVM ,TYPE_ICS_KVM ,TYPE_KVM_ICP , nr_servers, nr_irqs, &err); }if (machine_kernel_irqchip_required (machine) && !xics) {@@ -170,8 +172,9 @@ static XICSState *xics_system_init(MachineState *machine, }if (!xics) { - xics =try_create_xics (TYPE_XICS_SPAPR ,TYPE_ICS_SIMPLE ,TYPE_ICP , - nr_servers, nr_irqs, errp); + xics =try_create_xics (SPAPR_MACHINE (machine), +TYPE_XICS_SPAPR ,TYPE_ICS_SIMPLE , +TYPE_ICP , nr_servers, nr_irqs, errp); }return xics;hw/ppc/spapr_events.c +2
-2@@ -752,7 +752,7 @@ void spapr_events_init(sPAPRMachineState *spapr) spapr->event_sources =spapr_event_sources_new ();spapr_event_sources_register (spapr->event_sources,EVENT_CLASS_EPOW , -xics_spapr_alloc (spapr->xics,0 , false, +spapr_ics_alloc (spapr->ics,0 , false, &error_fatal));/* NOTE: if machine supports modern/dedicated hotplug event source, @@ -765,7 +765,7 @@ void spapr_events_init(sPAPRMachineState *spapr)*/ if (spapr->use_hotplug_event_source) {spapr_event_sources_register (spapr->event_sources,EVENT_CLASS_HOT_PLUG , -xics_spapr_alloc (spapr->xics,0 , false, +spapr_ics_alloc (spapr->ics,0 , false, &error_fatal)); }hw/ppc/spapr_pci.c +4
-4@@ -325,7 +325,7 @@ static void rtas_ibm_change_msi(PowerPCCPU *cpu, sPAPRMachineState *spapr,return ; } -xics_spapr_free (spapr->xics, msi->first_irq, msi->num); +spapr_ics_free (spapr->ics, msi->first_irq, msi->num);if (msi_present (pdev)) {spapr_msi_setmsg (pdev,0 , false,0 ,0 ); }@@ -363,7 +363,7 @@ static void rtas_ibm_change_msi(PowerPCCPU *cpu, sPAPRMachineState *spapr, }/* Allocate MSIs */ - irq =xics_spapr_alloc_block (spapr->xics, req_num, false, + irq =spapr_ics_alloc_block (spapr->ics, req_num, false, ret_intr_type ==RTAS_TYPE_MSI , &err);if (err) { error_reportf_err(err, "Can't allocate MSIs for device %x: ",@@ -374,7 +374,7 @@ static void rtas_ibm_change_msi(PowerPCCPU *cpu, sPAPRMachineState *spapr,/* Release previous MSIs */ if (msi) { -xics_spapr_free (spapr->xics, msi->first_irq, msi->num); +spapr_ics_free (spapr->ics, msi->first_irq, msi->num);g_hash_table_remove (phb->msi, &config_addr); }@@ -1485,7 +1485,7 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp)uint32_t irq;Error *local_err =NULL ; - irq =xics_spapr_alloc_block (spapr->xics,1 , true, false, &local_err); + irq =spapr_ics_alloc_block (spapr->ics,1 , true, false, &local_err);if (local_err) {error_propagate (errp, local_err);error_prepend (errp,"can't allocate LSIs: " );hw/ppc/spapr_vio.c +1
-1@@ -454,7 +454,7 @@ static void spapr_vio_busdev_realize(DeviceState *qdev, Error **errp) dev->qdev.id = id; } - dev->irq =xics_spapr_alloc (spapr->xics, dev->irq, false, &local_err); + dev->irq =spapr_ics_alloc (spapr->ics, dev->irq, false, &local_err);if (local_err) {error_propagate (errp, local_err);return ;include/hw/ppc/spapr.h +1
-0@@ -59,6 +59,7 @@ struct sPAPRMachineState { QLIST_HEAD(, sPAPRPHBState) phbs;struct sPAPRNVRAM *nvram;XICSState *xics; +ICSState *ics;DeviceState *rtc;void *htab;include/hw/ppc/xics.h +3
-3@@ -180,10 +180,10 @@ struct ICSIRQState {#define XICS_IRQS_SPAPR 1024qemu_irq xics_get_qirq (XICSState *icp,int irq); -int xics_spapr_alloc (XICSState *icp,int irq_hint,bool lsi,Error **errp); -int xics_spapr_alloc_block (XICSState *icp,int num,bool lsi,bool align, +int spapr_ics_alloc (ICSState *ics,int irq_hint,bool lsi,Error **errp); +int spapr_ics_alloc_block (ICSState *ics,int num,bool lsi,bool align,Error **errp); -void xics_spapr_free (XICSState *icp,int irq,int num); +void spapr_ics_free (ICSState *ics,int irq,int num);void spapr_dt_xics (XICSState *xics,void *fdt,uint32_t phandle);void xics_cpu_setup (XICSState *icp,PowerPCCPU *cpu);
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [Qemu-devel] [PATCH v2 03/22] ppc/xics: store the ICS object under the sPAPR machine
Quoted 111 lines · David Gibson
Quoted 11 lines · Cédric Le Goater
A list of ICS objects was introduced under the XICS object for the PowerNV machine, but, for the sPAPR machine, it brings extra complexity as there is only a single ICS. To simplify the code, let's add the ICS pointer under the sPAPR machine and try to reduce the use of this list where possible.
Also, change the xics_spapr_*() routines to use an ICS object instead of an XICSState and change their name to reflect that these are specific to the sPAPR ICS object.
Signed-off-by Cédric Le Goater <[email protected]>Looks good apart from a minor point noted below.
Quoted 96 lines
--- hw/intc/xics_spapr.c | 22 +++++++++------------- hw/ppc/spapr.c | 29 ++++++++++++++++------------- hw/ppc/spapr_events.c | 4 ++-- hw/ppc/spapr_pci.c | 8 ++++---- hw/ppc/spapr_vio.c | 2 +- include/hw/ppc/spapr.h | 1 + include/hw/ppc/xics.h | 6 +++--- 7 files changed, 36 insertions(+), 36 deletions(-)hw/intc/xics_spapr.c +9
-13@@ -118,7 +118,7 @@ static void rtas_set_xive(PowerPCCPU *cpu, sPAPRMachineState *spapr, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { - ICSState *ics = QLIST_FIRST(&spapr->xics->ics); + ICSState *ics = spapr->ics;uint32_t nr, srcno, server, priority;if ((nargs !=3 ) || (nret !=1 )) {@@ -151,7 +151,7 @@ static void rtas_get_xive(PowerPCCPU *cpu, sPAPRMachineState *spapr, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { - ICSState *ics = QLIST_FIRST(&spapr->xics->ics); + ICSState *ics = spapr->ics;uint32_t nr, srcno;if ((nargs !=1 ) || (nret !=3 )) {@@ -181,7 +181,7 @@ static void rtas_int_off(PowerPCCPU *cpu, sPAPRMachineState *spapr, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { - ICSState *ics = QLIST_FIRST(&spapr->xics->ics); + ICSState *ics = spapr->ics;uint32_t nr, srcno;if ((nargs !=1 ) || (nret !=1 )) {@@ -212,7 +212,7 @@ static void rtas_int_on(PowerPCCPU *cpu, sPAPRMachineState *spapr, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { - ICSState *ics = QLIST_FIRST(&spapr->xics->ics); + ICSState *ics = spapr->ics;uint32_t nr, srcno;if ((nargs !=1 ) || (nret !=1 )) {@@ -294,9 +294,8 @@ static int ics_find_free_block(ICSState *ics, int num, int alignnum)return -1 ; } -int xics_spapr_alloc (XICSState *xics,int irq_hint,bool lsi,Error **errp) +int spapr_ics_alloc (ICSState *ics,int irq_hint,bool lsi,Error **errp) { -ICSState *ics =QLIST_FIRST (&xics->ics);int irq;if (!ics) {@@ -327,10 +326,9 @@ int xics_spapr_alloc(XICSState *xics, int irq_hint, bool lsi, Error **errp)* Allocate block of consecutive IRQs, and return the number of the first IRQ in * the block. If align==true, aligns the first IRQ number to num. */ -int xics_spapr_alloc_block (XICSState *xics,int num,bool lsi,bool align, -Error **errp) +int spapr_ics_alloc_block (ICSState *ics,int num,bool lsi, +bool align,Error **errp) { -ICSState *ics =QLIST_FIRST (&xics->ics);int i, first =-1 ;if (!ics) {@@ -380,11 +378,9 @@ static void ics_free(ICSState *ics, int srcno, int num) } } -void xics_spapr_free (XICSState *xics,int irq,int num) +void spapr_ics_free (ICSState *ics,int irq,int num) { -ICSState *ics =xics_find_source (xics, irq); - -if (ics) { +if (ics_valid_irq (ics, irq)) {trace_xics_ics_free (0 , irq, num);ics_free (ics, irq - ics->offset, num); }hw/ppc/spapr.c +0
-0@@ -95,13 +95,13 @@#define HTAB_SIZE (spapr) (1ULL << ((spapr)->htab_shift))
Quoted 15 lines
hw/ppc/spapr.c line 104
Quoted 9 lines
hw/ppc/spapr.c +2
-2-static XICSState *try_create_xics (const char *type,const char *type_ics, +static XICSState *try_create_xics (sPAPRMachineState *spapr, +const char *type,const char *type_ics,const char *type_icp,int nr_servers,int nr_irqs,Error **errp) {Error *err =NULL , *local_err =NULL ;XICSState *xics; -ICSState *ics =NULL ;I'd prefer to keep this local and just update
spapr->icsat the end of the function. It won't really make a difference, since if the xics doesn't initialize nothing will work, but currently if this fails it could leavespapr->icswith a bogus but non-NULL pointer, which isn't good practice.
Indeed. I will make the change.
Thanks,
C.
Quoted 167 lines
Quoted 166 lines
hw/ppc/spapr.c +14
-11int i; xics =XICS_COMMON (object_new (type));@@ -111,16 +111,17 @@ static XICSState *try_create_xics(const char *type, const char *type_ics, goto error; } - ics =ICS_SIMPLE (object_new (type_ics)); -object_property_add_child (OBJECT (xics),"ics" ,OBJECT (ics),NULL ); -object_property_set_int (OBJECT (ics), nr_irqs,"nr-irqs" , &err); -object_property_add_const_link (OBJECT (ics),"xics" ,OBJECT (xics),NULL ); -object_property_set_bool (OBJECT (ics), true,"realized" , &local_err); + spapr->ics =ICS_SIMPLE (object_new (type_ics)); +object_property_add_child (OBJECT (spapr),"ics" ,OBJECT (spapr->ics),NULL ); +object_property_set_int (OBJECT (spapr->ics), nr_irqs,"nr-irqs" , &err); +object_property_add_const_link (OBJECT (spapr->ics),"xics" ,OBJECT (xics), +NULL ); +object_property_set_bool (OBJECT (spapr->ics), true,"realized" , &local_err);error_propagate (&err, local_err);if (err) { goto error; } -QLIST_INSERT_HEAD (&xics->ics, ics, list); +QLIST_INSERT_HEAD (&xics->ics, spapr->ics, list); xics->ss =g_malloc0 (nr_servers *sizeof (ICPState)); xics->nr_servers = nr_servers;@@ -142,8 +143,8 @@ static XICSState *try_create_xics(const char *type, const char *type_ics, error:error_propagate (errp, err); -if (ics) { -object_unparent (OBJECT (ics)); +if (spapr->ics) { +object_unparent (OBJECT (spapr->ics)); }object_unparent (OBJECT (xics));return NULL ;@@ -158,7 +159,8 @@ static XICSState *xics_system_init(MachineState *machine,Error *err =NULL ;if (machine_kernel_irqchip_allowed (machine)) { - xics =try_create_xics (TYPE_XICS_SPAPR_KVM ,TYPE_ICS_KVM , + xics =try_create_xics (SPAPR_MACHINE (machine), +TYPE_XICS_SPAPR_KVM ,TYPE_ICS_KVM ,TYPE_KVM_ICP , nr_servers, nr_irqs, &err); }if (machine_kernel_irqchip_required (machine) && !xics) {@@ -170,8 +172,9 @@ static XICSState *xics_system_init(MachineState *machine, }if (!xics) { - xics =try_create_xics (TYPE_XICS_SPAPR ,TYPE_ICS_SIMPLE ,TYPE_ICP , - nr_servers, nr_irqs, errp); + xics =try_create_xics (SPAPR_MACHINE (machine), +TYPE_XICS_SPAPR ,TYPE_ICS_SIMPLE , +TYPE_ICP , nr_servers, nr_irqs, errp); }return xics;hw/ppc/spapr_events.c +2
-2@@ -752,7 +752,7 @@ void spapr_events_init(sPAPRMachineState *spapr) spapr->event_sources =spapr_event_sources_new ();spapr_event_sources_register (spapr->event_sources,EVENT_CLASS_EPOW , -xics_spapr_alloc (spapr->xics,0 , false, +spapr_ics_alloc (spapr->ics,0 , false, &error_fatal));/* NOTE: if machine supports modern/dedicated hotplug event source, @@ -765,7 +765,7 @@ void spapr_events_init(sPAPRMachineState *spapr)*/ if (spapr->use_hotplug_event_source) {spapr_event_sources_register (spapr->event_sources,EVENT_CLASS_HOT_PLUG , -xics_spapr_alloc (spapr->xics,0 , false, +spapr_ics_alloc (spapr->ics,0 , false, &error_fatal)); }hw/ppc/spapr_pci.c +4
-4@@ -325,7 +325,7 @@ static void rtas_ibm_change_msi(PowerPCCPU *cpu, sPAPRMachineState *spapr,return ; } -xics_spapr_free (spapr->xics, msi->first_irq, msi->num); +spapr_ics_free (spapr->ics, msi->first_irq, msi->num);if (msi_present (pdev)) {spapr_msi_setmsg (pdev,0 , false,0 ,0 ); }@@ -363,7 +363,7 @@ static void rtas_ibm_change_msi(PowerPCCPU *cpu, sPAPRMachineState *spapr, }/* Allocate MSIs */ - irq =xics_spapr_alloc_block (spapr->xics, req_num, false, + irq =spapr_ics_alloc_block (spapr->ics, req_num, false, ret_intr_type ==RTAS_TYPE_MSI , &err);if (err) { error_reportf_err(err, "Can't allocate MSIs for device %x: ",@@ -374,7 +374,7 @@ static void rtas_ibm_change_msi(PowerPCCPU *cpu, sPAPRMachineState *spapr,/* Release previous MSIs */ if (msi) { -xics_spapr_free (spapr->xics, msi->first_irq, msi->num); +spapr_ics_free (spapr->ics, msi->first_irq, msi->num);g_hash_table_remove (phb->msi, &config_addr); }@@ -1485,7 +1485,7 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp)uint32_t irq;Error *local_err =NULL ; - irq =xics_spapr_alloc_block (spapr->xics,1 , true, false, &local_err); + irq =spapr_ics_alloc_block (spapr->ics,1 , true, false, &local_err);if (local_err) {error_propagate (errp, local_err);error_prepend (errp,"can't allocate LSIs: " );hw/ppc/spapr_vio.c +1
-1@@ -454,7 +454,7 @@ static void spapr_vio_busdev_realize(DeviceState *qdev, Error **errp) dev->qdev.id = id; } - dev->irq =xics_spapr_alloc (spapr->xics, dev->irq, false, &local_err); + dev->irq =spapr_ics_alloc (spapr->ics, dev->irq, false, &local_err);if (local_err) {error_propagate (errp, local_err);return ;include/hw/ppc/spapr.h +1
-0@@ -59,6 +59,7 @@ struct sPAPRMachineState { QLIST_HEAD(, sPAPRPHBState) phbs;struct sPAPRNVRAM *nvram;XICSState *xics; +ICSState *ics;DeviceState *rtc;void *htab;include/hw/ppc/xics.h +3
-3@@ -180,10 +180,10 @@ struct ICSIRQState {#define XICS_IRQS_SPAPR 1024qemu_irq xics_get_qirq (XICSState *icp,int irq); -int xics_spapr_alloc (XICSState *icp,int irq_hint,bool lsi,Error **errp); -int xics_spapr_alloc_block (XICSState *icp,int num,bool lsi,bool align, +int spapr_ics_alloc (ICSState *ics,int irq_hint,bool lsi,Error **errp); +int spapr_ics_alloc_block (ICSState *ics,int num,bool lsi,bool align,Error **errp); -void xics_spapr_free (XICSState *icp,int irq,int num); +void spapr_ics_free (ICSState *ics,int irq,int num);void spapr_dt_xics (XICSState *xics,void *fdt,uint32_t phandle);void xics_cpu_setup (XICSState *icp,PowerPCCPU *cpu);
PATCH v2 4/22 ppc/xics: add an InterruptStatsProvider interface to ICS and ICP objects
In reply to Cédric Le GoaterThis is, again, to reduce the use of the list of ICS objects. Let's make each individual ICS and ICP object an InterruptStatsProvider and remove this same interface from XICSState.
--- hw/intc/xics.c | 76 +++++++++++++++++++++++++++++++--------------------------- 1 file changed, 41 insertions(+), 35 deletions(-)
hw/intc/xics.c +41 -35
@@ -92,44 +92,44 @@ void xics_cpu_setup(XICSState *xics, PowerPCCPU *cpu) } } -static void xics_common_pic_print_info (InterruptStatsProvider *obj, -Monitor *mon) +static void icp_pic_print_info (InterruptStatsProvider *obj, +Monitor *mon) { -XICSState *xics =XICS_COMMON (obj); -ICSState *ics; +ICPState *icp =ICP (obj); +int cpu_index = icp->cs ? icp->cs->cpu_index :-1 ; + +if (!icp->output) { +return ; + } +monitor_printf (mon,"CPU %d XIRR=%08x (%p) PP=%02x MFRR=%02x\n" , + cpu_index, icp->xirr, icp->xirr_owner, + icp->pending_priority, icp->mfrr); +} + +static void ics_simple_pic_print_info (InterruptStatsProvider *obj, +Monitor *mon) +{ +ICSState *ics =ICS_SIMPLE (obj);uint32_t i; -for (i =0 ; i < xics->nr_servers; i++) { -ICPState *icp = &xics->ss[i]; +monitor_printf (mon,"ICS %4x..%4x %p\n" , + ics->offset, ics->offset + ics->nr_irqs -1 , ics); -if (!icp->output) { -continue ; - } -monitor_printf (mon,"CPU %d XIRR=%08x (%p) PP=%02x MFRR=%02x\n" , - i, icp->xirr, icp->xirr_owner, - icp->pending_priority, icp->mfrr); +if (!ics->irqs) { +return ; } - QLIST_FOREACH(ics, &xics->ics, list) { -monitor_printf (mon,"ICS %4x..%4x %p\n" , - ics->offset, ics->offset + ics->nr_irqs -1 , ics); +for (i =0 ; i < ics->nr_irqs; i++) { +ICSIRQState *irq = ics->irqs + i; -if (!ics->irqs) { +if (!(irq->flags &XICS_FLAGS_IRQ_MASK )) {continue ; } - -for (i =0 ; i < ics->nr_irqs; i++) { -ICSIRQState *irq = ics->irqs + i; - -if (!(irq->flags &XICS_FLAGS_IRQ_MASK )) { -continue ; - } -monitor_printf (mon," %4x %s %02x %02x\n" , - ics->offset + i, - (irq->flags &XICS_FLAGS_IRQ_LSI ) ? -"LSI" :"MSI" , - irq->priority, irq->status); - } +monitor_printf (mon," %4x %s %02x %02x\n" , + ics->offset + i, + (irq->flags &XICS_FLAGS_IRQ_LSI ) ? +"LSI" :"MSI" , + irq->priority, irq->status); } }
@@ -161,10 +161,8 @@ static void xics_common_initfn(Object *obj)static void xics_common_class_init (ObjectClass *oc,void *data) {DeviceClass *dc =DEVICE_CLASS (oc); -InterruptStatsProviderClass *ic =INTERRUPT_STATS_PROVIDER_CLASS (oc); dc->reset = xics_common_reset; - ic->print_info = xics_common_pic_print_info; }static const TypeInfo xics_common_info = {
@@ -174,10 +172,6 @@ static const TypeInfo xics_common_info = { .class_size = sizeof(XICSStateClass), .instance_init = xics_common_initfn, .class_init = xics_common_class_init, - .interfaces = (InterfaceInfo []) { - {TYPE_INTERRUPT_STATS_PROVIDER }, - { } - }, };/*
@@ -414,10 +408,12 @@ static void icp_realize(DeviceState *dev, Error **errp)static void icp_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass); +InterruptStatsProviderClass *ic =INTERRUPT_STATS_PROVIDER_CLASS (klass); dc->reset = icp_reset; dc->vmsd = &vmstate_icp_server; dc->realize = icp_realize; + ic->print_info = icp_pic_print_info; }static const TypeInfo icp_info = {
@@ -426,6 +422,10 @@ static const TypeInfo icp_info = { .instance_size = sizeof(ICPState), .class_init = icp_class_init, .class_size = sizeof(ICPStateClass), + .interfaces = (InterfaceInfo []) { + {TYPE_INTERRUPT_STATS_PROVIDER }, + { } + }, };/*
@@ -692,6 +692,7 @@ static void ics_simple_class_init(ObjectClass *klass, void *data) {DeviceClass *dc =DEVICE_CLASS (klass);ICSStateClass *isc =ICS_BASE_CLASS (klass); +InterruptStatsProviderClass *ic =INTERRUPT_STATS_PROVIDER_CLASS (klass); dc->realize = ics_simple_realize; dc->props = ics_simple_properties;
@@ -701,6 +702,7 @@ static void ics_simple_class_init(ObjectClass *klass, void *data) isc->reject = ics_simple_reject; isc->resend = ics_simple_resend; isc->eoi = ics_simple_eoi; + ic->print_info = ics_simple_pic_print_info; }static const TypeInfo ics_simple_info = {
@@ -710,6 +712,10 @@ static const TypeInfo ics_simple_info = { .class_init = ics_simple_class_init, .class_size = sizeof(ICSStateClass), .instance_init = ics_simple_initfn, + .interfaces = (InterfaceInfo []) { + {TYPE_INTERRUPT_STATS_PROVIDER }, + { } + }, };static const TypeInfo ics_base_info = {
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v2 04/22] ppc/xics: add an InterruptStatsProvider interface to ICS and ICP objects
Quoted 5 lines · Cédric Le Goater
This is, again, to reduce the use of the list of ICS objects. Let's make each individual ICS and ICP object an InterruptStatsProvider and remove this same interface from XICSState.
Signed-off-by Cédric Le Goater <[email protected]>
I'm a little hesitant about this, because it means that getting the interrupt stats information is now spread out over the qom tree, whereas previously there was a single location to get a good summary of the systems overall interrupt status. The previous behaviour seems like it would be more convenient for debugging.
That said, I see the structural advantages of this split. Hmm.. still thinking..
Quoted 155 lines
--- hw/intc/xics.c | 76 +++++++++++++++++++++++++++++++--------------------------- 1 file changed, 41 insertions(+), 35 deletions(-)hw/intc/xics.c +41
-35@@ -92,44 +92,44 @@ void xics_cpu_setup(XICSState *xics, PowerPCCPU *cpu) } } -static void xics_common_pic_print_info (InterruptStatsProvider *obj, -Monitor *mon) +static void icp_pic_print_info (InterruptStatsProvider *obj, +Monitor *mon) { -XICSState *xics =XICS_COMMON (obj); -ICSState *ics; +ICPState *icp =ICP (obj); +int cpu_index = icp->cs ? icp->cs->cpu_index :-1 ; + +if (!icp->output) { +return ; + } +monitor_printf (mon,"CPU %d XIRR=%08x (%p) PP=%02x MFRR=%02x\n" , + cpu_index, icp->xirr, icp->xirr_owner, + icp->pending_priority, icp->mfrr); +} + +static void ics_simple_pic_print_info (InterruptStatsProvider *obj, +Monitor *mon) +{ +ICSState *ics =ICS_SIMPLE (obj);uint32_t i; -for (i =0 ; i < xics->nr_servers; i++) { -ICPState *icp = &xics->ss[i]; +monitor_printf (mon,"ICS %4x..%4x %p\n" , + ics->offset, ics->offset + ics->nr_irqs -1 , ics); -if (!icp->output) { -continue ; - } -monitor_printf (mon,"CPU %d XIRR=%08x (%p) PP=%02x MFRR=%02x\n" , - i, icp->xirr, icp->xirr_owner, - icp->pending_priority, icp->mfrr); +if (!ics->irqs) { +return ; } - QLIST_FOREACH(ics, &xics->ics, list) { -monitor_printf (mon,"ICS %4x..%4x %p\n" , - ics->offset, ics->offset + ics->nr_irqs -1 , ics); +for (i =0 ; i < ics->nr_irqs; i++) { +ICSIRQState *irq = ics->irqs + i; -if (!ics->irqs) { +if (!(irq->flags &XICS_FLAGS_IRQ_MASK )) {continue ; } - -for (i =0 ; i < ics->nr_irqs; i++) { -ICSIRQState *irq = ics->irqs + i; - -if (!(irq->flags &XICS_FLAGS_IRQ_MASK )) { -continue ; - } -monitor_printf (mon," %4x %s %02x %02x\n" , - ics->offset + i, - (irq->flags &XICS_FLAGS_IRQ_LSI ) ? -"LSI" :"MSI" , - irq->priority, irq->status); - } +monitor_printf (mon," %4x %s %02x %02x\n" , + ics->offset + i, + (irq->flags &XICS_FLAGS_IRQ_LSI ) ? +"LSI" :"MSI" , + irq->priority, irq->status); } }@@ -161,10 +161,8 @@ static void xics_common_initfn(Object *obj)static void xics_common_class_init (ObjectClass *oc,void *data) {DeviceClass *dc =DEVICE_CLASS (oc); -InterruptStatsProviderClass *ic =INTERRUPT_STATS_PROVIDER_CLASS (oc); dc->reset = xics_common_reset; - ic->print_info = xics_common_pic_print_info; }static const TypeInfo xics_common_info = {@@ -174,10 +172,6 @@ static const TypeInfo xics_common_info = { .class_size = sizeof(XICSStateClass), .instance_init = xics_common_initfn, .class_init = xics_common_class_init, - .interfaces = (InterfaceInfo []) { - {TYPE_INTERRUPT_STATS_PROVIDER }, - { } - }, };/* @@ -414,10 +408,12 @@ static void icp_realize(DeviceState *dev, Error **errp)static void icp_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass); +InterruptStatsProviderClass *ic =INTERRUPT_STATS_PROVIDER_CLASS (klass); dc->reset = icp_reset; dc->vmsd = &vmstate_icp_server; dc->realize = icp_realize; + ic->print_info = icp_pic_print_info; }static const TypeInfo icp_info = {@@ -426,6 +422,10 @@ static const TypeInfo icp_info = { .instance_size = sizeof(ICPState), .class_init = icp_class_init, .class_size = sizeof(ICPStateClass), + .interfaces = (InterfaceInfo []) { + {TYPE_INTERRUPT_STATS_PROVIDER }, + { } + }, };/* @@ -692,6 +692,7 @@ static void ics_simple_class_init(ObjectClass *klass, void *data) {DeviceClass *dc =DEVICE_CLASS (klass);ICSStateClass *isc =ICS_BASE_CLASS (klass); +InterruptStatsProviderClass *ic =INTERRUPT_STATS_PROVIDER_CLASS (klass); dc->realize = ics_simple_realize; dc->props = ics_simple_properties;@@ -701,6 +702,7 @@ static void ics_simple_class_init(ObjectClass *klass, void *data) isc->reject = ics_simple_reject; isc->resend = ics_simple_resend; isc->eoi = ics_simple_eoi; + ic->print_info = ics_simple_pic_print_info; }static const TypeInfo ics_simple_info = {@@ -710,6 +712,10 @@ static const TypeInfo ics_simple_info = { .class_init = ics_simple_class_init, .class_size = sizeof(ICSStateClass), .instance_init = ics_simple_initfn, + .interfaces = (InterfaceInfo []) { + {TYPE_INTERRUPT_STATS_PROVIDER }, + { } + }, };static const TypeInfo ics_base_info = {
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 04/22] ppc/xics: add an InterruptStatsProvider interface to ICS and ICP objects
Quoted 7 lines · David Gibson
Quoted 5 lines · Cédric Le Goater
This is, again, to reduce the use of the list of ICS objects. Let's make each individual ICS and ICP object an InterruptStatsProvider and remove this same interface from XICSState.
Signed-off-by Cédric Le Goater <[email protected]>
Quoted 8 lines
I'm a little hesitant about this, because it means that getting the interrupt stats information is now spread out over the qom tree, whereas previously there was a single location to get a good summary of the systems overall interrupt status. The previous behaviour seems like it would be more convenient for debugging.
That said, I see the structural advantages of this split. Hmm.. still thinking..
This is true. Another argument in favour of what you are saying is the order in which these are printed. See below.
What we could do after the cleanup is to make the machine an InterruptStatsProvider to clarify things.
Thanks,
C.
(qemu) info pic
CPU 18 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 0 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 21 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 2 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 23 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 4 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 11 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 25 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 6 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 13 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 27 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 8 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 15 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 29 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 30 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 17 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 20 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 19 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 1 XIRR=00000000 ((nil)) PP=ff MFRR=ff ICS 1000..13ff 0x10018f1ea40
1000 MSI ff 00
1001 MSI ff 00
1002 MSI ff 00
1003 MSI ff 00
1004 LSI ff 00
1005 LSI ff 00
1006 LSI ff 00
1007 LSI ff 00
1008 MSI ff 00
1009 MSI ff 00
100a MSI ff 00
100b MSI ff 00
100c MSI ff 00
CPU 22 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 3 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 10 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 24 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 5 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 12 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 26 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 7 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 14 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 28 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 9 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 16 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 31 XIRR=00000000 ((nil)) PP=ff MFRR=ff
Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 04/22] ppc/xics: add an InterruptStatsProvider interface to ICS and ICP objects
Quoted 14 lines · Cédric Le Goater
Quoted 13 lines · David Gibson
Quoted 5 lines · Cédric Le Goater
This is, again, to reduce the use of the list of ICS objects. Let's make each individual ICS and ICP object an InterruptStatsProvider and remove this same interface from XICSState.
Signed-off-by Cédric Le Goater <[email protected]>I'm a little hesitant about this, because it means that getting the interrupt stats information is now spread out over the qom tree, whereas previously there was a single location to get a good summary of the systems overall interrupt status. The previous behaviour seems like it would be more convenient for debugging.
Quoted 8 lines
Quoted 2 lines
That said, I see the structural advantages of this split. Hmm.. still thinking..
This is true. Another argument in favour of what you are saying is the order in which these are printed. See below.
What we could do after the cleanup is to make the machine an InterruptStatsProvider to clarify things.
Right. So "info pic" does at least iterate through all the providers, but the semi-random order is pretty icky. I think putting the stats provider on the machine would be a better idea - I guess it should be easy enough if the xics code provides a helper.
Quoted 55 lines
Thanks,
C.
(qemu) info pic
CPU 18 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 0 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 21 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 2 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 23 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 4 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 11 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 25 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 6 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 13 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 27 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 8 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 15 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 29 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 30 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 17 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 20 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 19 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 1 XIRR=00000000 ((nil)) PP=ff MFRR=ff ICS 1000..13ff0x10018f1ea40
1000 MSI ff 00
1001 MSI ff 00
1002 MSI ff 00
1003 MSI ff 00
1004 LSI ff 00
1005 LSI ff 00
1006 LSI ff 00
1007 LSI ff 00
1008 MSI ff 00
1009 MSI ff 00
100a MSI ff 00
100b MSI ff 00
100c MSI ff 00
CPU 22 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 3 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 10 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 24 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 5 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 12 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 26 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 7 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 14 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 28 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 9 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 16 XIRR=00000000 ((nil)) PP=ff MFRR=ff CPU 31 XIRR=00000000 ((nil)) PP=ff MFRR=ff
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 04/22] ppc/xics: add an InterruptStatsProvider interface to ICS and ICP objects
Quoted 21 lines · David Gibson
Quoted 20 lines · Cédric Le Goater
Quoted 7 lines · David Gibson
Quoted 5 lines · Cédric Le Goater
This is, again, to reduce the use of the list of ICS objects. Let's make each individual ICS and ICP object an InterruptStatsProvider and remove this same interface from XICSState.
Signed-off-by Cédric Le Goater <[email protected]>Quoted 8 lines
I'm a little hesitant about this, because it means that getting the interrupt stats information is now spread out over the qom tree, whereas previously there was a single location to get a good summary of the systems overall interrupt status. The previous behaviour seems like it would be more convenient for debugging.
That said, I see the structural advantages of this split. Hmm.. still thinking..
This is true. Another argument in favour of what you are saying is the order in which these are printed. See below.
Quoted 7 lines
Quoted 2 lines
What we could do after the cleanup is to make the machine an InterruptStatsProvider to clarify things.
Right. So "info pic" does at least iterate through all the providers, but the semi-random order is pretty icky. I think putting the stats provider on the machine would be a better idea - I guess it should be easy enough if the xics code provides a helper.
OK. This is on my TODO list for the next version of the patchset but as a followup patch. I don't want to change too much the initial cleanups as he took me a while to find a working path to redo XICS.
Thanks,
C.
PATCH v2 5/22 ppc/xics: introduce a QOM interface to handle ICSs
In reply to Cédric Le GoaterThis QOM interface provides two simple handlers. One is to get an ICS object from an irq number and a second to resend the irqs when needed.
--- hw/intc/xics.c | 7 +++++++ include/hw/ppc/xics.h | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+)
hw/intc/xics.c +7 -0
@@ -726,6 +726,12 @@ static const TypeInfo ics_base_info = { .class_size = sizeof(ICSStateClass), }; +static const TypeInfo xics_interface_info = { + .name =TYPE_XICS_INTERFACE , + .parent =TYPE_INTERFACE , + .class_size =sizeof (XICSInterfaceClass), +}; +/* * Exported functions */
@@ -766,6 +772,7 @@ static void xics_register_types(void)type_register_static (&ics_simple_info);type_register_static (&ics_base_info);type_register_static (&icp_info); +type_register_static (&xics_interface_info); }type_init (xics_register_types)
include/hw/ppc/xics.h +18 -0
@@ -177,6 +177,24 @@ struct ICSIRQState {uint8_t flags; }; +typedef struct XICSInterface { +Object parent; +}XICSInterface ; + +#define TYPE_XICS_INTERFACE "xics-interface" +#define XICS_INTERFACE (obj) \ + OBJECT_CHECK(XICSInterface, (obj), TYPE_XICS_INTERFACE) +#define XICS_INTERFACE_CLASS (klass) \ + OBJECT_CLASS_CHECK(XICSInterfaceClass, (klass), TYPE_XICS_INTERFACE) +#define XICS_INTERFACE_GET_CLASS (obj) \ + OBJECT_GET_CLASS(XICSInterfaceClass, (obj), TYPE_XICS_INTERFACE) + +typedef struct XICSInterfaceClass { +InterfaceClass parent; +ICSState *(*ics_get)(XICSInterface *xi,int irq); +void (*ics_resend)(XICSInterface *xi); +}XICSInterfaceClass ; +#define XICS_IRQS_SPAPR 1024qemu_irq xics_get_qirq (XICSState *icp,int irq);
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v2 05/22] ppc/xics: introduce a QOM interface to handle ICSs
Quoted 2 lines · Cédric Le Goater
This QOM interface provides two simple handlers. One is to get an ICS object from an irq number and a second to resend the irqs when needed.
Maybe call this XICSFabric rather than XicsInterface. While it's an interface from the QOM point-of-view, that doesn't really describe where it sits in the hardware model, and it's the ics and icp objects which provide all the interfaces which are visible to the guest or to interrupt generating devices.
Apart from that,
Quoted 60 lines
Signed-off-by Cédric Le Goater <[email protected]>--- hw/intc/xics.c | 7 +++++++ include/hw/ppc/xics.h | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+)hw/intc/xics.c +7
-0@@ -726,6 +726,12 @@ static const TypeInfo ics_base_info = { .class_size = sizeof(ICSStateClass), }; +static const TypeInfo xics_interface_info = { + .name =TYPE_XICS_INTERFACE , + .parent =TYPE_INTERFACE , + .class_size =sizeof (XICSInterfaceClass), +}; +/* * Exported functions */ @@ -766,6 +772,7 @@ static void xics_register_types(void)type_register_static (&ics_simple_info);type_register_static (&ics_base_info);type_register_static (&icp_info); +type_register_static (&xics_interface_info); }type_init (xics_register_types)include/hw/ppc/xics.h +18
-0@@ -177,6 +177,24 @@ struct ICSIRQState {uint8_t flags; }; +typedef struct XICSInterface { +Object parent; +}XICSInterface ; + +#define TYPE_XICS_INTERFACE "xics-interface" +#define XICS_INTERFACE (obj) \ + OBJECT_CHECK(XICSInterface, (obj), TYPE_XICS_INTERFACE) +#define XICS_INTERFACE_CLASS (klass) \ + OBJECT_CLASS_CHECK(XICSInterfaceClass, (klass), TYPE_XICS_INTERFACE) +#define XICS_INTERFACE_GET_CLASS (obj) \ + OBJECT_GET_CLASS(XICSInterfaceClass, (obj), TYPE_XICS_INTERFACE) + +typedef struct XICSInterfaceClass { +InterfaceClass parent; +ICSState *(*ics_get)(XICSInterface *xi,int irq); +void (*ics_resend)(XICSInterface *xi); +}XICSInterfaceClass ; +#define XICS_IRQS_SPAPR 1024qemu_irq xics_get_qirq (XICSState *icp,int irq);
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [Qemu-devel] [PATCH v2 05/22] ppc/xics: introduce a QOM interface to handle ICSs
Quoted 9 lines · David Gibson
Quoted 2 lines · Cédric Le Goater
This QOM interface provides two simple handlers. One is to get an ICS object from an irq number and a second to resend the irqs when needed.
Maybe call this XICSFabric rather than XicsInterface. While it's an interface from the QOM point-of-view, that doesn't really describe where it sits in the hardware model, and it's the ics and icp objects which provide all the interfaces which are visible to the guest or to interrupt generating devices.
Curiously, this is the only email that was not trashed by my bogus filters and so this is the only change I did in v3 ...
C.
Quoted 65 lines
Apart from that,
Reviewed-by David Gibson <[email protected]>Quoted 60 lines
Signed-off-by Cédric Le Goater <[email protected]>--- hw/intc/xics.c | 7 +++++++ include/hw/ppc/xics.h | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+)hw/intc/xics.c +7
-0@@ -726,6 +726,12 @@ static const TypeInfo ics_base_info = { .class_size = sizeof(ICSStateClass), }; +static const TypeInfo xics_interface_info = { + .name =TYPE_XICS_INTERFACE , + .parent =TYPE_INTERFACE , + .class_size =sizeof (XICSInterfaceClass), +}; +/* * Exported functions */ @@ -766,6 +772,7 @@ static void xics_register_types(void)type_register_static (&ics_simple_info);type_register_static (&ics_base_info);type_register_static (&icp_info); +type_register_static (&xics_interface_info); }type_init (xics_register_types)include/hw/ppc/xics.h +18
-0@@ -177,6 +177,24 @@ struct ICSIRQState {uint8_t flags; }; +typedef struct XICSInterface { +Object parent; +}XICSInterface ; + +#define TYPE_XICS_INTERFACE "xics-interface" +#define XICS_INTERFACE (obj) \ + OBJECT_CHECK(XICSInterface, (obj), TYPE_XICS_INTERFACE) +#define XICS_INTERFACE_CLASS (klass) \ + OBJECT_CLASS_CHECK(XICSInterfaceClass, (klass), TYPE_XICS_INTERFACE) +#define XICS_INTERFACE_GET_CLASS (obj) \ + OBJECT_GET_CLASS(XICSInterfaceClass, (obj), TYPE_XICS_INTERFACE) + +typedef struct XICSInterfaceClass { +InterfaceClass parent; +ICSState *(*ics_get)(XICSInterface *xi,int irq); +void (*ics_resend)(XICSInterface *xi); +}XICSInterfaceClass ; +#define XICS_IRQS_SPAPR 1024qemu_irq xics_get_qirq (XICSState *icp,int irq);
PATCH v2 6/22 ppc/xics: use the QOM interface under the sPAPR machine
In reply to Cédric Le GoaterAdd 'ics_get' and 'ics_resend' handlers to the sPAPR machine. These are relatively simple for a single ICS.
--- hw/intc/xics.c | 2 +- hw/ppc/spapr.c | 18 ++++++++++++++++++ include/hw/ppc/xics.h | 1 + 3 files changed, 20 insertions(+), 1 deletion(-)
hw/intc/xics.c +1 -1
@@ -193,7 +193,7 @@ static void ics_reject(ICSState *ics, uint32_t nr) } } -static void ics_resend (ICSState *ics) +void ics_resend (ICSState *ics) {ICSStateClass *k =ICS_BASE_GET_CLASS (ics);
hw/ppc/spapr.c +18 -0
@@ -2901,6 +2901,20 @@ static void spapr_phb_placement(sPAPRMachineState *spapr, uint32_t index, *mmio64 =SPAPR_PCI_BASE + (index +1 ) *SPAPR_PCI_MEM64_WIN_SIZE ; } +static ICSState *spapr_ics_get (XICSInterface *dev,int irq) +{ +sPAPRMachineState *spapr =SPAPR_MACHINE (dev); + +return ics_valid_irq (spapr->ics, irq) ? spapr->ics :NULL ; +} + +static void spapr_ics_resend (XICSInterface *dev) +{ +sPAPRMachineState *spapr =SPAPR_MACHINE (dev); + +ics_resend (spapr->ics); +} +static void spapr_machine_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);
@@ -2909,6 +2923,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)NMIClass *nc =NMI_CLASS (oc);HotplugHandlerClass *hc =HOTPLUG_HANDLER_CLASS (oc);PPCVirtualHypervisorClass *vhc =PPC_VIRTUAL_HYPERVISOR_CLASS (oc); +XICSInterfaceClass *xic =XICS_INTERFACE_CLASS (oc); mc->desc ="pSeries Logical Partition (PAPR compliant)" ;
@@ -2942,6 +2957,8 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) nc->nmi_monitor_handler = spapr_nmi; smc->phb_placement = spapr_phb_placement; vhc->hypercall = emulate_spapr_hypercall; + xic->ics_get = spapr_ics_get; + xic->ics_resend = spapr_ics_resend; }static const TypeInfo spapr_machine_info = {
@@ -2958,6 +2975,7 @@ static const TypeInfo spapr_machine_info = { { TYPE_NMI }, { TYPE_HOTPLUG_HANDLER }, { TYPE_PPC_VIRTUAL_HYPERVISOR }, + { TYPE_XICS_INTERFACE }, { } }, };
include/hw/ppc/xics.h +1 -0
@@ -222,5 +222,6 @@ void ics_simple_write_xive(ICSState *ics, int nr, int server,void ics_set_irq_type (ICSState *ics,int srcno,bool lsi);ICSState *xics_find_source (XICSState *icp,int irq); +void ics_resend (ICSState *ics);#endif /* XICS_H */
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v2 06/22] ppc/xics: use the QOM interface under the sPAPR machine
Quoted 4 lines · Cédric Le Goater
Add '
ics_get' and 'ics_resend' handlers to the sPAPR machine. These are relatively simple for a single ICS.Signed-off-by Cédric Le Goater <[email protected]>
Quoted 80 lines
--- hw/intc/xics.c | 2 +- hw/ppc/spapr.c | 18 ++++++++++++++++++ include/hw/ppc/xics.h | 1 + 3 files changed, 20 insertions(+), 1 deletion(-)hw/intc/xics.c +1
-1@@ -193,7 +193,7 @@ static void ics_reject(ICSState *ics, uint32_t nr) } } -static void ics_resend (ICSState *ics) +void ics_resend (ICSState *ics) {ICSStateClass *k =ICS_BASE_GET_CLASS (ics);hw/ppc/spapr.c +18
-0@@ -2901,6 +2901,20 @@ static void spapr_phb_placement(sPAPRMachineState *spapr, uint32_t index, *mmio64 =SPAPR_PCI_BASE + (index +1 ) *SPAPR_PCI_MEM64_WIN_SIZE ; } +static ICSState *spapr_ics_get (XICSInterface *dev,int irq) +{ +sPAPRMachineState *spapr =SPAPR_MACHINE (dev); + +return ics_valid_irq (spapr->ics, irq) ? spapr->ics :NULL ; +} + +static void spapr_ics_resend (XICSInterface *dev) +{ +sPAPRMachineState *spapr =SPAPR_MACHINE (dev); + +ics_resend (spapr->ics); +} +static void spapr_machine_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);@@ -2909,6 +2923,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)NMIClass *nc =NMI_CLASS (oc);HotplugHandlerClass *hc =HOTPLUG_HANDLER_CLASS (oc);PPCVirtualHypervisorClass *vhc =PPC_VIRTUAL_HYPERVISOR_CLASS (oc); +XICSInterfaceClass *xic =XICS_INTERFACE_CLASS (oc); mc->desc ="pSeries Logical Partition (PAPR compliant)" ;@@ -2942,6 +2957,8 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) nc->nmi_monitor_handler = spapr_nmi; smc->phb_placement = spapr_phb_placement; vhc->hypercall = emulate_spapr_hypercall; + xic->ics_get = spapr_ics_get; + xic->ics_resend = spapr_ics_resend; }static const TypeInfo spapr_machine_info = {@@ -2958,6 +2975,7 @@ static const TypeInfo spapr_machine_info = { { TYPE_NMI }, { TYPE_HOTPLUG_HANDLER }, { TYPE_PPC_VIRTUAL_HYPERVISOR }, + { TYPE_XICS_INTERFACE }, { } }, };include/hw/ppc/xics.h +1
-0@@ -222,5 +222,6 @@ void ics_simple_write_xive(ICSState *ics, int nr, int server,void ics_set_irq_type (ICSState *ics,int srcno,bool lsi);ICSState *xics_find_source (XICSState *icp,int irq); +void ics_resend (ICSState *ics);#endif /* XICS_H */
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
PATCH v2 7/22 ppc/xics: use the QOM interface to get irqs
In reply to Cédric Le Goater--- hw/intc/xics.c | 5 +++-- hw/ppc/spapr_events.c | 6 +++--- hw/ppc/spapr_pci.c | 2 +- include/hw/pci-host/spapr.h | 2 +- include/hw/ppc/spapr_vio.h | 2 +- include/hw/ppc/xics.h | 3 ++- 6 files changed, 11 insertions(+), 9 deletions(-)
hw/intc/xics.c +3 -2
@@ -747,9 +747,10 @@ ICSState *xics_find_source(XICSState *xics, int irq)return NULL ; } -qemu_irq xics_get_qirq (XICSState *xics,int irq) +qemu_irq xics_get_qirq (XICSInterface *xi,int irq) { -ICSState *ics =xics_find_source (xics, irq); +XICSInterfaceClass *xic =XICS_INTERFACE_GET_CLASS (xi); +ICSState *ics = xic->ics_get (xi, irq);if (ics) {return ics->qirqs[irq - ics->offset];
hw/ppc/spapr_events.c +3 -3
@@ -481,7 +481,7 @@ static void spapr_powerdown_req(Notifier *n, void *opaque)rtas_event_log_queue (RTAS_LOG_TYPE_EPOW , new_epow, true); -qemu_irq_pulse (xics_get_qirq (spapr->xics, +qemu_irq_pulse (xics_get_qirq (XICS_INTERFACE (spapr),rtas_event_log_to_irq (spapr,RTAS_LOG_TYPE_EPOW ))); }
@@ -574,7 +574,7 @@ static void spapr_hotplug_req_event(uint8_t hp_id, uint8_t hp_action,rtas_event_log_queue (RTAS_LOG_TYPE_HOTPLUG , new_hp, true); -qemu_irq_pulse (xics_get_qirq (spapr->xics, +qemu_irq_pulse (xics_get_qirq (XICS_INTERFACE (spapr),rtas_event_log_to_irq (spapr,RTAS_LOG_TYPE_HOTPLUG ))); }
@@ -695,7 +695,7 @@ static void check_exception(PowerPCCPU *cpu, sPAPRMachineState *spapr,spapr_event_sources_get_source (spapr->event_sources, i);g_assert (source->enabled); -qemu_irq_pulse (xics_get_qirq (spapr->xics, source->irq)); +qemu_irq_pulse (xics_get_qirq (XICS_INTERFACE (spapr), source->irq)); } }
hw/ppc/spapr_pci.c +1 -1
@@ -736,7 +736,7 @@ static void spapr_msi_write(void *opaque, hwaddr addr,trace_spapr_pci_msi_write (addr, data, irq); -qemu_irq_pulse (xics_get_qirq (spapr->xics, irq)); +qemu_irq_pulse (xics_get_qirq (XICS_INTERFACE (spapr), irq)); }static const MemoryRegionOps spapr_msi_ops = {
include/hw/pci-host/spapr.h +1 -1
@@ -106,7 +106,7 @@ static inline qemu_irq spapr_phb_lsi_qirq(struct sPAPRPHBState *phb, int pin) {sPAPRMachineState *spapr =SPAPR_MACHINE (qdev_get_machine ()); -return xics_get_qirq (spapr->xics, phb->lsi_table[pin].irq); +return xics_get_qirq (XICS_INTERFACE (spapr), phb->lsi_table[pin].irq); }PCIHostState *spapr_create_phb (sPAPRMachineState *spapr,int index);
include/hw/ppc/spapr_vio.h +1 -1
@@ -87,7 +87,7 @@ static inline qemu_irq spapr_vio_qirq(VIOsPAPRDevice *dev) {sPAPRMachineState *spapr =SPAPR_MACHINE (qdev_get_machine ()); -return xics_get_qirq (spapr->xics, dev->irq); +return xics_get_qirq (XICS_INTERFACE (spapr), dev->irq); } static inline bool spapr_vio_dma_valid(VIOsPAPRDevice *dev, uint64_t taddr,
include/hw/ppc/xics.h +2 -1
@@ -197,7 +197,8 @@ typedef struct XICSInterfaceClass {#define XICS_IRQS_SPAPR 1024 -qemu_irq xics_get_qirq (XICSState *icp,int irq); +qemu_irq xics_get_qirq (XICSInterface *xi,int irq); +int spapr_ics_alloc (ICSState *ics,int irq_hint,bool lsi,Error **errp);int spapr_ics_alloc_block (ICSState *ics,int num,bool lsi,bool align,Error **errp);
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v2 07/22] ppc/xics: use the QOM interface to get irqs
Quoted 1 line · Cédric Le Goater
Signed-off-by Cédric Le Goater <[email protected]>
Quoted 110 lines
--- hw/intc/xics.c | 5 +++-- hw/ppc/spapr_events.c | 6 +++--- hw/ppc/spapr_pci.c | 2 +- include/hw/pci-host/spapr.h | 2 +- include/hw/ppc/spapr_vio.h | 2 +- include/hw/ppc/xics.h | 3 ++- 6 files changed, 11 insertions(+), 9 deletions(-)hw/intc/xics.c +3
-2@@ -747,9 +747,10 @@ ICSState *xics_find_source(XICSState *xics, int irq)return NULL ; } -qemu_irq xics_get_qirq (XICSState *xics,int irq) +qemu_irq xics_get_qirq (XICSInterface *xi,int irq) { -ICSState *ics =xics_find_source (xics, irq); +XICSInterfaceClass *xic =XICS_INTERFACE_GET_CLASS (xi); +ICSState *ics = xic->ics_get (xi, irq);if (ics) {return ics->qirqs[irq - ics->offset];hw/ppc/spapr_events.c +3
-3@@ -481,7 +481,7 @@ static void spapr_powerdown_req(Notifier *n, void *opaque)rtas_event_log_queue (RTAS_LOG_TYPE_EPOW , new_epow, true); -qemu_irq_pulse (xics_get_qirq (spapr->xics, +qemu_irq_pulse (xics_get_qirq (XICS_INTERFACE (spapr),rtas_event_log_to_irq (spapr,RTAS_LOG_TYPE_EPOW ))); }@@ -574,7 +574,7 @@ static void spapr_hotplug_req_event(uint8_t hp_id, uint8_t hp_action,rtas_event_log_queue (RTAS_LOG_TYPE_HOTPLUG , new_hp, true); -qemu_irq_pulse (xics_get_qirq (spapr->xics, +qemu_irq_pulse (xics_get_qirq (XICS_INTERFACE (spapr),rtas_event_log_to_irq (spapr,RTAS_LOG_TYPE_HOTPLUG ))); }@@ -695,7 +695,7 @@ static void check_exception(PowerPCCPU *cpu, sPAPRMachineState *spapr,spapr_event_sources_get_source (spapr->event_sources, i);g_assert (source->enabled); -qemu_irq_pulse (xics_get_qirq (spapr->xics, source->irq)); +qemu_irq_pulse (xics_get_qirq (XICS_INTERFACE (spapr), source->irq)); } }hw/ppc/spapr_pci.c +1
-1@@ -736,7 +736,7 @@ static void spapr_msi_write(void *opaque, hwaddr addr,trace_spapr_pci_msi_write (addr, data, irq); -qemu_irq_pulse (xics_get_qirq (spapr->xics, irq)); +qemu_irq_pulse (xics_get_qirq (XICS_INTERFACE (spapr), irq)); }static const MemoryRegionOps spapr_msi_ops = {include/hw/pci-host/spapr.h +1
-1@@ -106,7 +106,7 @@ static inline qemu_irq spapr_phb_lsi_qirq(struct sPAPRPHBState *phb, int pin) {sPAPRMachineState *spapr =SPAPR_MACHINE (qdev_get_machine ()); -return xics_get_qirq (spapr->xics, phb->lsi_table[pin].irq); +return xics_get_qirq (XICS_INTERFACE (spapr), phb->lsi_table[pin].irq); }PCIHostState *spapr_create_phb (sPAPRMachineState *spapr,int index);include/hw/ppc/spapr_vio.h +1
-1@@ -87,7 +87,7 @@ static inline qemu_irq spapr_vio_qirq(VIOsPAPRDevice *dev) {sPAPRMachineState *spapr =SPAPR_MACHINE (qdev_get_machine ()); -return xics_get_qirq (spapr->xics, dev->irq); +return xics_get_qirq (XICS_INTERFACE (spapr), dev->irq); } static inline bool spapr_vio_dma_valid(VIOsPAPRDevice *dev, uint64_t taddr,include/hw/ppc/xics.h +2
-1@@ -197,7 +197,8 @@ typedef struct XICSInterfaceClass {#define XICS_IRQS_SPAPR 1024 -qemu_irq xics_get_qirq (XICSState *icp,int irq); +qemu_irq xics_get_qirq (XICSInterface *xi,int irq); +int spapr_ics_alloc (ICSState *ics,int irq_hint,bool lsi,Error **errp);int spapr_ics_alloc_block (ICSState *ics,int num,bool lsi,bool align,Error **errp);
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
PATCH v2 8/22 ppc/xics: use the QOM interface to resend irqs
In reply to Cédric Le Goater--- hw/intc/xics.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-)
hw/intc/xics.c +14 -12
@@ -229,16 +229,15 @@ static void icp_check_ipi(ICPState *ss)qemu_irq_raise (ss->output); } -static void icp_resend (ICPState *ss) +static void icp_resend (XICSInterface *xi,ICPState *ss) { -ICSState *ics; +XICSInterfaceClass *xic =XICS_INTERFACE_GET_CLASS (xi);if (ss->mfrr <CPPR (ss)) {icp_check_ipi (ss); } - QLIST_FOREACH(ics, &ss->xics->ics, list) { -ics_resend (ics); - } + + xic->ics_resend (xi); }void icp_set_cppr (ICPState *ss,uint8_t cppr)
@@ -262,7 +261,7 @@ void icp_set_cppr(ICPState *ss, uint8_t cppr) } }else {if (!XISR (ss)) { -icp_resend (ss); +icp_resend (XICS_INTERFACE (qdev_get_machine ()), ss); } } }
@@ -299,6 +298,8 @@ uint32_t icp_ipoll(ICPState *ss, uint32_t *mfrr)void icp_eoi (ICPState *ss,uint32_t xirr) { +XICSInterface *xi =XICS_INTERFACE (qdev_get_machine ()); +XICSInterfaceClass *xic =XICS_INTERFACE_GET_CLASS (xi);ICSState *ics;uint32_t irq;
@@ -306,13 +307,13 @@ void icp_eoi(ICPState *ss, uint32_t xirr) ss->xirr = (ss->xirr & ~CPPR_MASK ) | (xirr &CPPR_MASK );trace_xics_icp_eoi (ss->cs->cpu_index, xirr, ss->xirr); irq = xirr &XISR_MASK ; - QLIST_FOREACH(ics, &ss->xics->ics, list) { -if (ics_valid_irq (ics, irq)) { -ics_eoi (ics, irq); - } + + ics = xic->ics_get (xi, irq); +if (ics) { +ics_eoi (ics, irq); }if (!XISR (ss)) { -icp_resend (ss); +icp_resend (xi, ss); } }
@@ -592,10 +593,11 @@ static void ics_simple_reset(DeviceState *dev)static int ics_simple_post_load (ICSState *ics,int version_id) { +XICSInterface *xi =XICS_INTERFACE (qdev_get_machine ());int i;for (i =0 ; i < ics->xics->nr_servers; i++) { -icp_resend (&ics->xics->ss[i]); +icp_resend (xi, &ics->xics->ss[i]); }return 0 ;
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v2 08/22] ppc/xics: use the QOM interface to resend irqs
Quoted 31 lines · Cédric Le Goater
Signed-off-by Cédric Le Goater <[email protected]>--- hw/intc/xics.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-)hw/intc/xics.c +4
-5@@ -229,16 +229,15 @@ static void icp_check_ipi(ICPState *ss)qemu_irq_raise (ss->output); } -static void icp_resend (ICPState *ss) +static void icp_resend (XICSInterface *xi,ICPState *ss) { -ICSState *ics; +XICSInterfaceClass *xic =XICS_INTERFACE_GET_CLASS (xi);if (ss->mfrr <CPPR (ss)) {icp_check_ipi (ss); } - QLIST_FOREACH(ics, &ss->xics->ics, list) { -ics_resend (ics); - } + + xic->ics_resend (xi); }void icp_set_cppr (ICPState *ss,uint8_t cppr)
hw/intc/xics.c void icp_set_cppr(ICPState *ss, uint8_t cppr) · line 264
Quoted 5 lines
hw/intc/xics.c +1
-1@@ -262,7 +261,7 @@ void icp_set_cppr(ICPState *ss, uint8_t cppr) } }else {if (!XISR (ss)) { -icp_resend (ss); +icp_resend (XICS_INTERFACE (qdev_get_machine ()), ss);
Here you're assuming that the machine is the implementor of the xics interface, which is kinda ugly. The ICP should have a pointer to the xics interface, which will eventually replace the pointer to the overall xics object it has now.
But I haven't read the rest of the series yet, maybe this is just transitional.
Quoted 32 lines
hw/intc/xics.c +7
-5} } }@@ -299,6 +298,8 @@ uint32_t icp_ipoll(ICPState *ss, uint32_t *mfrr)void icp_eoi (ICPState *ss,uint32_t xirr) { +XICSInterface *xi =XICS_INTERFACE (qdev_get_machine ()); +XICSInterfaceClass *xic =XICS_INTERFACE_GET_CLASS (xi);ICSState *ics;uint32_t irq;@@ -306,13 +307,13 @@ void icp_eoi(ICPState *ss, uint32_t xirr) ss->xirr = (ss->xirr & ~CPPR_MASK ) | (xirr &CPPR_MASK );trace_xics_icp_eoi (ss->cs->cpu_index, xirr, ss->xirr); irq = xirr &XISR_MASK ; - QLIST_FOREACH(ics, &ss->xics->ics, list) { -if (ics_valid_irq (ics, irq)) { -ics_eoi (ics, irq); - } + + ics = xic->ics_get (xi, irq); +if (ics) { +ics_eoi (ics, irq); }if (!XISR (ss)) { -icp_resend (ss); +icp_resend (xi, ss); } }
hw/intc/xics.c static void ics_simple_reset(DeviceState *dev) · line 601
Quoted 10 lines
hw/intc/xics.c +2
-1@@ -592,10 +593,11 @@ static void ics_simple_reset(DeviceState *dev)static int ics_simple_post_load (ICSState *ics,int version_id) { +XICSInterface *xi =XICS_INTERFACE (qdev_get_machine ());int i;for (i =0 ; i < ics->xics->nr_servers; i++) { -icp_resend (&ics->xics->ss[i]); +icp_resend (xi, &ics->xics->ss[i]); }
This resend triggering needs to get moved to the xics interface implementor - i.e. the machine. It's actually already broken right now, since it incorrectly relies on the ordering of the ics and icp restore during migration.
Quoted 1 line
hw/intc/xics.c +0
-0return 0 ;
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 08/22] ppc/xics: use the QOM interface to resend irqs
Quoted 30 lines · David Gibson
Quoted 29 lines · Cédric Le Goater
Signed-off-by Cédric Le Goater <[email protected]>--- hw/intc/xics.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-)hw/intc/xics.c +4
-5@@ -229,16 +229,15 @@ static void icp_check_ipi(ICPState *ss)qemu_irq_raise (ss->output); } -static void icp_resend (ICPState *ss) +static void icp_resend (XICSInterface *xi,ICPState *ss) { -ICSState *ics; +XICSInterfaceClass *xic =XICS_INTERFACE_GET_CLASS (xi);if (ss->mfrr <CPPR (ss)) {icp_check_ipi (ss); } - QLIST_FOREACH(ics, &ss->xics->ics, list) { -ics_resend (ics); - } + + xic->ics_resend (xi); }
Quoted 12 lines
hw/intc/xics.c void icp_set_cppr(ICPState *ss, uint8_t cppr) · line 264
Quoted 7 lines
hw/intc/xics.c +1
-1void icp_set_cppr (ICPState *ss,uint8_t cppr)@@ -262,7 +261,7 @@ void icp_set_cppr(ICPState *ss, uint8_t cppr) } }else {if (!XISR (ss)) { -icp_resend (ss); +icp_resend (XICS_INTERFACE (qdev_get_machine ()), ss);Here you're assuming that the machine is the implementor of the xics interface, which is kinda ugly. The ICP should have a pointer to the xics interface, which will eventually replace the pointer to the overall xics object it has now.
yes. I will try improve that. I don't like those calls to qdev_get_machine()either.
There are done in a couple of places though, under spapr_cpu_core to get XICS for instance.
Quoted 41 lines
But I haven't read the rest of the series yet, maybe this is just transitional.
Quoted 38 lines
hw/intc/xics.c +8
-5} } }@@ -299,6 +298,8 @@ uint32_t icp_ipoll(ICPState *ss, uint32_t *mfrr)void icp_eoi (ICPState *ss,uint32_t xirr) { +XICSInterface *xi =XICS_INTERFACE (qdev_get_machine ()); +XICSInterfaceClass *xic =XICS_INTERFACE_GET_CLASS (xi);ICSState *ics;uint32_t irq;@@ -306,13 +307,13 @@ void icp_eoi(ICPState *ss, uint32_t xirr) ss->xirr = (ss->xirr & ~CPPR_MASK ) | (xirr &CPPR_MASK );trace_xics_icp_eoi (ss->cs->cpu_index, xirr, ss->xirr); irq = xirr &XISR_MASK ; - QLIST_FOREACH(ics, &ss->xics->ics, list) { -if (ics_valid_irq (ics, irq)) { -ics_eoi (ics, irq); - } + + ics = xic->ics_get (xi, irq); +if (ics) { +ics_eoi (ics, irq); }if (!XISR (ss)) { -icp_resend (ss); +icp_resend (xi, ss); } }@@ -592,10 +593,11 @@ static void ics_simple_reset(DeviceState *dev)static int ics_simple_post_load (ICSState *ics,int version_id) { +XICSInterface *xi =XICS_INTERFACE (qdev_get_machine ());int i;
Quoted 9 lines
hw/intc/xics.c static void ics_simple_reset(DeviceState *dev) · line 601
Quoted 4 lines
hw/intc/xics.c +1
-1for (i =0 ; i < ics->xics->nr_servers; i++) { -icp_resend (&ics->xics->ss[i]); +icp_resend (xi, &ics->xics->ss[i]); }This resend triggering needs to get moved to the xics interface implementor - i.e. the machine. It's actually already broken right now, since it incorrectly relies on the ordering of the ics and icp restore during migration.
I'm adding a icp_resend() handler in patch 12 and using it patch 14. Maybe we can move the post_load() handler out of ICS simple now ?
Thanks,
C.
Quoted 2 lines
Quoted 1 line
hw/intc/xics.c +0
-0return 0 ;
Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 08/22] ppc/xics: use the QOM interface to resend irqs
Quoted 17 lines
Quoted 7 lines
Quoted 7 lines
hw/intc/xics.c +1
-0@@ -592,10 +593,11 @@ static void ics_simple_reset(DeviceState *dev)static int ics_simple_post_load (ICSState *ics,int version_id) { +XICSInterface *xi =XICS_INTERFACE (qdev_get_machine ());int i;Quoted 9 lines
hw/intc/xics.c static void ics_simple_reset(DeviceState *dev) · line 601
Quoted 4 lines
hw/intc/xics.c +1
-1for (i =0 ; i < ics->xics->nr_servers; i++) { -icp_resend (&ics->xics->ss[i]); +icp_resend (xi, &ics->xics->ss[i]); }This resend triggering needs to get moved to the xics interface implementor - i.e. the machine. It's actually already broken right now, since it incorrectly relies on the ordering of the ics and icp restore during migration.
Quoted 2 lines
I'm adding a
icp_resend()handler in patch 12 and using it patch 14. Maybe we can move thepost_load()handler out of ICS simple now ?
Could you give me a little more info on what should be done ? I lack context on this problem.
So should we call :
ICPState *ss = opaque;
ICPStateClass *info = ICP_GET_CLASS(ss);
if (info->post_load) {
return info->post_load(ss, version_id);
}and then
ICSState *ics = opaque;
ICSStateClass *info = ICS_BASE_GET_CLASS(ics);
if (info->post_load) {
return info->post_load(ics, version_id);
}from spapr_post_load() ?
Thanks,
C.
Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 08/22] ppc/xics: use the QOM interface to resend irqs
Quoted 34 lines · Cédric Le Goater
Quoted 17 lines
Quoted 7 lines
Quoted 7 lines
hw/intc/xics.c +1
-0@@ -592,10 +593,11 @@ static void ics_simple_reset(DeviceState *dev)static int ics_simple_post_load (ICSState *ics,int version_id) { +XICSInterface *xi =XICS_INTERFACE (qdev_get_machine ());int i;Quoted 9 lines
hw/intc/xics.c static void ics_simple_reset(DeviceState *dev) · line 601
Quoted 4 lines
hw/intc/xics.c +1
-1for (i =0 ; i < ics->xics->nr_servers; i++) { -icp_resend (&ics->xics->ss[i]); +icp_resend (xi, &ics->xics->ss[i]); }This resend triggering needs to get moved to the xics interface implementor - i.e. the machine. It's actually already broken right now, since it incorrectly relies on the ordering of the ics and icp restore during migration.
Quoted 2 lines
I'm adding a
icp_resend()handler in patch 12 and using it patch 14. Maybe we can move thepost_load()handler out of ICS simple now ?Could you give me a little more info on what should be done ? I lack context on this problem.
So should we call :
ICPState *ss = opaque; ICPStateClass *info = ICP_GET_CLASS(ss); if (info->post_load) { return info->post_load(ss, version_id); }and then
Quoted 8 lines
ICSState *ics = opaque; ICSStateClass *info = ICS_BASE_GET_CLASS(ics); if (info->post_load) { return info->post_load(ics, version_id); }from
spapr_post_load()?
Uh.. now I'm trying to remember what the correct order is. Any part of the post_load which is entirely local to the ics or icp, and doesn't communicate with the other part should remain in a local post-load handler.
The part of the resend which involves interaction between ics and icp should move to the mahine. Because the ics and icp are both descendents of the machine, the migration core does guarantee their local post_lodas will run before the machine's post-load. At the moment however, we require either the ics post_loads to run before the icp or the other way around - I forget which. Because these are "cousin" objects, that order is not guaranteed by the migration core.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 08/22] ppc/xics: use the QOM interface to resend irqs
In reply to Cédric Le GoaterQuoted 44 lines · Cédric Le Goater
Quoted 30 lines · David Gibson
Quoted 29 lines · Cédric Le Goater
Signed-off-by Cédric Le Goater <[email protected]>--- hw/intc/xics.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-)hw/intc/xics.c +4
-5@@ -229,16 +229,15 @@ static void icp_check_ipi(ICPState *ss)qemu_irq_raise (ss->output); } -static void icp_resend (ICPState *ss) +static void icp_resend (XICSInterface *xi,ICPState *ss) { -ICSState *ics; +XICSInterfaceClass *xic =XICS_INTERFACE_GET_CLASS (xi);if (ss->mfrr <CPPR (ss)) {icp_check_ipi (ss); } - QLIST_FOREACH(ics, &ss->xics->ics, list) { -ics_resend (ics); - } + + xic->ics_resend (xi); }Quoted 12 lines
hw/intc/xics.c void icp_set_cppr(ICPState *ss, uint8_t cppr) · line 264
Quoted 7 lines
hw/intc/xics.c +1
-1void icp_set_cppr (ICPState *ss,uint8_t cppr)@@ -262,7 +261,7 @@ void icp_set_cppr(ICPState *ss, uint8_t cppr) } }else {if (!XISR (ss)) { -icp_resend (ss); +icp_resend (XICS_INTERFACE (qdev_get_machine ()), ss);Here you're assuming that the machine is the implementor of the xics interface, which is kinda ugly. The ICP should have a pointer to the xics interface, which will eventually replace the pointer to the overall xics object it has now.
Quoted 5 lines
yes. I will try improve that. I don't like those calls to qdev_get_machine()either.
There are done in a couple of places though, under
spapr_cpu_coreto get XICS for instance.
Right, but I'm happier with it there, in code that's definitely associated with a particular machine, rather than in the xics code which is at least somewhat reusable.
Quoted 62 lines
Quoted 41 lines
But I haven't read the rest of the series yet, maybe this is just transitional.
Quoted 38 lines
hw/intc/xics.c +8
-5} } }@@ -299,6 +298,8 @@ uint32_t icp_ipoll(ICPState *ss, uint32_t *mfrr)void icp_eoi (ICPState *ss,uint32_t xirr) { +XICSInterface *xi =XICS_INTERFACE (qdev_get_machine ()); +XICSInterfaceClass *xic =XICS_INTERFACE_GET_CLASS (xi);ICSState *ics;uint32_t irq;@@ -306,13 +307,13 @@ void icp_eoi(ICPState *ss, uint32_t xirr) ss->xirr = (ss->xirr & ~CPPR_MASK ) | (xirr &CPPR_MASK );trace_xics_icp_eoi (ss->cs->cpu_index, xirr, ss->xirr); irq = xirr &XISR_MASK ; - QLIST_FOREACH(ics, &ss->xics->ics, list) { -if (ics_valid_irq (ics, irq)) { -ics_eoi (ics, irq); - } + + ics = xic->ics_get (xi, irq); +if (ics) { +ics_eoi (ics, irq); }if (!XISR (ss)) { -icp_resend (ss); +icp_resend (xi, ss); } }@@ -592,10 +593,11 @@ static void ics_simple_reset(DeviceState *dev)static int ics_simple_post_load (ICSState *ics,int version_id) { +XICSInterface *xi =XICS_INTERFACE (qdev_get_machine ());int i;Quoted 9 lines
hw/intc/xics.c static void ics_simple_reset(DeviceState *dev) · line 601
Quoted 4 lines
hw/intc/xics.c +1
-1for (i =0 ; i < ics->xics->nr_servers; i++) { -icp_resend (&ics->xics->ss[i]); +icp_resend (xi, &ics->xics->ss[i]); }This resend triggering needs to get moved to the xics interface implementor - i.e. the machine. It's actually already broken right now, since it incorrectly relies on the ordering of the ics and icp restore during migration.
I'm adding a
icp_resend()handler in patch 12 and using it patch 14. Maybe we can move thepost_load()handler out of ICS simple now ?Thanks,
C.
Quoted 2 lines
Quoted 1 line
hw/intc/xics.c +0
-0return 0 ;
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 08/22] ppc/xics: use the QOM interface to resend irqs
Quoted 16 lines
Quoted 16 lines
Quoted 4 lines
Quoted 4 lines
void
icp_set_cppr(ICPState *ss, uint8_t cppr)hw/intc/xics.c +0
-0@@ -262,7 +261,7 @@ void icp_set_cppr(ICPState *ss, uint8_t cppr) } }else {Quoted 8 lines
hw/intc/xics.c void icp_set_cppr(ICPState *ss, uint8_t cppr) · line 264
Quoted 3 lines
hw/intc/xics.c +1
-1if (!XISR (ss)) { -icp_resend (ss); +icp_resend (XICS_INTERFACE (qdev_get_machine ()), ss);Here you're assuming that the machine is the implementor of the xics interface, which is kinda ugly. The ICP should have a pointer to the xics interface, which will eventually replace the pointer to the overall xics object it has now.
yes. I will try improve that. I don't like those calls to qdev_get_machine()either.
Quoted 6 lines
Quoted 2 lines
There are done in a couple of places though, under
spapr_cpu_coreto get XICS for instance.Right, but I'm happier with it there, in code that's definitely associated with a particular machine, rather than in the xics code which is at least somewhat reusable.
I fixed that with the backlink on the XICSFabric.
C.
PATCH v2 9/22 ppc/xics: remove xics_find_source()
In reply to Cédric Le GoaterIt is not used anymore now that we have the QOM interface for XICS.
--- hw/intc/xics.c | 12 ------------ include/hw/ppc/xics.h | 1 - 2 files changed, 13 deletions(-)
hw/intc/xics.c +0 -12
@@ -737,18 +737,6 @@ static const TypeInfo xics_interface_info = {/* * Exported functions */ -ICSState *xics_find_source (XICSState *xics,int irq) -{ -ICSState *ics; - - QLIST_FOREACH(ics, &xics->ics, list) { -if (ics_valid_irq (ics, irq)) { -return ics; - } - } -return NULL ; -} -qemu_irq xics_get_qirq (XICSInterface *xi,int irq) {XICSInterfaceClass *xic =XICS_INTERFACE_GET_CLASS (xi);
include/hw/ppc/xics.h +0 -1
@@ -222,7 +222,6 @@ void ics_simple_write_xive(ICSState *ics, int nr, int server,void ics_set_irq_type (ICSState *ics,int srcno,bool lsi); -ICSState *xics_find_source (XICSState *icp,int irq);void ics_resend (ICSState *ics);#endif /* XICS_H */
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v2 09/22] ppc/xics: remove xics_find_source()
Quoted 3 lines · Cédric Le Goater
It is not used anymore now that we have the QOM interface for XICS.
Signed-off-by Cédric Le Goater <[email protected]>
Several of these patches are small enough that I wonder if they could be merged, though.
Quoted 40 lines
--- hw/intc/xics.c | 12 ------------ include/hw/ppc/xics.h | 1 - 2 files changed, 13 deletions(-)hw/intc/xics.c +0
-12@@ -737,18 +737,6 @@ static const TypeInfo xics_interface_info = {/* * Exported functions */ -ICSState *xics_find_source (XICSState *xics,int irq) -{ -ICSState *ics; - - QLIST_FOREACH(ics, &xics->ics, list) { -if (ics_valid_irq (ics, irq)) { -return ics; - } - } -return NULL ; -} -qemu_irq xics_get_qirq (XICSInterface *xi,int irq) {XICSInterfaceClass *xic =XICS_INTERFACE_GET_CLASS (xi);include/hw/ppc/xics.h +0
-1@@ -222,7 +222,6 @@ void ics_simple_write_xive(ICSState *ics, int nr, int server,void ics_set_irq_type (ICSState *ics,int srcno,bool lsi); -ICSState *xics_find_source (XICSState *icp,int irq);void ics_resend (ICSState *ics);#endif /* XICS_H */
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 09/22] ppc/xics: remove xics_find_source()
Quoted 9 lines · David Gibson
Quoted 3 lines · Cédric Le Goater
It is not used anymore now that we have the QOM interface for XICS.
Signed-off-by Cédric Le Goater <[email protected]>Reviewed-by David Gibson <[email protected]>Several of these patches are small enough that I wonder if they could be merged, though.
yes I could probably keep all the removal at the end. I will take a look at that.
Thanks,
C.
Quoted 42 lines
Quoted 41 lines
--- hw/intc/xics.c | 12 ------------ include/hw/ppc/xics.h | 1 - 2 files changed, 13 deletions(-)hw/intc/xics.c +0
-12@@ -737,18 +737,6 @@ static const TypeInfo xics_interface_info = {/* * Exported functions */ -ICSState *xics_find_source (XICSState *xics,int irq) -{ -ICSState *ics; - - QLIST_FOREACH(ics, &xics->ics, list) { -if (ics_valid_irq (ics, irq)) { -return ics; - } - } -return NULL ; -} -qemu_irq xics_get_qirq (XICSInterface *xi,int irq) {XICSInterfaceClass *xic =XICS_INTERFACE_GET_CLASS (xi);include/hw/ppc/xics.h +0
-1@@ -222,7 +222,6 @@ void ics_simple_write_xive(ICSState *ics, int nr, int server,void ics_set_irq_type (ICSState *ics,int srcno,bool lsi); -ICSState *xics_find_source (XICSState *icp,int irq);void ics_resend (ICSState *ics);#endif /* XICS_H */
PATCH v2 10/22 ppc/xics: register the reset handler of ICS objects
In reply to Cédric Le GoaterThe reset of the ICS objects is currently handled by XICS but this can be done for each individual ICS. This also reduces the use of the XICS list of ICS.
--- hw/intc/xics.c | 5 ----- hw/ppc/spapr.c | 1 + 2 files changed, 1 insertion(+), 5 deletions(-)
hw/intc/xics.c +0 -5
@@ -139,16 +139,11 @@ static void ics_simple_pic_print_info(InterruptStatsProvider *obj,static void xics_common_reset (DeviceState *d) {XICSState *xics =XICS_COMMON (d); -ICSState *ics;int i;for (i =0 ; i < xics->nr_servers; i++) {device_reset (DEVICE (&xics->ss[i])); } - - QLIST_FOREACH(ics, &xics->ics, list) { -device_reset (DEVICE (ics)); - } }static void xics_common_initfn (Object *obj)
hw/ppc/spapr.c +1 -0
@@ -112,6 +112,7 @@ static XICSState *try_create_xics(sPAPRMachineState *spapr, } spapr->ics =ICS_SIMPLE (object_new (type_ics)); +qdev_set_parent_bus (DEVICE (spapr->ics),sysbus_get_default ());object_property_add_child (OBJECT (spapr),"ics" ,OBJECT (spapr->ics),NULL );object_property_set_int (OBJECT (spapr->ics), nr_irqs,"nr-irqs" , &err); object_property_add_const_link(OBJECT(spapr->ics), "xics", OBJECT(xics),
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v2 10/22] ppc/xics: register the reset handler of ICS objects
Quoted 5 lines · Cédric Le Goater
The reset of the ICS objects is currently handled by XICS but this can be done for each individual ICS. This also reduces the use of the XICS list of ICS.
Signed-off-by Cédric Le Goater <[email protected]>
Quoted 38 lines
--- hw/intc/xics.c | 5 ----- hw/ppc/spapr.c | 1 + 2 files changed, 1 insertion(+), 5 deletions(-)hw/intc/xics.c +0
-5@@ -139,16 +139,11 @@ static void ics_simple_pic_print_info(InterruptStatsProvider *obj,static void xics_common_reset (DeviceState *d) {XICSState *xics =XICS_COMMON (d); -ICSState *ics;int i;for (i =0 ; i < xics->nr_servers; i++) {device_reset (DEVICE (&xics->ss[i])); } - - QLIST_FOREACH(ics, &xics->ics, list) { -device_reset (DEVICE (ics)); - } }static void xics_common_initfn (Object *obj)hw/ppc/spapr.c +1
-0@@ -112,6 +112,7 @@ static XICSState *try_create_xics(sPAPRMachineState *spapr, } spapr->ics =ICS_SIMPLE (object_new (type_ics)); +qdev_set_parent_bus (DEVICE (spapr->ics),sysbus_get_default ());object_property_add_child (OBJECT (spapr),"ics" ,OBJECT (spapr->ics),NULL );object_property_set_int (OBJECT (spapr->ics), nr_irqs,"nr-irqs" , &err); object_property_add_const_link(OBJECT(spapr->ics), "xics", OBJECT(xics),
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
PATCH v2 11/22 ppc/xics: remove the XICS list of ICS
In reply to Cédric Le GoaterThis is not used anymore.
--- hw/intc/xics.c | 8 -------- hw/ppc/spapr.c | 1 - include/hw/ppc/xics.h | 2 -- 3 files changed, 11 deletions(-)
hw/intc/xics.c +0 -8
@@ -146,13 +146,6 @@ static void xics_common_reset(DeviceState *d) } } -static void xics_common_initfn (Object *obj) -{ -XICSState *xics =XICS_COMMON (obj); - -QLIST_INIT (&xics->ics); -} -static void xics_common_class_init (ObjectClass *oc,void *data) {DeviceClass *dc =DEVICE_CLASS (oc);
@@ -165,7 +158,6 @@ static const TypeInfo xics_common_info = { .parent = TYPE_DEVICE, .instance_size = sizeof(XICSState), .class_size = sizeof(XICSStateClass), - .instance_init = xics_common_initfn, .class_init = xics_common_class_init, };
hw/ppc/spapr.c +0 -1
@@ -122,7 +122,6 @@ static XICSState *try_create_xics(sPAPRMachineState *spapr,if (err) { goto error; } -QLIST_INSERT_HEAD (&xics->ics, spapr->ics, list); xics->ss =g_malloc0 (nr_servers *sizeof (ICPState)); xics->nr_servers = nr_servers;
include/hw/ppc/xics.h +0 -2
@@ -82,7 +82,6 @@ struct XICSState {/*< public >*/ uint32_t nr_servers;ICPState *ss; - QLIST_HEAD(, ICSState) ics; };#define TYPE_ICP "icp"
@@ -152,7 +151,6 @@ struct ICSState {qemu_irq *qirqs;ICSIRQState *irqs;XICSState *xics; -QLIST_ENTRY (ICSState) list; };static inline bool ics_valid_irq (ICSState *ics,uint32_t nr)
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v2 11/22] ppc/xics: remove the XICS list of ICS
Quoted 3 lines · Cédric Le Goater
This is not used anymore.
Signed-off-by Cédric Le Goater <[email protected]>
Quoted 64 lines
--- hw/intc/xics.c | 8 -------- hw/ppc/spapr.c | 1 - include/hw/ppc/xics.h | 2 -- 3 files changed, 11 deletions(-)hw/intc/xics.c +0
-8@@ -146,13 +146,6 @@ static void xics_common_reset(DeviceState *d) } } -static void xics_common_initfn (Object *obj) -{ -XICSState *xics =XICS_COMMON (obj); - -QLIST_INIT (&xics->ics); -} -static void xics_common_class_init (ObjectClass *oc,void *data) {DeviceClass *dc =DEVICE_CLASS (oc);@@ -165,7 +158,6 @@ static const TypeInfo xics_common_info = { .parent = TYPE_DEVICE, .instance_size = sizeof(XICSState), .class_size = sizeof(XICSStateClass), - .instance_init = xics_common_initfn, .class_init = xics_common_class_init, };hw/ppc/spapr.c +0
-1@@ -122,7 +122,6 @@ static XICSState *try_create_xics(sPAPRMachineState *spapr,if (err) { goto error; } -QLIST_INSERT_HEAD (&xics->ics, spapr->ics, list); xics->ss =g_malloc0 (nr_servers *sizeof (ICPState)); xics->nr_servers = nr_servers;include/hw/ppc/xics.h +0
-2@@ -82,7 +82,6 @@ struct XICSState {/*< public >*/ uint32_t nr_servers;ICPState *ss; - QLIST_HEAD(, ICSState) ics; };#define TYPE_ICP "icp"@@ -152,7 +151,6 @@ struct ICSState {qemu_irq *qirqs;ICSIRQState *irqs;XICSState *xics; -QLIST_ENTRY (ICSState) list; };static inline bool ics_valid_irq (ICSState *ics,uint32_t nr)
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
PATCH v2 12/22 ppc/xics: extend the QOM interface to handle ICPs
In reply to Cédric Le GoaterLet's add two new handlers for ICPs. One is to get an ICP object from a server number and a second is to resend the irqs when needed.
--- hw/intc/xics.c | 2 +- hw/ppc/spapr.c | 20 ++++++++++++++++++++ include/hw/ppc/xics.h | 3 +++ 3 files changed, 24 insertions(+), 1 deletion(-)
hw/intc/xics.c +1 -1
@@ -216,7 +216,7 @@ static void icp_check_ipi(ICPState *ss)qemu_irq_raise (ss->output); } -static void icp_resend (XICSInterface *xi,ICPState *ss) +void icp_resend (XICSInterface *xi,ICPState *ss) {XICSInterfaceClass *xic =XICS_INTERFACE_GET_CLASS (xi);
hw/ppc/spapr.c +20 -0
@@ -2915,6 +2915,24 @@ static void spapr_ics_resend(XICSInterface *dev)ics_resend (spapr->ics); } +static ICPState *spapr_icp_get (XICSInterface *xi,int server) +{ +sPAPRMachineState *spapr =SPAPR_MACHINE (xi); + +return (server < spapr->xics->nr_servers) ? &spapr->xics->ss[server] : +NULL ; +} + +static void spapr_icp_resend (XICSInterface *xi) +{ +sPAPRMachineState *spapr =SPAPR_MACHINE (xi); +int i; + +for (i =0 ; i < spapr->xics->nr_servers; i++) { +icp_resend (xi, &spapr->xics->ss[i]); + } +} +static void spapr_machine_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);
@@ -2959,6 +2977,8 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) vhc->hypercall = emulate_spapr_hypercall; xic->ics_get = spapr_ics_get; xic->ics_resend = spapr_ics_resend; + xic->icp_get = spapr_icp_get; + xic->icp_resend = spapr_icp_resend; }static const TypeInfo spapr_machine_info = {
include/hw/ppc/xics.h +3 -0
@@ -191,6 +191,8 @@ typedef struct XICSInterfaceClass {InterfaceClass parent;ICSState *(*ics_get)(XICSInterface *xi,int irq);void (*ics_resend)(XICSInterface *xi); +ICPState *(*icp_get)(XICSInterface *xi,int server); +void (*icp_resend)(XICSInterface *xi); } XICSInterfaceClass;#define XICS_IRQS_SPAPR 1024
@@ -221,5 +223,6 @@ void ics_simple_write_xive(ICSState *ics, int nr, int server,void ics_set_irq_type (ICSState *ics,int srcno,bool lsi);void ics_resend (ICSState *ics); +void icp_resend (XICSInterface *xi,ICPState *ss);#endif /* XICS_H */
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v2 12/22] ppc/xics: extend the QOM interface to handle ICPs
Quoted 38 lines · Cédric Le Goater
Let's add two new handlers for ICPs. One is to get an ICP object from a server number and a second is to resend the irqs when needed.
Signed-off-by Cédric Le Goater <[email protected]>--- hw/intc/xics.c | 2 +- hw/ppc/spapr.c | 20 ++++++++++++++++++++ include/hw/ppc/xics.h | 3 +++ 3 files changed, 24 insertions(+), 1 deletion(-)hw/intc/xics.c +1
-1@@ -216,7 +216,7 @@ static void icp_check_ipi(ICPState *ss)qemu_irq_raise (ss->output); } -static void icp_resend (XICSInterface *xi,ICPState *ss) +void icp_resend (XICSInterface *xi,ICPState *ss) {XICSInterfaceClass *xic =XICS_INTERFACE_GET_CLASS (xi);hw/ppc/spapr.c +7
-0@@ -2915,6 +2915,24 @@ static void spapr_ics_resend(XICSInterface *dev)ics_resend (spapr->ics); } +static ICPState *spapr_icp_get (XICSInterface *xi,int server) +{ +sPAPRMachineState *spapr =SPAPR_MACHINE (xi); + +return (server < spapr->xics->nr_servers) ? &spapr->xics->ss[server] : +NULL ; +}
hw/ppc/spapr.c static void spapr_ics_resend(XICSInterface *dev) · line 2934
Quoted 10 lines
hw/ppc/spapr.c +10
-0+ +static void spapr_icp_resend (XICSInterface *xi) +{ +sPAPRMachineState *spapr =SPAPR_MACHINE (xi); +int i; + +for (i =0 ; i < spapr->xics->nr_servers; i++) { +icp_resend (xi, &spapr->xics->ss[i]); + } +}
I'm not quite sure where you plan to use the resend hook. AFAICT all the existing users of this path can do fine using icp_get() then icp_resend() directly.
Quoted 33 lines
hw/ppc/spapr.c +3
-0+static void spapr_machine_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);@@ -2959,6 +2977,8 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) vhc->hypercall = emulate_spapr_hypercall; xic->ics_get = spapr_ics_get; xic->ics_resend = spapr_ics_resend; + xic->icp_get = spapr_icp_get; + xic->icp_resend = spapr_icp_resend; }static const TypeInfo spapr_machine_info = {include/hw/ppc/xics.h +3
-0@@ -191,6 +191,8 @@ typedef struct XICSInterfaceClass {InterfaceClass parent;ICSState *(*ics_get)(XICSInterface *xi,int irq);void (*ics_resend)(XICSInterface *xi); +ICPState *(*icp_get)(XICSInterface *xi,int server); +void (*icp_resend)(XICSInterface *xi); } XICSInterfaceClass;#define XICS_IRQS_SPAPR 1024@@ -221,5 +223,6 @@ void ics_simple_write_xive(ICSState *ics, int nr, int server,void ics_set_irq_type (ICSState *ics,int srcno,bool lsi);void ics_resend (ICSState *ics); +void icp_resend (XICSInterface *xi,ICPState *ss);#endif /* XICS_H */
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 12/22] ppc/xics: extend the QOM interface to handle ICPs
Quoted 45 lines · David Gibson
Quoted 44 lines · Cédric Le Goater
Let's add two new handlers for ICPs. One is to get an ICP object from a server number and a second is to resend the irqs when needed.
Signed-off-by Cédric Le Goater <[email protected]>--- hw/intc/xics.c | 2 +- hw/ppc/spapr.c | 20 ++++++++++++++++++++ include/hw/ppc/xics.h | 3 +++ 3 files changed, 24 insertions(+), 1 deletion(-)hw/intc/xics.c +1
-1@@ -216,7 +216,7 @@ static void icp_check_ipi(ICPState *ss)qemu_irq_raise (ss->output); } -static void icp_resend (XICSInterface *xi,ICPState *ss) +void icp_resend (XICSInterface *xi,ICPState *ss) {XICSInterfaceClass *xic =XICS_INTERFACE_GET_CLASS (xi);hw/ppc/spapr.c +13
-0@@ -2915,6 +2915,24 @@ static void spapr_ics_resend(XICSInterface *dev)ics_resend (spapr->ics); } +static ICPState *spapr_icp_get (XICSInterface *xi,int server) +{ +sPAPRMachineState *spapr =SPAPR_MACHINE (xi); + +return (server < spapr->xics->nr_servers) ? &spapr->xics->ss[server] : +NULL ; +} + +static void spapr_icp_resend (XICSInterface *xi) +{ +sPAPRMachineState *spapr =SPAPR_MACHINE (xi); +int i; +
Quoted 8 lines
hw/ppc/spapr.c static void spapr_ics_resend(XICSInterface *dev) · line 2934
Quoted 4 lines
hw/ppc/spapr.c +4
-0+for (i =0 ; i < spapr->xics->nr_servers; i++) { +icp_resend (xi, &spapr->xics->ss[i]); + } +}I'm not quite sure where you plan to use the resend hook. AFAICT all the existing users of this path can do fine using
icp_get()thenicp_resend()directly.
This is for ics_simple_post_load().
C.
Quoted 35 lines
Quoted 34 lines
hw/ppc/spapr.c +3
-0+static void spapr_machine_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);@@ -2959,6 +2977,8 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) vhc->hypercall = emulate_spapr_hypercall; xic->ics_get = spapr_ics_get; xic->ics_resend = spapr_ics_resend; + xic->icp_get = spapr_icp_get; + xic->icp_resend = spapr_icp_resend; }static const TypeInfo spapr_machine_info = {include/hw/ppc/xics.h +3
-0@@ -191,6 +191,8 @@ typedef struct XICSInterfaceClass {InterfaceClass parent;ICSState *(*ics_get)(XICSInterface *xi,int irq);void (*ics_resend)(XICSInterface *xi); +ICPState *(*icp_get)(XICSInterface *xi,int server); +void (*icp_resend)(XICSInterface *xi); } XICSInterfaceClass;#define XICS_IRQS_SPAPR 1024@@ -221,5 +223,6 @@ void ics_simple_write_xive(ICSState *ics, int nr, int server,void ics_set_irq_type (ICSState *ics,int srcno,bool lsi);void ics_resend (ICSState *ics); +void icp_resend (XICSInterface *xi,ICPState *ss);#endif /* XICS_H */
Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 12/22] ppc/xics: extend the QOM interface to handle ICPs
Quoted 55 lines · Cédric Le Goater
Quoted 45 lines · David Gibson
Quoted 44 lines · Cédric Le Goater
Let's add two new handlers for ICPs. One is to get an ICP object from a server number and a second is to resend the irqs when needed.
Signed-off-by Cédric Le Goater <[email protected]>--- hw/intc/xics.c | 2 +- hw/ppc/spapr.c | 20 ++++++++++++++++++++ include/hw/ppc/xics.h | 3 +++ 3 files changed, 24 insertions(+), 1 deletion(-)hw/intc/xics.c +1
-1@@ -216,7 +216,7 @@ static void icp_check_ipi(ICPState *ss)qemu_irq_raise (ss->output); } -static void icp_resend (XICSInterface *xi,ICPState *ss) +void icp_resend (XICSInterface *xi,ICPState *ss) {XICSInterfaceClass *xic =XICS_INTERFACE_GET_CLASS (xi);hw/ppc/spapr.c +13
-0@@ -2915,6 +2915,24 @@ static void spapr_ics_resend(XICSInterface *dev)ics_resend (spapr->ics); } +static ICPState *spapr_icp_get (XICSInterface *xi,int server) +{ +sPAPRMachineState *spapr =SPAPR_MACHINE (xi); + +return (server < spapr->xics->nr_servers) ? &spapr->xics->ss[server] : +NULL ; +} + +static void spapr_icp_resend (XICSInterface *xi) +{ +sPAPRMachineState *spapr =SPAPR_MACHINE (xi); +int i; +Quoted 8 lines
hw/ppc/spapr.c static void spapr_ics_resend(XICSInterface *dev) · line 2934
Quoted 4 lines
hw/ppc/spapr.c +4
-0+for (i =0 ; i < spapr->xics->nr_servers; i++) { +icp_resend (xi, &spapr->xics->ss[i]); + } +}I'm not quite sure where you plan to use the resend hook. AFAICT all the existing users of this path can do fine using
icp_get()thenicp_resend()directly.
Quoted 1 line
This is for
ics_simple_post_load().
Ah, right. That's the bit that involves co-ordination between ICS and ICP. It should therefore move to the machine (well, xics fabric implementor) so you shouldn't need this callback in the end anyway.
Quoted 39 lines
C.
Quoted 35 lines
Quoted 34 lines
hw/ppc/spapr.c +3
-0+static void spapr_machine_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);@@ -2959,6 +2977,8 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) vhc->hypercall = emulate_spapr_hypercall; xic->ics_get = spapr_ics_get; xic->ics_resend = spapr_ics_resend; + xic->icp_get = spapr_icp_get; + xic->icp_resend = spapr_icp_resend; }static const TypeInfo spapr_machine_info = {include/hw/ppc/xics.h +3
-0@@ -191,6 +191,8 @@ typedef struct XICSInterfaceClass {InterfaceClass parent;ICSState *(*ics_get)(XICSInterface *xi,int irq);void (*ics_resend)(XICSInterface *xi); +ICPState *(*icp_get)(XICSInterface *xi,int server); +void (*icp_resend)(XICSInterface *xi); } XICSInterfaceClass;#define XICS_IRQS_SPAPR 1024@@ -221,5 +223,6 @@ void ics_simple_write_xive(ICSState *ics, int nr, int server,void ics_set_irq_type (ICSState *ics,int srcno,bool lsi);void ics_resend (ICSState *ics); +void icp_resend (XICSInterface *xi,ICPState *ss);#endif /* XICS_H */
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
PATCH v2 13/22 ppc/xics: simplify the cpu_setup() handler
In reply to Cédric Le GoaterThe cpu_setup() handler currently takes a 'XICSState *' argument to grab the kernel ICP file descriptor. This interface can be simplified by using the 'xics' backlink of the ICP object.
This change is also required by subsequent patches which makes use of the QOM interface for XICS.
--- hw/intc/xics.c | 5 +++-- hw/intc/xics_kvm.c | 11 +++-------- include/hw/ppc/xics.h | 2 +- 3 files changed, 7 insertions(+), 11 deletions(-)
hw/intc/xics.c +3 -2
@@ -66,14 +66,15 @@ void xics_cpu_setup(XICSState *xics, PowerPCCPU *cpu)CPUState *cs =CPU (cpu);CPUPPCState *env = &cpu->env;ICPState *ss = &xics->ss[cs->cpu_index]; -XICSStateClass *info =XICS_COMMON_GET_CLASS (xics); +XICSStateClass *info;assert (cs->cpu_index < xics->nr_servers); ss->cs = cs; + info =XICS_COMMON_GET_CLASS (ss->xics);if (info->cpu_setup) { - info->cpu_setup (xics, cpu); + info->cpu_setup (ss, cpu); }switch (PPC_INPUT (env)) {
hw/intc/xics_kvm.c +3 -8
@@ -334,17 +334,12 @@ static const TypeInfo ics_kvm_info = {/* * XICS-KVM */ -static void xics_kvm_cpu_setup (XICSState *xics,PowerPCCPU *cpu) +static void xics_kvm_cpu_setup (ICPState *ss,PowerPCCPU *cpu) { -CPUState *cs; -ICPState *ss; -KVMXICSState *xicskvm =XICS_SPAPR_KVM (xics); +CPUState *cs =CPU (cpu); +KVMXICSState *xicskvm =XICS_SPAPR_KVM (ss->xics);int ret; - cs =CPU (cpu); - ss = &xics->ss[cs->cpu_index]; - -assert (cs->cpu_index < xics->nr_servers);if (xicskvm->kernel_xics_fd ==-1 ) {abort (); }
include/hw/ppc/xics.h +1 -1
@@ -73,7 +73,7 @@ typedef struct ICSIRQState ICSIRQState;struct XICSStateClass {DeviceClass parent_class; -void (*cpu_setup)(XICSState *icp,PowerPCCPU *cpu); +void (*cpu_setup)(ICPState *icp,PowerPCCPU *cpu); };struct XICSState {
Signature · 1 line
2.7.4
PATCH v2 14/22 ppc/xics: use the QOM interface to grab an ICP
In reply to Cédric Le GoaterAlso introduce a xics_icp_get() helper to simplify the changes.
--- hw/intc/xics.c | 31 ++++++++++++++++++------------- hw/intc/xics_spapr.c | 17 +++++++++-------- hw/ppc/spapr_cpu_core.c | 4 ++-- include/hw/ppc/xics.h | 8 ++++---- 4 files changed, 33 insertions(+), 27 deletions(-)
hw/intc/xics.c +18 -13
@@ -49,26 +49,26 @@ int xics_get_cpu_index_by_dt_id(int cpu_dt_id)return -1 ; } -void xics_cpu_destroy (XICSState *xics,PowerPCCPU *cpu) +void xics_cpu_destroy (XICSInterface *xi,PowerPCCPU *cpu) {CPUState *cs =CPU (cpu); -ICPState *ss = &xics->ss[cs->cpu_index]; +ICPState *ss =xics_icp_get (xi, cs->cpu_index); -assert (cs->cpu_index < xics->nr_servers); +assert (ss);assert (cs == ss->cs); ss->output =NULL ; ss->cs =NULL ; } -void xics_cpu_setup (XICSState *xics,PowerPCCPU *cpu) +void xics_cpu_setup (XICSInterface *xi,PowerPCCPU *cpu) {CPUState *cs =CPU (cpu);CPUPPCState *env = &cpu->env; -ICPState *ss = &xics->ss[cs->cpu_index]; +ICPState *ss =xics_icp_get (xi, cs->cpu_index);XICSStateClass *info; -assert (cs->cpu_index < xics->nr_servers); +assert (ss); ss->cs = cs;
@@ -307,8 +307,9 @@ void icp_eoi(ICPState *ss, uint32_t xirr)static void icp_irq (ICSState *ics,int server,int nr,uint8_t priority) { -XICSState *xics = ics->xics; -ICPState *ss = xics->ss + server; +XICSInterface *xi =XICS_INTERFACE (qdev_get_machine ()); +XICSInterfaceClass *xic =XICS_INTERFACE_GET_CLASS (xi); +ICPState *ss = xic->icp_get (xi, server);trace_xics_icp_irq (server, nr, priority);
@@ -582,12 +583,9 @@ static void ics_simple_reset(DeviceState *dev)static int ics_simple_post_load (ICSState *ics,int version_id) {XICSInterface *xi =XICS_INTERFACE (qdev_get_machine ()); -int i; - -for (i =0 ; i < ics->xics->nr_servers; i++) { -icp_resend (xi, &ics->xics->ss[i]); - } +XICSInterfaceClass *xic =XICS_INTERFACE_GET_CLASS (xi); + xic->icp_resend (xi);return 0 ; }
@@ -737,6 +735,13 @@ qemu_irq xics_get_qirq(XICSInterface *xi, int irq)return NULL ; } +ICPState *xics_icp_get (XICSInterface *xi,int server) +{ +XICSInterfaceClass *xic =XICS_INTERFACE_GET_CLASS (xi); + +return xic->icp_get (xi, server); +} +void ics_set_irq_type (ICSState *ics,int srcno,bool lsi) {assert (!(ics->irqs[srcno].flags &XICS_FLAGS_IRQ_MASK ));
hw/intc/xics_spapr.c +9 -8
@@ -44,7 +44,7 @@ static target_ulong h_cppr(PowerPCCPU *cpu, sPAPRMachineState *spapr, target_ulong opcode, target_ulong *args) { CPUState *cs = CPU(cpu); -ICPState *icp = &spapr->xics->ss[cs->cpu_index]; +ICPState *icp =xics_icp_get (XICS_INTERFACE (spapr), cs->cpu_index);target_ulong cppr = args[0 ];icp_set_cppr (icp, cppr);
@@ -56,12 +56,13 @@ static target_ulong h_ipi(PowerPCCPU *cpu, sPAPRMachineState *spapr, {target_ulong server =xics_get_cpu_index_by_dt_id (args[0 ]);target_ulong mfrr = args[1 ]; +ICPState *icp =xics_icp_get (XICS_INTERFACE (spapr), server); -if (server >= spapr->xics->nr_servers) { +if (!icp) {return H_PARAMETER ; } -icp_set_mfrr (spapr->xics->ss + server, mfrr); +icp_set_mfrr (icp, mfrr);return H_SUCCESS ; }
@@ -69,7 +70,7 @@ static target_ulong h_xirr(PowerPCCPU *cpu, sPAPRMachineState *spapr, target_ulong opcode, target_ulong *args) { CPUState *cs = CPU(cpu); -ICPState *icp = &spapr->xics->ss[cs->cpu_index]; +ICPState *icp =xics_icp_get (XICS_INTERFACE (spapr), cs->cpu_index);uint32_t xirr =icp_accept (icp); args[0 ] = xirr;
@@ -80,7 +81,7 @@ static target_ulong h_xirr_x(PowerPCCPU *cpu, sPAPRMachineState *spapr, target_ulong opcode, target_ulong *args) { CPUState *cs = CPU(cpu); -ICPState *icp = &spapr->xics->ss[cs->cpu_index]; +ICPState *icp =xics_icp_get (XICS_INTERFACE (spapr), cs->cpu_index);uint32_t xirr =icp_accept (icp); args[0 ] = xirr;
@@ -92,7 +93,7 @@ static target_ulong h_eoi(PowerPCCPU *cpu, sPAPRMachineState *spapr, target_ulong opcode, target_ulong *args) { CPUState *cs = CPU(cpu); -ICPState *icp = &spapr->xics->ss[cs->cpu_index]; +ICPState *icp =xics_icp_get (XICS_INTERFACE (spapr), cs->cpu_index);target_ulong xirr = args[0 ];icp_eoi (icp, xirr);
@@ -103,7 +104,7 @@ static target_ulong h_ipoll(PowerPCCPU *cpu, sPAPRMachineState *spapr, target_ulong opcode, target_ulong *args) { CPUState *cs = CPU(cpu); -ICPState *icp = &spapr->xics->ss[cs->cpu_index]; +ICPState *icp =xics_icp_get (XICS_INTERFACE (spapr), cs->cpu_index);uint32_t mfrr;uint32_t xirr =icp_ipoll (icp, &mfrr);
@@ -134,7 +135,7 @@ static void rtas_set_xive(PowerPCCPU *cpu, sPAPRMachineState *spapr, server =xics_get_cpu_index_by_dt_id (rtas_ld (args,1 )); priority =rtas_ld (args,2 ); -if (!ics_valid_irq (ics, nr) || (server >= ics->xics->nr_servers) +if (!ics_valid_irq (ics, nr) || !xics_icp_get (XICS_INTERFACE (spapr), server) || (priority >0xff )) {rtas_st (rets,0 ,RTAS_OUT_PARAM_ERROR );return ;
hw/ppc/spapr_cpu_core.c +2 -2
@@ -42,7 +42,7 @@ static void spapr_cpu_destroy(PowerPCCPU *cpu) {sPAPRMachineState *spapr =SPAPR_MACHINE (qdev_get_machine ()); -xics_cpu_destroy (spapr->xics, cpu); +xics_cpu_destroy (XICS_INTERFACE (spapr), cpu);qemu_unregister_reset (spapr_cpu_reset, cpu); }
@@ -76,7 +76,7 @@ static void spapr_cpu_init(sPAPRMachineState *spapr, PowerPCCPU *cpu, cs->numa_node = i; } -xics_cpu_setup (spapr->xics, cpu); +xics_cpu_setup (XICS_INTERFACE (spapr), cpu);qemu_register_reset (spapr_cpu_reset, cpu);spapr_cpu_reset (cpu);
include/hw/ppc/xics.h +4 -4
@@ -197,16 +197,16 @@ typedef struct XICSInterfaceClass {#define XICS_IRQS_SPAPR 1024 -qemu_irq xics_get_qirq (XICSInterface *xi,int irq); -int spapr_ics_alloc (ICSState *ics,int irq_hint,bool lsi,Error **errp);int spapr_ics_alloc_block (ICSState *ics,int num,bool lsi,bool align,Error **errp);void spapr_ics_free (ICSState *ics,int irq,int num);void spapr_dt_xics (XICSState *xics,void *fdt,uint32_t phandle); -void xics_cpu_setup (XICSState *icp,PowerPCCPU *cpu); -void xics_cpu_destroy (XICSState *icp,PowerPCCPU *cpu); +qemu_irq xics_get_qirq (XICSInterface *xi,int irq); +ICPState *xics_icp_get (XICSInterface *xi,int server); +void xics_cpu_setup (XICSInterface *xi,PowerPCCPU *cpu); +void xics_cpu_destroy (XICSInterface *xi,PowerPCCPU *cpu);/* Internal XICS interfaces */ int xics_get_cpu_index_by_dt_id (int cpu_dt_id);
Signature · 1 line
2.7.4
PATCH v2 15/22 ppc/xics: simplify spapr_dt_xics() interface
In reply to Cédric Le Goaterspapr_dt_xics() only needs the number of servers to build the device tree nodes. Let's change the routine interface to reflect that.
--- hw/intc/xics_spapr.c | 4 ++-- hw/ppc/spapr.c | 2 +- include/hw/ppc/xics.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
hw/intc/xics_spapr.c +2 -2
@@ -387,10 +387,10 @@ void spapr_ics_free(ICSState *ics, int irq, int num) } } -void spapr_dt_xics (XICSState *xics,void *fdt,uint32_t phandle) +void spapr_dt_xics (int nr_servers,void *fdt,uint32_t phandle) {uint32_t interrupt_server_ranges_prop[] = { -0 ,cpu_to_be32 (xics->nr_servers), +0 ,cpu_to_be32 (nr_servers), };int node;
hw/ppc/spapr.c +1 -1
@@ -964,7 +964,7 @@ static void *spapr_build_fdt(sPAPRMachineState *spapr,_FDT (fdt_setprop_cell (fdt,0 ,"#size-cells" ,2 ));/* /interrupt controller */ -spapr_dt_xics (spapr->xics, fdt,PHANDLE_XICP ); +spapr_dt_xics (spapr->xics->nr_servers, fdt,PHANDLE_XICP ); ret =spapr_populate_memory (spapr, fdt);if (ret <0 ) {
include/hw/ppc/xics.h +1 -1
@@ -201,7 +201,7 @@ int spapr_ics_alloc(ICSState *ics, int irq_hint, bool lsi, Error **errp);int spapr_ics_alloc_block (ICSState *ics,int num,bool lsi,bool align,Error **errp);void spapr_ics_free (ICSState *ics,int irq,int num); -void spapr_dt_xics (XICSState *xics,void *fdt,uint32_t phandle); +void spapr_dt_xics (int nr_servers,void *fdt,uint32_t phandle);qemu_irq xics_get_qirq (XICSInterface *xi,int irq);ICPState *xics_icp_get (XICSInterface *xi,int server);
Signature · 1 line
2.7.4
PATCH v2 16/22 ppc/xics: register the reset handler of ICP objects
In reply to Cédric Le GoaterThe reset of the ICP objects is currently handled by XICS but this can be done for each individual ICP.
--- hw/intc/xics.c | 18 ------------------ hw/ppc/spapr.c | 1 + 2 files changed, 1 insertion(+), 18 deletions(-)
hw/intc/xics.c +0 -18
@@ -137,29 +137,11 @@ static void ics_simple_pic_print_info(InterruptStatsProvider *obj,/* * XICS Common class - parent for emulated XICS and KVM-XICS */ -static void xics_common_reset (DeviceState *d) -{ -XICSState *xics =XICS_COMMON (d); -int i; - -for (i =0 ; i < xics->nr_servers; i++) { -device_reset (DEVICE (&xics->ss[i])); - } -} - -static void xics_common_class_init (ObjectClass *oc,void *data) -{ -DeviceClass *dc =DEVICE_CLASS (oc); - - dc->reset = xics_common_reset; -} -static const TypeInfo xics_common_info = { .name =TYPE_XICS_COMMON , .parent =TYPE_DEVICE , .instance_size =sizeof (XICSState), .class_size =sizeof (XICSStateClass), - .class_init = xics_common_class_init, };/*
hw/ppc/spapr.c +1 -0
@@ -130,6 +130,7 @@ static XICSState *try_create_xics(sPAPRMachineState *spapr,ICPState *icp = &xics->ss[i];object_initialize (icp,sizeof (*icp), type_icp); +qdev_set_parent_bus (DEVICE (icp),sysbus_get_default ());object_property_add_child (OBJECT (xics),"icp[*]" ,OBJECT (icp),NULL );object_property_add_const_link (OBJECT (icp),"xics" ,OBJECT (xics),NULL );object_property_set_bool (OBJECT (icp), true,"realized" , &err);
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v2 16/22] ppc/xics: register the reset handler of ICP objects
Quoted 4 lines · Cédric Le Goater
The reset of the ICP objects is currently handled by XICS but this can be done for each individual ICP.
Signed-off-by Cédric Le Goater <[email protected]>
Hrm. I think whether device_reset() gets called automatically depends on how the device is wired into the composition tree, and I'm not sure the icps are in the right place for it to work.
This doesn't replace the code in xics_common_reset() so if it does work it means we must have previously been resetting the ICPs twice. Is that right?
Quoted 51 lines
--- hw/intc/xics.c | 18 ------------------ hw/ppc/spapr.c | 1 + 2 files changed, 1 insertion(+), 18 deletions(-)hw/intc/xics.c +0
-18@@ -137,29 +137,11 @@ static void ics_simple_pic_print_info(InterruptStatsProvider *obj,/* * XICS Common class - parent for emulated XICS and KVM-XICS */ -static void xics_common_reset (DeviceState *d) -{ -XICSState *xics =XICS_COMMON (d); -int i; - -for (i =0 ; i < xics->nr_servers; i++) { -device_reset (DEVICE (&xics->ss[i])); - } -} - -static void xics_common_class_init (ObjectClass *oc,void *data) -{ -DeviceClass *dc =DEVICE_CLASS (oc); - - dc->reset = xics_common_reset; -} -static const TypeInfo xics_common_info = { .name =TYPE_XICS_COMMON , .parent =TYPE_DEVICE , .instance_size =sizeof (XICSState), .class_size =sizeof (XICSStateClass), - .class_init = xics_common_class_init, };/* hw/ppc/spapr.c +1
-0@@ -130,6 +130,7 @@ static XICSState *try_create_xics(sPAPRMachineState *spapr,ICPState *icp = &xics->ss[i];object_initialize (icp,sizeof (*icp), type_icp); +qdev_set_parent_bus (DEVICE (icp),sysbus_get_default ());object_property_add_child (OBJECT (xics),"icp[*]" ,OBJECT (icp),NULL );object_property_add_const_link (OBJECT (icp),"xics" ,OBJECT (xics),NULL );object_property_set_bool (OBJECT (icp), true,"realized" , &err);
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 16/22] ppc/xics: register the reset handler of ICP objects
Quoted 9 lines · David Gibson
Quoted 4 lines · Cédric Le Goater
The reset of the ICP objects is currently handled by XICS but this can be done for each individual ICP.
Signed-off-by Cédric Le Goater <[email protected]>Hrm. I think whether
device_reset()gets called automatically depends on how the device is wired into the composition tree, and I'm not sure the icps are in the right place for it to work.
reset gets called only if it under sysbus or if you have registered a reset_handler. previously, XICS was a sysbus object so xics_common_reset() was getting called automatically.
Quoted 3 lines
This doesn't replace the code in
xics_common_reset()so if it does work it means we must have previously been resetting the ICPs twice. Is that right?
no. but there has been some confusion with the recent changes on XICS.
What replace the code in xics_common_reset() is :
qdev_set_parent_bus(DEVICE(icp), sysbus_get_default());
That's how the reset handlers get called from QOM objects.
C.
Quoted 52 lines
Quoted 51 lines
--- hw/intc/xics.c | 18 ------------------ hw/ppc/spapr.c | 1 + 2 files changed, 1 insertion(+), 18 deletions(-)hw/intc/xics.c +0
-18@@ -137,29 +137,11 @@ static void ics_simple_pic_print_info(InterruptStatsProvider *obj,/* * XICS Common class - parent for emulated XICS and KVM-XICS */ -static void xics_common_reset (DeviceState *d) -{ -XICSState *xics =XICS_COMMON (d); -int i; - -for (i =0 ; i < xics->nr_servers; i++) { -device_reset (DEVICE (&xics->ss[i])); - } -} - -static void xics_common_class_init (ObjectClass *oc,void *data) -{ -DeviceClass *dc =DEVICE_CLASS (oc); - - dc->reset = xics_common_reset; -} -static const TypeInfo xics_common_info = { .name =TYPE_XICS_COMMON , .parent =TYPE_DEVICE , .instance_size =sizeof (XICSState), .class_size =sizeof (XICSStateClass), - .class_init = xics_common_class_init, };/* hw/ppc/spapr.c +1
-0@@ -130,6 +130,7 @@ static XICSState *try_create_xics(sPAPRMachineState *spapr,ICPState *icp = &xics->ss[i];object_initialize (icp,sizeof (*icp), type_icp); +qdev_set_parent_bus (DEVICE (icp),sysbus_get_default ());object_property_add_child (OBJECT (xics),"icp[*]" ,OBJECT (icp),NULL );object_property_add_const_link (OBJECT (icp),"xics" ,OBJECT (xics),NULL );object_property_set_bool (OBJECT (icp), true,"realized" , &err);
Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 16/22] ppc/xics: register the reset handler of ICP objects
Quoted 7 lines · Cédric Le Goater
Quoted 6 lines · David Gibson
Quoted 4 lines · Cédric Le Goater
The reset of the ICP objects is currently handled by XICS but this can be done for each individual ICP.
Signed-off-by Cédric Le Goater <[email protected]>
Quoted 7 lines
Quoted 3 lines
Hrm. I think whether
device_reset()gets called automatically depends on how the device is wired into the composition tree, and I'm not sure the icps are in the right place for it to work.reset gets called only if it under sysbus or if you have registered a
reset_handler. previously, XICS was a sysbus object soxics_common_reset()was getting called automatically.
Right. Hmm. So I think artificially placing the ics under the sysbus is not the right way to get the reset called - I think explicitly registering a reset handler is better.
The only thing that concerns me about that is that the MMIO ICS variants we'll want for powernv really _do_ have a bus presence, either on sysbus or some descendent, so that will get its reset called automatically. I'm not sure what the best way to ensure the reset gets called exactly once in all cases.
Quoted 4 lines
Quoted 3 lines
This doesn't replace the code in
xics_common_reset()so if it does work it means we must have previously been resetting the ICPs twice. Is that right?
Quoted 8 lines
no. but there has been some confusion with the recent changes on XICS.
What replace the code in
xics_common_reset()is :qdev_set_parent_bus(DEVICE(icp), sysbus_get_default());That's how the reset handlers get called from QOM objects.
Right, I saw that later on.
Quoted 56 lines
C.
Quoted 52 lines
Quoted 51 lines
--- hw/intc/xics.c | 18 ------------------ hw/ppc/spapr.c | 1 + 2 files changed, 1 insertion(+), 18 deletions(-)hw/intc/xics.c +0
-18@@ -137,29 +137,11 @@ static void ics_simple_pic_print_info(InterruptStatsProvider *obj,/* * XICS Common class - parent for emulated XICS and KVM-XICS */ -static void xics_common_reset (DeviceState *d) -{ -XICSState *xics =XICS_COMMON (d); -int i; - -for (i =0 ; i < xics->nr_servers; i++) { -device_reset (DEVICE (&xics->ss[i])); - } -} - -static void xics_common_class_init (ObjectClass *oc,void *data) -{ -DeviceClass *dc =DEVICE_CLASS (oc); - - dc->reset = xics_common_reset; -} -static const TypeInfo xics_common_info = { .name =TYPE_XICS_COMMON , .parent =TYPE_DEVICE , .instance_size =sizeof (XICSState), .class_size =sizeof (XICSStateClass), - .class_init = xics_common_class_init, };/* hw/ppc/spapr.c +1
-0@@ -130,6 +130,7 @@ static XICSState *try_create_xics(sPAPRMachineState *spapr,ICPState *icp = &xics->ss[i];object_initialize (icp,sizeof (*icp), type_icp); +qdev_set_parent_bus (DEVICE (icp),sysbus_get_default ());object_property_add_child (OBJECT (xics),"icp[*]" ,OBJECT (icp),NULL );object_property_add_const_link (OBJECT (icp),"xics" ,OBJECT (xics),NULL );object_property_set_bool (OBJECT (icp), true,"realized" , &err);
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 16/22] ppc/xics: register the reset handler of ICP objects
[ adding Peter for some insights ]
Quoted 20 lines · David Gibson
Quoted 7 lines · Cédric Le Goater
Quoted 6 lines · David Gibson
Quoted 4 lines · Cédric Le Goater
The reset of the ICP objects is currently handled by XICS but this can be done for each individual ICP.
Signed-off-by Cédric Le Goater <[email protected]>Quoted 7 lines
Quoted 3 lines
Hrm. I think whether
device_reset()gets called automatically depends on how the device is wired into the composition tree, and I'm not sure the icps are in the right place for it to work.reset gets called only if it under sysbus or if you have registered a
reset_handler. previously, XICS was a sysbus object soxics_common_reset()was getting called automatically.Right. Hmm. So I think artificially placing the ics under the sysbus is not the right way to get the reset called - I think explicitly registering a reset handler is better.
Quoted 5 lines
The only thing that concerns me about that is that the MMIO ICS variants we'll want for powernv really _do_ have a bus presence, either on sysbus or some descendent, so that will get its reset called automatically. I'm not sure what the best way to ensure the reset gets called exactly once in all cases.
Well, I am not sure either. I have reproduced this pattern as it is frequently used under ARM which has quite a few QOM'ified machines.
Thanks,
C.
Quoted 72 lines
Quoted 4 lines
Quoted 3 lines
This doesn't replace the code in
xics_common_reset()so if it does work it means we must have previously been resetting the ICPs twice. Is that right?Quoted 8 lines
no. but there has been some confusion with the recent changes on XICS.
What replace the code in
xics_common_reset()is :qdev_set_parent_bus(DEVICE(icp), sysbus_get_default());That's how the reset handlers get called from QOM objects.
Right, I saw that later on.
Quoted 56 lines
C.
Quoted 52 lines
Quoted 51 lines
--- hw/intc/xics.c | 18 ------------------ hw/ppc/spapr.c | 1 + 2 files changed, 1 insertion(+), 18 deletions(-)hw/intc/xics.c +0
-18@@ -137,29 +137,11 @@ static void ics_simple_pic_print_info(InterruptStatsProvider *obj,/* * XICS Common class - parent for emulated XICS and KVM-XICS */ -static void xics_common_reset (DeviceState *d) -{ -XICSState *xics =XICS_COMMON (d); -int i; - -for (i =0 ; i < xics->nr_servers; i++) { -device_reset (DEVICE (&xics->ss[i])); - } -} - -static void xics_common_class_init (ObjectClass *oc,void *data) -{ -DeviceClass *dc =DEVICE_CLASS (oc); - - dc->reset = xics_common_reset; -} -static const TypeInfo xics_common_info = { .name =TYPE_XICS_COMMON , .parent =TYPE_DEVICE , .instance_size =sizeof (XICSState), .class_size =sizeof (XICSStateClass), - .class_init = xics_common_class_init, };/* hw/ppc/spapr.c +1
-0@@ -130,6 +130,7 @@ static XICSState *try_create_xics(sPAPRMachineState *spapr,ICPState *icp = &xics->ss[i];object_initialize (icp,sizeof (*icp), type_icp); +qdev_set_parent_bus (DEVICE (icp),sysbus_get_default ());object_property_add_child (OBJECT (xics),"icp[*]" ,OBJECT (icp),NULL );object_property_add_const_link (OBJECT (icp),"xics" ,OBJECT (xics),NULL );object_property_set_bool (OBJECT (icp), true,"realized" , &err);
PATCH v2 17/22 ppc/xics: move the ICP array under the sPAPR machine
In reply to Cédric Le Goater--- hw/ppc/spapr.c | 17 ++++++++--------- include/hw/ppc/spapr.h | 3 +++ include/hw/ppc/xics.h | 2 -- 3 files changed, 11 insertions(+), 11 deletions(-)
hw/ppc/spapr.c +8 -9
@@ -123,15 +123,15 @@ static XICSState *try_create_xics(sPAPRMachineState *spapr, goto error; } - xics->ss =g_malloc0 (nr_servers *sizeof (ICPState)); - xics->nr_servers = nr_servers; + spapr->icps =g_malloc0 (nr_servers *sizeof (ICPState)); + spapr->nr_servers = nr_servers;for (i =0 ; i < nr_servers; i++) { -ICPState *icp = &xics->ss[i]; +ICPState *icp = &spapr->icps[i];object_initialize (icp,sizeof (*icp), type_icp);qdev_set_parent_bus (DEVICE (icp),sysbus_get_default ()); -object_property_add_child (OBJECT (xics),"icp[*]" ,OBJECT (icp),NULL ); +object_property_add_child (OBJECT (spapr),"icp[*]" ,OBJECT (icp),NULL );object_property_add_const_link (OBJECT (icp),"xics" ,OBJECT (xics),NULL );object_property_set_bool (OBJECT (icp), true,"realized" , &err);if (err) {
@@ -965,7 +965,7 @@ static void *spapr_build_fdt(sPAPRMachineState *spapr,_FDT (fdt_setprop_cell (fdt,0 ,"#size-cells" ,2 ));/* /interrupt controller */ -spapr_dt_xics (spapr->xics->nr_servers, fdt,PHANDLE_XICP ); +spapr_dt_xics (spapr->nr_servers, fdt,PHANDLE_XICP ); ret =spapr_populate_memory (spapr, fdt);if (ret <0 ) {
@@ -2920,8 +2920,7 @@ static ICPState *spapr_icp_get(XICSInterface *xi, int server) {sPAPRMachineState *spapr =SPAPR_MACHINE (xi); -return (server < spapr->xics->nr_servers) ? &spapr->xics->ss[server] : -NULL ; +return (server < spapr->nr_servers) ? &spapr->icps[server] :NULL ; }static void spapr_icp_resend (XICSInterface *xi)
@@ -2929,8 +2928,8 @@ static void spapr_icp_resend(XICSInterface *xi)sPAPRMachineState *spapr =SPAPR_MACHINE (xi);int i; -for (i =0 ; i < spapr->xics->nr_servers; i++) { -icp_resend (xi, &spapr->xics->ss[i]); +for (i =0 ; i < spapr->nr_servers; i++) { +icp_resend (xi, &spapr->icps[i]); } }
include/hw/ppc/spapr.h +3 -0
@@ -95,6 +95,9 @@ struct sPAPRMachineState {/*< public >*/ char *kvm_type;MemoryHotplugState hotplug_memory; + +uint32_t nr_servers; +ICPState *icps; };#define H_SUCCESS 0
include/hw/ppc/xics.h +0 -2
@@ -80,8 +80,6 @@ struct XICSState {/*< private >*/ SysBusDevice parent_obj;/*< public >*/ -uint32_t nr_servers; -ICPState *ss; };#define TYPE_ICP "icp"
Signature · 1 line
2.7.4
PATCH v2 18/22 ppc/xics: move kernel_xics_fd out of KVMXICSState
In reply to Cédric Le GoaterThe kernel ICP file descriptor is the only reason behind the KVMXICSState class and it's in the way of more cleanups. Let's make it a static for the moment and move forward.
If this is problem, we could use an attribute under the sPAPR machine later on.
--- hw/intc/xics_kvm.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
hw/intc/xics_kvm.c +7 -9
@@ -40,6 +40,8 @@#include <sys/ioctl.h> +static int kernel_xics_fd =-1 ; + typedef struct KVMXICSState { XICSState parent_obj;
@@ -145,7 +147,6 @@ static const TypeInfo icp_kvm_info = {*/ static void ics_get_kvm_state (ICSState *ics) { -KVMXICSState *xicskvm =XICS_SPAPR_KVM (ics->xics);uint64_t state;struct kvm_device_attr attr = { .flags =0 ,
@@ -160,7 +161,7 @@ static void ics_get_kvm_state(ICSState *ics) attr.attr = i + ics->offset; - ret =ioctl (xicskvm->kernel_xics_fd,KVM_GET_DEVICE_ATTR , &attr); + ret =ioctl (kernel_xics_fd,KVM_GET_DEVICE_ATTR , &attr);if (ret !=0 ) {error_report ("Unable to retrieve KVM interrupt controller state" " for IRQ %d: %s" , i + ics->offset,strerror (errno));
@@ -204,7 +205,6 @@ static void ics_get_kvm_state(ICSState *ics)static int ics_set_kvm_state (ICSState *ics,int version_id) { -KVMXICSState *xicskvm =XICS_SPAPR_KVM (ics->xics);uint64_t state;struct kvm_device_attr attr = { .flags =0 ,
@@ -238,7 +238,7 @@ static int ics_set_kvm_state(ICSState *ics, int version_id) } } - ret =ioctl (xicskvm->kernel_xics_fd,KVM_SET_DEVICE_ATTR , &attr); + ret =ioctl (kernel_xics_fd,KVM_SET_DEVICE_ATTR , &attr);if (ret !=0 ) {error_report ("Unable to restore KVM interrupt controller state" " for IRQs %d: %s" , i + ics->offset,strerror (errno));
@@ -337,10 +337,9 @@ static const TypeInfo ics_kvm_info = {static void xics_kvm_cpu_setup (ICPState *ss,PowerPCCPU *cpu) {CPUState *cs =CPU (cpu); -KVMXICSState *xicskvm =XICS_SPAPR_KVM (ss->xics);int ret; -if (xicskvm->kernel_xics_fd ==-1 ) { +if (kernel_xics_fd ==-1 ) {abort (); }
@@ -353,7 +352,7 @@ static void xics_kvm_cpu_setup(ICPState *ss, PowerPCCPU *cpu)return ; } - ret =kvm_vcpu_enable_cap (cs,KVM_CAP_IRQ_XICS ,0 , xicskvm->kernel_xics_fd, + ret =kvm_vcpu_enable_cap (cs,KVM_CAP_IRQ_XICS ,0 , kernel_xics_fd,kvm_arch_vcpu_id (cs));if (ret <0 ) { error_report("Unable to connect CPU%ld to kernel XICS: %s",
@@ -374,7 +373,6 @@ static void rtas_dummy(PowerPCCPU *cpu, sPAPRMachineState *spapr,static void xics_kvm_realize (DeviceState *dev,Error **errp) { -KVMXICSState *xicskvm =XICS_SPAPR_KVM (dev);int rc;struct kvm_create_device xics_create_device = { .type =KVM_DEV_TYPE_XICS ,
@@ -423,7 +421,7 @@ static void xics_kvm_realize(DeviceState *dev, Error **errp) goto fail; } - xicskvm->kernel_xics_fd = xics_create_device.fd; + kernel_xics_fd = xics_create_device.fd; kvm_kernel_irqchip = true; kvm_msi_via_irqfd_allowed = true;
Signature · 1 line
2.7.4
PATCH v2 19/22 ppc/xics: move the cpu_setup() handler under the ICPState class
In reply to Cédric Le GoaterThe cpu_setup() handler is currenlty under the XICSState class but it really belongs under ICPState as it is setting up a vCPU.
It makes use of the kernel ICP file descriptor which could be a problem.
--- hw/intc/xics.c | 8 +++---- hw/intc/xics_kvm.c | 58 +++++++++++++++++++++++++-------------------------- include/hw/ppc/xics.h | 3 +-- 3 files changed, 34 insertions(+), 35 deletions(-)
hw/intc/xics.c +4 -4
@@ -66,15 +66,15 @@ void xics_cpu_setup(XICSInterface *xi, PowerPCCPU *cpu)CPUState *cs =CPU (cpu);CPUPPCState *env = &cpu->env;ICPState *ss =xics_icp_get (xi, cs->cpu_index); -XICSStateClass *info; +ICPStateClass *icpc;assert (ss); ss->cs = cs; - info =XICS_COMMON_GET_CLASS (ss->xics); -if (info->cpu_setup) { - info->cpu_setup (ss, cpu); + icpc =ICP_GET_CLASS (ss); +if (icpc->cpu_setup) { + icpc->cpu_setup (ss, cpu); }switch (PPC_INPUT (env)) {
hw/intc/xics_kvm.c +29 -29
84 lines not on this page · raw message
include/hw/ppc/xics.h +1 -2
@@ -72,8 +72,6 @@ typedef struct ICSIRQState ICSIRQState;struct XICSStateClass {DeviceClass parent_class; - -void (*cpu_setup)(ICPState *icp,PowerPCCPU *cpu); };struct XICSState {
@@ -98,6 +96,7 @@ struct ICPStateClass {void (*pre_save)(ICPState *s);int (*post_load)(ICPState *s,int version_id); +void (*cpu_setup)(ICPState *icp,PowerPCCPU *cpu); };struct ICPState {
Signature · 1 line
2.7.4
PATCH v2 20/22 ppc/xics: remove the 'xics' backlinks
In reply to Cédric Le GoaterThese are not used anymore. Do the cleanups
--- hw/intc/xics.c | 28 ---------------------------- hw/intc/xics_kvm.c | 10 ---------- hw/ppc/spapr.c | 3 --- include/hw/ppc/xics.h | 3 --- 4 files changed, 44 deletions(-)
hw/intc/xics.c +0 -28
@@ -360,23 +360,6 @@ static void icp_reset(DeviceState *dev)qemu_set_irq (icp->output,0 ); } -static void icp_realize (DeviceState *dev,Error **errp) -{ -ICPState *icp =ICP (dev); -Object *obj; -Error *err =NULL ; - - obj =object_property_get_link (OBJECT (dev),"xics" , &err); -if (!obj) { -error_setg (errp,"%s: required link 'xics' not found: %s" , - __func__,error_get_pretty (err)); -return ; - } - - icp->xics =XICS_COMMON (obj); -} - -static void icp_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass);
@@ -384,7 +367,6 @@ static void icp_class_init(ObjectClass *klass, void *data) dc->reset = icp_reset; dc->vmsd = &vmstate_icp_server; - dc->realize = icp_realize; ic->print_info = icp_pic_print_info; }
@@ -634,16 +616,6 @@ static void ics_simple_initfn(Object *obj)static void ics_simple_realize (DeviceState *dev,Error **errp) {ICSState *ics =ICS_SIMPLE (dev); -Object *obj; -Error *err =NULL ; - - obj =object_property_get_link (OBJECT (dev),"xics" , &err); -if (!obj) { -error_setg (errp,"%s: required link 'xics' not found: %s" , - __func__,error_get_pretty (err)); -return ; - } - ics->xics =XICS_COMMON (obj);if (!ics->nr_irqs) {error_setg (errp,"Number of interrupts needs to be greater 0" );
hw/intc/xics_kvm.c +0 -10
@@ -323,16 +323,6 @@ static void ics_kvm_reset(DeviceState *dev)static void ics_kvm_realize (DeviceState *dev,Error **errp) {ICSState *ics =ICS_SIMPLE (dev); -Object *obj; -Error *err =NULL ; - - obj =object_property_get_link (OBJECT (dev),"xics" , &err); -if (!obj) { -error_setg (errp,"%s: required link 'xics' not found: %s" , - __func__,error_get_pretty (err)); -return ; - } - ics->xics =XICS_COMMON (obj);if (!ics->nr_irqs) {error_setg (errp,"Number of interrupts needs to be greater 0" );
hw/ppc/spapr.c +0 -3
@@ -115,8 +115,6 @@ static XICSState *try_create_xics(sPAPRMachineState *spapr,qdev_set_parent_bus (DEVICE (spapr->ics),sysbus_get_default ());object_property_add_child (OBJECT (spapr),"ics" ,OBJECT (spapr->ics),NULL );object_property_set_int (OBJECT (spapr->ics), nr_irqs,"nr-irqs" , &err); -object_property_add_const_link (OBJECT (spapr->ics),"xics" ,OBJECT (xics), -NULL );object_property_set_bool (OBJECT (spapr->ics), true,"realized" , &local_err);error_propagate (&err, local_err);if (err) {
@@ -132,7 +130,6 @@ static XICSState *try_create_xics(sPAPRMachineState *spapr,object_initialize (icp,sizeof (*icp), type_icp);qdev_set_parent_bus (DEVICE (icp),sysbus_get_default ());object_property_add_child (OBJECT (spapr),"icp[*]" ,OBJECT (icp),NULL ); -object_property_add_const_link (OBJECT (icp),"xics" ,OBJECT (xics),NULL );object_property_set_bool (OBJECT (icp), true,"realized" , &err);if (err) { goto error;
include/hw/ppc/xics.h +0 -3
@@ -110,8 +110,6 @@ struct ICPState {uint8_t mfrr;qemu_irq output;bool cap_irq_xics_enabled; - -XICSState *xics; };#define TYPE_ICS_BASE "ics-base"
@@ -147,7 +145,6 @@ struct ICSState {uint32_t offset;qemu_irq *qirqs;ICSIRQState *irqs; -XICSState *xics; };static inline bool ics_valid_irq (ICSState *ics,uint32_t nr)
Signature · 1 line
2.7.4
PATCH v2 21/22 ppc/xics: export the XICS init routines
In reply to Cédric Le GoaterThere is nothing left related to the XICS object in the realize functions of the KVMXICSState and XICSState class. So adapt the interfaces to call these routines directly from the sPAPR machine init sequence.
--- hw/intc/xics_kvm.c | 13 +++---------- hw/intc/xics_spapr.c | 11 ++--------- hw/ppc/spapr.c | 4 +++- include/hw/ppc/xics.h | 5 +++++ 4 files changed, 13 insertions(+), 20 deletions(-)
hw/intc/xics_kvm.c +3 -10
@@ -363,7 +363,7 @@ static void rtas_dummy(PowerPCCPU *cpu, sPAPRMachineState *spapr, __func__); } -static void xics_kvm_realize (DeviceState *dev,Error **errp) +int xics_kvm_init (sPAPRMachineState *spapr,Error **errp) {int rc;struct kvm_create_device xics_create_device = {
@@ -419,27 +419,20 @@ static void xics_kvm_realize(DeviceState *dev, Error **errp) kvm_msi_via_irqfd_allowed = true; kvm_gsi_direct_mapping = true; -return ; +return rc; fail:kvmppc_define_rtas_kernel_token (0 ,"ibm,set-xive" );kvmppc_define_rtas_kernel_token (0 ,"ibm,get-xive" );kvmppc_define_rtas_kernel_token (0 ,"ibm,int-on" );kvmppc_define_rtas_kernel_token (0 ,"ibm,int-off" ); -} - -static void xics_kvm_class_init (ObjectClass *oc,void *data) -{ -DeviceClass *dc =DEVICE_CLASS (oc); - - dc->realize = xics_kvm_realize; +return -1 ; }static const TypeInfo xics_spapr_kvm_info = { .name =TYPE_XICS_SPAPR_KVM , .parent =TYPE_XICS_COMMON , .instance_size =sizeof (KVMXICSState), - .class_init = xics_kvm_class_init, };static void xics_kvm_register_types (void )
hw/intc/xics_spapr.c +2 -9
@@ -240,7 +240,7 @@ static void rtas_int_on(PowerPCCPU *cpu, sPAPRMachineState *spapr,rtas_st (rets,0 ,RTAS_OUT_SUCCESS ); } -static void xics_spapr_realize (DeviceState *dev,Error **errp) +int xics_spapr_init (sPAPRMachineState *spapr,Error **errp) {/* Registration of global state belongs into realize */ spapr_rtas_register (RTAS_IBM_SET_XIVE ,"ibm,set-xive" , rtas_set_xive);
@@ -254,13 +254,7 @@ static void xics_spapr_realize(DeviceState *dev, Error **errp)spapr_register_hypercall (H_XIRR_X , h_xirr_x);spapr_register_hypercall (H_EOI , h_eoi);spapr_register_hypercall (H_IPOLL , h_ipoll); -} - -static void xics_spapr_class_init (ObjectClass *oc,void *data) -{ -DeviceClass *dc =DEVICE_CLASS (oc); - - dc->realize = xics_spapr_realize; +return 0 ; }static const TypeInfo xics_spapr_info = {
@@ -268,7 +262,6 @@ static const TypeInfo xics_spapr_info = { .parent = TYPE_XICS_COMMON, .instance_size = sizeof(XICSState), .class_size = sizeof(XICSStateClass), - .class_init = xics_spapr_class_init, };#define ICS_IRQ_FREE (ics, srcno) \
hw/ppc/spapr.c +3 -1
@@ -156,7 +156,8 @@ static XICSState *xics_system_init(MachineState *machine,if (kvm_enabled ()) {Error *err =NULL ; -if (machine_kernel_irqchip_allowed (machine)) { +if (machine_kernel_irqchip_allowed (machine) && + !xics_kvm_init (SPAPR_MACHINE (machine), errp)) { xics =try_create_xics (SPAPR_MACHINE (machine),TYPE_XICS_SPAPR_KVM ,TYPE_ICS_KVM ,TYPE_KVM_ICP , nr_servers, nr_irqs, &err);
@@ -170,6 +171,7 @@ static XICSState *xics_system_init(MachineState *machine, }if (!xics) { +xics_spapr_init (SPAPR_MACHINE (machine), errp); xics =try_create_xics (SPAPR_MACHINE (machine),TYPE_XICS_SPAPR ,TYPE_ICS_SIMPLE ,TYPE_ICP , nr_servers, nr_irqs, errp);
include/hw/ppc/xics.h +5 -0
@@ -219,4 +219,9 @@ void ics_set_irq_type(ICSState *ics, int srcno, bool lsi);void ics_resend (ICSState *ics);void icp_resend (XICSInterface *xi,ICPState *ss); +typedef struct sPAPRMachineState sPAPRMachineState ; + +int xics_kvm_init (sPAPRMachineState *spapr,Error **errp); +int xics_spapr_init (sPAPRMachineState *spapr,Error **errp); +#endif /* XICS_H */
Signature · 1 line
2.7.4
PATCH v2 22/22 ppc/xics: remove the XICSState classes
In reply to Cédric Le GoaterThese classed are not used anymore. They have been deprecated by the QOM interface. Do the cleanups.
--- hw/intc/xics.c | 11 ----------- hw/intc/xics_kvm.c | 13 ------------- hw/intc/xics_spapr.c | 14 -------------- hw/ppc/spapr.c | 41 +++++++++++++++-------------------------- include/hw/ppc/spapr.h | 1 - include/hw/ppc/xics.h | 35 ----------------------------------- 6 files changed, 15 insertions(+), 100 deletions(-)
hw/intc/xics.c +0 -11
@@ -135,16 +135,6 @@ static void ics_simple_pic_print_info(InterruptStatsProvider *obj, }/* -* XICS Common class - parent for emulated XICS and KVM-XICS -*/ -static const TypeInfo xics_common_info = { - .name =TYPE_XICS_COMMON , - .parent =TYPE_DEVICE , - .instance_size =sizeof (XICSState), - .class_size =sizeof (XICSStateClass), -}; - -/* * ICP: Presentation layer */
@@ -706,7 +696,6 @@ void ics_set_irq_type(ICSState *ics, int srcno, bool lsi)static void xics_register_types (void ) { -type_register_static (&xics_common_info);type_register_static (&ics_simple_info);type_register_static (&ics_base_info);type_register_static (&icp_info);
hw/intc/xics_kvm.c +0 -13
@@ -42,12 +42,6 @@static int kernel_xics_fd =-1 ; -typedef struct KVMXICSState { -XICSState parent_obj; - -int kernel_xics_fd; -}KVMXICSState ; -/* * ICP-KVM */
@@ -429,15 +423,8 @@ fail:return -1 ; } -static const TypeInfo xics_spapr_kvm_info = { - .name =TYPE_XICS_SPAPR_KVM , - .parent =TYPE_XICS_COMMON , - .instance_size =sizeof (KVMXICSState), -}; -static void xics_kvm_register_types (void ) { -type_register_static (&xics_spapr_kvm_info);type_register_static (&ics_kvm_info);type_register_static (&icp_kvm_info); }
hw/intc/xics_spapr.c +0 -14
@@ -257,13 +257,6 @@ int xics_spapr_init(sPAPRMachineState *spapr, Error **errp)return 0 ; } -static const TypeInfo xics_spapr_info = { - .name =TYPE_XICS_SPAPR , - .parent =TYPE_XICS_COMMON , - .instance_size =sizeof (XICSState), - .class_size =sizeof (XICSStateClass), -}; -#define ICS_IRQ_FREE (ics, srcno) \ (!((ics)->irqs[(srcno)].flags & (XICS_FLAGS_IRQ_MASK)))
@@ -400,10 +393,3 @@ void spapr_dt_xics(int nr_servers, void *fdt, uint32_t phandle)_FDT (fdt_setprop_cell (fdt, node,"linux,phandle" , phandle));_FDT (fdt_setprop_cell (fdt, node,"phandle" , phandle)); } - -static void xics_spapr_register_types (void ) -{ -type_register_static (&xics_spapr_info); -} - -type_init (xics_spapr_register_types)
hw/ppc/spapr.c +15 -26
92 lines not on this page · raw message
include/hw/ppc/spapr.h +0 -1
@@ -58,7 +58,6 @@ struct sPAPRMachineState {struct VIOsPAPRBus *vio_bus; QLIST_HEAD(, sPAPRPHBState) phbs;struct sPAPRNVRAM *nvram; -XICSState *xics;ICSState *ics;DeviceState *rtc;
include/hw/ppc/xics.h +0 -35
@@ -30,29 +30,6 @@#include "hw/sysbus.h" -#define TYPE_XICS_COMMON "xics-common" -#define XICS_COMMON (obj) OBJECT_CHECK(XICSState, (obj), TYPE_XICS_COMMON) - -/* -* Retain xics as the type name to be compatible for migration. Rest all the -* functions, class and variables are renamed as xics_spapr. -*/ -#define TYPE_XICS_SPAPR "xics" -#define XICS_SPAPR (obj) OBJECT_CHECK(XICSState, (obj), TYPE_XICS_SPAPR) - -#define TYPE_XICS_SPAPR_KVM "xics-spapr-kvm" -#define XICS_SPAPR_KVM (obj) \ - OBJECT_CHECK(KVMXICSState, (obj), TYPE_XICS_SPAPR_KVM) - -#define XICS_COMMON_CLASS (klass) \ - OBJECT_CLASS_CHECK(XICSStateClass, (klass), TYPE_XICS_COMMON) -#define XICS_SPAPR_CLASS (klass) \ - OBJECT_CLASS_CHECK(XICSStateClass, (klass), TYPE_XICS_SPAPR) -#define XICS_COMMON_GET_CLASS (obj) \ - OBJECT_GET_CLASS(XICSStateClass, (obj), TYPE_XICS_COMMON) -#define XICS_SPAPR_GET_CLASS (obj) \ - OBJECT_GET_CLASS(XICSStateClass, (obj), TYPE_XICS_SPAPR) -#define XICS_IPI 0x2#define XICS_BUID 0x1#define XICS_IRQ_BASE (XICS_BUID << 12)
@@ -62,24 +39,12 @@* (the kernel implementation supports more but we don't exploit * that yet) */ -typedef struct XICSStateClass XICSStateClass ; -typedef struct XICSState XICSState ;typedef struct ICPStateClass ICPStateClass ;typedef struct ICPState ICPState ;typedef struct ICSStateClass ICSStateClass ;typedef struct ICSState ICSState ;typedef struct ICSIRQState ICSIRQState ; -struct XICSStateClass { -DeviceClass parent_class; -}; - -struct XICSState { -/*< private >*/ -SysBusDevice parent_obj; -/*< public >*/ -}; -#define TYPE_ICP "icp"#define ICP (obj) OBJECT_CHECK(ICPState, (obj), TYPE_ICP)
Signature · 1 line
2.7.4
Quoted 28 lines · Cédric Le Goater
Hello,
The goal behind this series is to simplify the XICS interface by moving back in the machine the way the ICS and ICP objects interact together. It's up to the machine to implement this "fabric" logic by providing a set of handlers of a QOM interface. These handlers are used to grab an ICS or an ICP object and also do irq resends. This idea was suggested by David Gibson.
The patchset is organised as follow. It starts with a preliminary cleanup to get rid of the
set_nr_irqs()andset_nr_servers()handlers. It also moves the creation of the ICS and ICP objects from the XICS object to the sPAPR machine. This simplifies the code significantly and prepares ground for future changes.As the sPAPR machine only makes use of a single ICS, we can store it at the machine level. This lets us remove dependencies on the list of ICS of the XICS object and simplify even more the code for the following changes.
The QOM interface to interact with the ICS and ICP objects is then introduced. These are moved under the machine and cleanups are done accordingly.
Finally, the XICSState classes are removed as they have been deprecated by the QOM interface.
Quoted 5 lines
After the initial cleanups, which are rather big, I have tried to keep the each patch small enough to ease the review and to spot any problem. Each should be bisectable. The tree is available here :
https://github.com/legoater/qemu/tree/ppc-2.9
So, after you posted this, I discover the patch I sent the other day - changing XICS away from a SysBusDevice breaks the postcopy migration test on KVM. I haven't had a chance to debug this yet, so for the time being I've pulled my patch from ppc-for-2.9. I've moved it into a new 'xics-cleanup' branch.
Quoted 50 lines
Thanks,
C.
Changes since v1:
- address the full picture.
Cédric Le Goater (22):
ppc/xics: removeset_nr_irqs()handler from XICSStateClass ppc/xics: removeset_nr_servers()handler from XICSStateClass ppc/xics: store the ICS object under the sPAPR machine ppc/xics: add an InterruptStatsProvider interface to ICS and ICP
objects
ppc/xics: introduce a QOM interface to handle ICSs ppc/xics: use the QOM interface under the sPAPR machine ppc/xics: use the QOM interface to get irqs
ppc/xics: use the QOM interface to resend irqs ppc/xics: removexics_find_source()
ppc/xics: register the reset handler of ICS objects ppc/xics: remove the XICS list of ICS
ppc/xics: extend the QOM interface to handle ICPs ppc/xics: simplify thecpu_setup()handler
ppc/xics: use the QOM interface to grab an ICP ppc/xics: simplifyspapr_dt_xics()interface ppc/xics: register the reset handler of ICP objects ppc/xics: move the ICP array under the sPAPR machine ppc/xics: movekernel_xics_fdout of KVMXICSState ppc/xics: move thecpu_setup()handler under the ICPState class ppc/xics: remove the 'xics' backlinks
ppc/xics: export the XICS init routines
ppc/xics: remove the XICSState classeshw/intc/xics.c | 295 +++++++++++++------------------------------- hw/intc/xics_kvm.c | 154 ++++++----------------- hw/intc/xics_spapr.c | 128 ++++--------------- hw/ppc/spapr.c | 116 +++++++++++++---- hw/ppc/spapr_cpu_core.c | 4 +- hw/ppc/spapr_events.c | 10 +- hw/ppc/spapr_pci.c | 10 +- hw/ppc/spapr_vio.c | 2 +- include/hw/pci-host/spapr.h | 2 +- include/hw/ppc/spapr.h | 5 +- include/hw/ppc/spapr_vio.h | 2 +- include/hw/ppc/xics.h | 93 ++++++-------- 12 files changed, 294 insertions(+), 527 deletions(-)
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Quoted 33 lines · David Gibson
Quoted 32 lines · Cédric Le Goater
Hello,
The goal behind this series is to simplify the XICS interface by moving back in the machine the way the ICS and ICP objects interact together. It's up to the machine to implement this "fabric" logic by providing a set of handlers of a QOM interface. These handlers are used to grab an ICS or an ICP object and also do irq resends. This idea was suggested by David Gibson.
The patchset is organised as follow. It starts with a preliminary cleanup to get rid of the
set_nr_irqs()andset_nr_servers()handlers. It also moves the creation of the ICS and ICP objects from the XICS object to the sPAPR machine. This simplifies the code significantly and prepares ground for future changes.As the sPAPR machine only makes use of a single ICS, we can store it at the machine level. This lets us remove dependencies on the list of ICS of the XICS object and simplify even more the code for the following changes.
The QOM interface to interact with the ICS and ICP objects is then introduced. These are moved under the machine and cleanups are done accordingly.
Finally, the XICSState classes are removed as they have been deprecated by the QOM interface.
After the initial cleanups, which are rather big, I have tried to keep the each patch small enough to ease the review and to spot any problem. Each should be bisectable. The tree is available here :
Quoted 7 lines
Quoted 1 line
https://github.com/legoater/qemu/tree/ppc-2.9So, after you posted this, I discover the patch I sent the other day - changing XICS away from a SysBusDevice breaks the postcopy migration test on KVM. I haven't had a chance to debug this yet, so for the time being I've pulled my patch from ppc-for-2.9. I've moved it into a new 'xics-cleanup' branch.
It is even worse than that, the kernel does not start. This is because the ICS and ICP objects are not reseted anymore and so the mfrr and irq priority values are incorrect : 0x0 instead of 0xFF.
Before that patch, the reset was implicit because the device was a SysBusDevice and all the devices were reseted when the bus was.
Other devices (not on a bus or/and QOM objects) need to register on SysBus to be reseted :
qdev_set_parent_bus(dev, sysbus_get_default());
or use a handler for :
qemu_register_reset()
which will be called by qemu_devices_reset()
I fell into this trap a few times with PowerNV and I should have spotted it before adding my Reviewed-by. Sorry about that.
So, to move on, we can use the fix below (You can merge it in your patch). I also updated my branch with it :
https://github.com/legoater/qemu/commits/ppc-2.9
I have checked that KVM and TCG migration still worked with the patchset and also rebased PowerNV on it. All seem to work. Tell me if you want a resend. The patchset needs some review any how and there should be some comment to address so it might be a bit too early for a resend.
FYI, the xics-cleanup branch has some issue with migration :
qemu-system-ppc64: VQ 0 size 0x80 < last_avail_idx 0x9f9 - used_idx 0x0
qemu-system-ppc64: Failed to load virtio-blk:virtio
qemu-system-ppc64: error while loading state for instance 0x0 of device 'pci@800000020000000:01.0/virtio-blk'
This is most probably a temporary regression, unrelated to XICS though.
Thanks,
C.
Quoted 1 line
From
f01dd87954b818096e4fb8c85265ea71a0075975Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= <[email protected]>
Date: Wed, 22 Feb 2017 10:50:25 +0100
Subject: [PATCH] ppc/xics: fix ICP and ICS reset
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
commit 5b17c7207938 ("xics: XICS should not be a SysBusDevice") changed the nature of the XICS object to be a descendent of TYPE_DEVICE. By doing so, the object is not on a bus and its reset handler is not called anymore. The direct consequence is that the ICP and ICS objects are not correctly initialized and so the IRQ subsystem is broken in the guest.
--- hw/ppc/spapr.c | 1 + include/hw/ppc/xics.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
hw/ppc/spapr.c +1 -0
@@ -104,6 +104,7 @@ static XICSState *try_create_xics(const char *type, int nr_servers, dev =DEVICE (object_new (type));qdev_prop_set_uint32 (dev,"nr_servers" , nr_servers);qdev_prop_set_uint32 (dev,"nr_irqs" , nr_irqs); +qdev_set_parent_bus (dev,sysbus_get_default ());object_property_set_bool (OBJECT (dev), true,"realized" , &err);if (err) {error_propagate (errp, err);
include/hw/ppc/xics.h +1 -1
@@ -80,7 +80,7 @@ struct XICSStateClass {struct XICSState {/*< private >*/ -SysBusDevice parent_obj; +DeviceState parent_obj;/*< public >*/ uint32_t nr_servers;uint32_t nr_irqs;
Signature · 1 line
2.7.4
Quoted 54 lines · Cédric Le Goater
Quoted 33 lines · David Gibson
Quoted 32 lines · Cédric Le Goater
Hello,
The goal behind this series is to simplify the XICS interface by moving back in the machine the way the ICS and ICP objects interact together. It's up to the machine to implement this "fabric" logic by providing a set of handlers of a QOM interface. These handlers are used to grab an ICS or an ICP object and also do irq resends. This idea was suggested by David Gibson.
The patchset is organised as follow. It starts with a preliminary cleanup to get rid of the
set_nr_irqs()andset_nr_servers()handlers. It also moves the creation of the ICS and ICP objects from the XICS object to the sPAPR machine. This simplifies the code significantly and prepares ground for future changes.As the sPAPR machine only makes use of a single ICS, we can store it at the machine level. This lets us remove dependencies on the list of ICS of the XICS object and simplify even more the code for the following changes.
The QOM interface to interact with the ICS and ICP objects is then introduced. These are moved under the machine and cleanups are done accordingly.
Finally, the XICSState classes are removed as they have been deprecated by the QOM interface.
After the initial cleanups, which are rather big, I have tried to keep the each patch small enough to ease the review and to spot any problem. Each should be bisectable. The tree is available here :
Quoted 7 lines
Quoted 1 line
https://github.com/legoater/qemu/tree/ppc-2.9So, after you posted this, I discover the patch I sent the other day - changing XICS away from a SysBusDevice breaks the postcopy migration test on KVM. I haven't had a chance to debug this yet, so for the time being I've pulled my patch from ppc-for-2.9. I've moved it into a new 'xics-cleanup' branch.
It is even worse than that, the kernel does not start. This is because the ICS and ICP objects are not reseted anymore and so the mfrr and irq priority values are incorrect :
0x0instead of0xFF.Before that patch, the reset was implicit because the device was a SysBusDevice and all the devices were reseted when the bus was.
Other devices (not on a bus or/and QOM objects) need to register on SysBus to be reseted :
qdev_set_parent_bus(dev, sysbus_get_default());
Quoted 8 lines
or use a handler for :
qemu_register_reset()which will be called by
qemu_devices_reset()I fell into this trap a few times with PowerNV and I should have spotted it before adding my Reviewed-by. Sorry about that.
Ah! Well, thanks for spotting it now and saving me the debugging.
Quoted 14 lines
So, to move on, we can use the fix below (You can merge it in your patch). I also updated my branch with it :
https://github.com/legoater/qemu/commits/ppc-2.9
I have checked that KVM and TCG migration still worked with the patchset and also rebased PowerNV on it. All seem to work. Tell me if you want a resend. The patchset needs some review any how and there should be some comment to address so it might be a bit too early for a resend.
Quoted 8 lines
FYI, the xics-cleanup branch has some issue with migration :
qemu-system-ppc64: VQ 0 size
0x80<last_avail_idx0x9f9-used_idx0x0
qemu-system-ppc64: Failed to load virtio-blk:virtio
qemu-system-ppc64: error while loading state for instance0x0of device 'pci@800000020000000:01.0/virtio-blk'This is most probably a temporary regression, unrelated to XICS though.
Hmm. I'm lss sure. This series changes the qom paths of ics and icp devices, which I'd expect to mess with migration, though I haven't had a chance to actually check yet.
So, as mentioned in one of my patch comments it hadn't been my intention for the ICS and ICPs to assume that the machine implements the fabric, but rather to replace their current "concrete" xics pointer with a xics interface pointer that would point to the (spapr) machine in practice.
Apart from that I'm pretty happy with the endpoint you reach. I'm a bit less convinced about the path taken to get there. I'm not sure if it's worth the churn of doing this reorg, but I think we'd get there more clearly and with less intermediate abstraction violations if it was done by:
1. Introduce the xics qom interface, but have it implemented by the existing xics object
2. Change the ics and icp to only interact with the xics object via the qom interface
3. Implement the qom interface in the spapr machine
4. Change to spapr directly creating ics and icp objects, pointing back to itself as the xics interface provider
5. Remove the xics concrete object
This also has the advantage that the qom path changing parts are isolated to step (4), meaning problems with migration should be easier to localize.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Quoted 6 lines · David Gibson
Quoted 6 lines
FYI, the xics-cleanup branch has some issue with migration :
qemu-system-ppc64: VQ 0 size
0x80<last_avail_idx0x9f9-used_idx0x0
qemu-system-ppc64: Failed to load virtio-blk:virtio
qemu-system-ppc64: error while loading state for instance0x0of device 'pci@800000020000000:01.0/virtio-blk'
Quoted 6 lines
Quoted 2 lines
This is most probably a temporary regression, unrelated to XICS though.
Hmm. I'm lss sure. This series changes the qom paths of ics and icp devices, which I'd expect to mess with migration, though I haven't had a chance to actually check yet.
Just to be clear, the problem occurs without this patchset. It's inherent to the branch, but you will need the fix on XICS to start the guest.
C.
Quoted 6 lines
Apart from that I'm pretty happy with the endpoint you reach. I'm a bit less convinced about the path taken to get there. I'm not sure if it's worth the churn of doing this reorg, but I think we'd get there more clearly and with less intermediate abstraction violations if it was done by:
Quoted 8 lines
1. Introduce the xics qom interface, but have it implemented by the existing xics object
2. Change the ics and icp to only interact with the xics object via the qom interface
3. Implement the qom interface in the spapr machine
4. Change to spapr directly creating ics and icp objects, pointing back to itself as the xics interface provider
5. Remove the xics concrete object
So that's a full rewrite of the patchset to reach the same point. I can only grumble for such a proposal :/
Quoted 3 lines
This also has the advantage that the qom path changing parts are isolated to step (4), meaning problems with migration should be easier to localize.
and migration works.
C.
Quoted 15 lines · Cédric Le Goater
Quoted 6 lines
Apart from that I'm pretty happy with the endpoint you reach. I'm a bit less convinced about the path taken to get there. I'm not sure if it's worth the churn of doing this reorg, but I think we'd get there more clearly and with less intermediate abstraction violations if it was done by:
Quoted 8 lines
1. Introduce the xics qom interface, but have it implemented by the existing xics object
2. Change the ics and icp to only interact with the xics object via the qom interface
3. Implement the qom interface in the spapr machine
4. Change to spapr directly creating ics and icp objects, pointing back to itself as the xics interface provider
5. Remove the xics concrete object
Quoted 2 lines
So that's a full rewrite of the patchset to reach the same point. I can only grumble for such a proposal :/
Yeah.. point taken.
Quoted 5 lines
Quoted 3 lines
This also has the advantage that the qom path changing parts are isolated to step (4), meaning problems with migration should be easier to localize.
and migration works.
Oh, that's a nice surprise. Ok never mind about the rework, just address the other comments and repost.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson