From: Cornelia Huck <cornelia.huck@de.ibm.com>
To: qemu-devel@nongnu.org
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>,
borntraeger@de.ibm.com, jfrei@linux.vnet.ibm.com, agraf@suse.de,
David Hildenbrand <dahi@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH 11/23] s390/sclp: rework sclp event facility initialization + device realization
Date: Mon, 31 Aug 2015 13:13:51 +0200 [thread overview]
Message-ID: <1441019643-10677-12-git-send-email-cornelia.huck@de.ibm.com> (raw)
In-Reply-To: <1441019643-10677-1-git-send-email-cornelia.huck@de.ibm.com>
From: David Hildenbrand <dahi@linux.vnet.ibm.com>
The current code only works by chance. The event facility is a sysbus
device, but specifies in its class structure as parent the DeviceClass
(instead of a device class).
The init function in return lies therefore at the same position as
the init function of SysBusDeviceClass and gets triggered instead -
a very bad idea of doing that (e.g. the parameter types don't match).
Let's bring the initialization code up to date, initializing the event
facility + child events in .instance_init and moving the realization of
the child events out of the init call, into the realization step.
Device realization is now automatically performed when the event facility
itself is realized. That realization implicitly triggers realization of
the child bus, which in turn initializes the events.
Please note that we have to manually propagate the realization of the bus
children, common code still has a TODO set for that task.
Reviewed-by: Matthew Rosato <mjrosato@linux.vnet.ibm.com>
Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
hw/s390x/event-facility.c | 50 ++++++++++++++++++++++++++-------------
include/hw/s390x/event-facility.h | 3 +--
2 files changed, 34 insertions(+), 19 deletions(-)
diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c
index 1ca6544..7b64e78 100644
--- a/hw/s390x/event-facility.c
+++ b/hw/s390x/event-facility.c
@@ -27,12 +27,12 @@ typedef struct SCLPEventsBus {
struct SCLPEventFacility {
SysBusDevice parent_obj;
SCLPEventsBus sbus;
+ SCLPEvent quiesce_event;
+ SCLPEvent cpu_hotplug_event;
/* guest' receive mask */
unsigned int receive_mask;
};
-static SCLPEvent cpu_hotplug;
-
/* return true if any child has event pending set */
static bool event_pending(SCLPEventFacility *ef)
{
@@ -287,8 +287,26 @@ out:
#define TYPE_SCLP_EVENTS_BUS "s390-sclp-events-bus"
+static void sclp_events_bus_realize(BusState *bus, Error **errp)
+{
+ BusChild *kid;
+
+ /* TODO: recursive realization has to be done in common code */
+ QTAILQ_FOREACH(kid, &bus->children, sibling) {
+ DeviceState *dev = kid->child;
+
+ object_property_set_bool(OBJECT(dev), true, "realized", errp);
+ if (*errp) {
+ return;
+ }
+ }
+}
+
static void sclp_events_bus_class_init(ObjectClass *klass, void *data)
{
+ BusClass *bc = BUS_CLASS(klass);
+
+ bc->realize = sclp_events_bus_realize;
}
static const TypeInfo sclp_events_bus_info = {
@@ -325,26 +343,24 @@ static const VMStateDescription vmstate_event_facility = {
}
};
-static int init_event_facility(SCLPEventFacility *event_facility)
+static void init_event_facility(Object *obj)
{
- DeviceState *sdev = DEVICE(event_facility);
- DeviceState *quiesce;
+ SCLPEventFacility *event_facility = EVENT_FACILITY(obj);
+ DeviceState *sdev = DEVICE(obj);
/* Spawn a new bus for SCLP events */
qbus_create_inplace(&event_facility->sbus, sizeof(event_facility->sbus),
TYPE_SCLP_EVENTS_BUS, sdev, NULL);
- quiesce = qdev_create(&event_facility->sbus.qbus, "sclpquiesce");
- if (!quiesce) {
- return -1;
- }
- qdev_init_nofail(quiesce);
-
- object_initialize(&cpu_hotplug, sizeof(cpu_hotplug), TYPE_SCLP_CPU_HOTPLUG);
- qdev_set_parent_bus(DEVICE(&cpu_hotplug), BUS(&event_facility->sbus));
- object_property_set_bool(OBJECT(&cpu_hotplug), true, "realized", NULL);
-
- return 0;
+ object_initialize(&event_facility->quiesce_event, sizeof(SCLPEvent),
+ "sclpquiesce");
+ qdev_set_parent_bus(DEVICE(&event_facility->quiesce_event),
+ &event_facility->sbus.qbus);
+ object_initialize(&event_facility->cpu_hotplug_event, sizeof(SCLPEvent),
+ TYPE_SCLP_CPU_HOTPLUG);
+ qdev_set_parent_bus(DEVICE(&event_facility->cpu_hotplug_event),
+ &event_facility->sbus.qbus);
+ /* the facility will automatically realize the devices via the bus */
}
static void reset_event_facility(DeviceState *dev)
@@ -363,7 +379,6 @@ static void init_event_facility_class(ObjectClass *klass, void *data)
dc->reset = reset_event_facility;
dc->vmsd = &vmstate_event_facility;
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
- k->init = init_event_facility;
k->command_handler = command_handler;
k->event_pending = event_pending;
}
@@ -371,6 +386,7 @@ static void init_event_facility_class(ObjectClass *klass, void *data)
static const TypeInfo sclp_event_facility_info = {
.name = TYPE_SCLP_EVENT_FACILITY,
.parent = TYPE_SYS_BUS_DEVICE,
+ .instance_init = init_event_facility,
.instance_size = sizeof(SCLPEventFacility),
.class_init = init_event_facility_class,
.class_size = sizeof(SCLPEventFacilityClass),
diff --git a/include/hw/s390x/event-facility.h b/include/hw/s390x/event-facility.h
index 871f3e7..eae3b3b 100644
--- a/include/hw/s390x/event-facility.h
+++ b/include/hw/s390x/event-facility.h
@@ -191,8 +191,7 @@ typedef struct SCLPEventClass {
typedef struct SCLPEventFacility SCLPEventFacility;
typedef struct SCLPEventFacilityClass {
- DeviceClass parent_class;
- int (*init)(SCLPEventFacility *ef);
+ SysBusDeviceClass parent_class;
void (*command_handler)(SCLPEventFacility *ef, SCCB *sccb, uint64_t code);
bool (*event_pending)(SCLPEventFacility *ef);
} SCLPEventFacilityClass;
--
2.5.1
next prev parent reply other threads:[~2015-08-31 11:14 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-31 11:13 [Qemu-devel] [PATCH 00/23] s390x: further patches Cornelia Huck
2015-08-31 11:13 ` [Qemu-devel] [PATCH 01/23] s390x/css: handle ccw-0 TIC correctly Cornelia Huck
2015-08-31 11:13 ` [Qemu-devel] [PATCH 02/23] s390x/css: ccw-0 enforces count > 0 Cornelia Huck
2015-08-31 11:13 ` [Qemu-devel] [PATCH 03/23] s390x/event-facility: fix receive mask check Cornelia Huck
2015-08-31 11:13 ` [Qemu-devel] [PATCH 04/23] s390x/css: start with cleared cstat/dstat Cornelia Huck
2015-08-31 11:13 ` [Qemu-devel] [PATCH 05/23] s390x/event-facility: fix location of receive mask Cornelia Huck
2015-08-31 11:13 ` [Qemu-devel] [PATCH 06/23] pc-bios/s390-ccw: Device detection in higher subchannel sets Cornelia Huck
2015-08-31 11:13 ` [Qemu-devel] [PATCH 07/23] pc-bios/s390-ccw: rebuild image Cornelia Huck
2015-08-31 11:13 ` [Qemu-devel] [PATCH 08/23] s390x/kvm: make setting of in-kernel irq routes more efficient Cornelia Huck
2015-08-31 11:13 ` [Qemu-devel] [PATCH 09/23] s390x/gdb: support reading/writing of control registers Cornelia Huck
2015-08-31 11:13 ` [Qemu-devel] [PATCH 10/23] sclp/s390: rework sclp cpu hotplug device notification Cornelia Huck
2015-08-31 11:13 ` Cornelia Huck [this message]
2015-08-31 11:13 ` [Qemu-devel] [PATCH 12/23] s390/sclp: replace sclp event types with proper defines Cornelia Huck
2015-08-31 11:13 ` [Qemu-devel] [PATCH 13/23] s390/sclp: temporarily fix unassignment/reassignment of memory subregions Cornelia Huck
2015-08-31 11:13 ` [Qemu-devel] [PATCH 14/23] s390/sclp: introduce a root sclp device Cornelia Huck
2015-08-31 11:13 ` [Qemu-devel] [PATCH 15/23] s390/sclp: move sclp_execute related functions into the SCLP class Cornelia Huck
2015-08-31 11:13 ` [Qemu-devel] [PATCH 16/23] s390/sclp: move sclp_service_interrupt into the sclp device Cornelia Huck
2015-08-31 11:13 ` [Qemu-devel] [PATCH 17/23] s390: no need to manually parse for slots and maxmem Cornelia Huck
2015-08-31 11:13 ` [Qemu-devel] [PATCH 18/23] s390: disallow memory hotplug for the s390-virtio machine Cornelia Huck
2015-08-31 11:13 ` [Qemu-devel] [PATCH 19/23] s390/sclp: ignore memory hotplug operations if it is disabled Cornelia Huck
2015-08-31 11:14 ` [Qemu-devel] [PATCH 20/23] s390: move memory calculation into the sclp device Cornelia Huck
2015-08-31 11:14 ` [Qemu-devel] [PATCH 21/23] s390: unify allocation of initial memory Cornelia Huck
2015-08-31 11:14 ` [Qemu-devel] [PATCH 22/23] s390/sclp: store the increment_size in the sclp device Cornelia Huck
2015-08-31 11:14 ` [Qemu-devel] [PATCH 23/23] s390/sclp: simplify calculation of rnmax Cornelia Huck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1441019643-10677-12-git-send-email-cornelia.huck@de.ibm.com \
--to=cornelia.huck@de.ibm.com \
--cc=agraf@suse.de \
--cc=borntraeger@de.ibm.com \
--cc=dahi@linux.vnet.ibm.com \
--cc=jfrei@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).