Received: from eggs.gnu.org ([208.118.235.92]:46021) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UUJBP-0005Bl-6V for qemu-devel@nongnu.org; Mon, 22 Apr 2013 12:01:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UUJBI-00079T-4K for qemu-devel@nongnu.org; Mon, 22 Apr 2013 12:01:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48327) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UUJBH-00079B-T7 for qemu-devel@nongnu.org; Mon, 22 Apr 2013 12:01:28 -0400 Date: Mon, 22 Apr 2013 17:59:33 +0200 From: Igor Mammedov Message-ID: <20130422175933.4276970c@nial.usersys.redhat.com> In-Reply-To: <517554E2.7000401@suse.de> References: <1366063976-4909-1-git-send-email-imammedo@redhat.com> <1366063976-4909-15-git-send-email-imammedo@redhat.com> <517554E2.7000401@suse.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 14/16] target-i386: move APIC to ICC bus List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andreas =?ISO-8859-1?B?RuRyYmVy?= Cc: aliguori@us.ibm.com, ehabkost@redhat.com, mst@redhat.com, jan.kiszka@siemens.com, claudio.fontana@huawei.com, qemu-devel@nongnu.org, aderumier@odiso.com, lcapitulino@redhat.com, jfrei@linux.vnet.ibm.com, yang.z.zhang@intel.com, pbonzini@redhat.com, lig.fnst@cn.fujitsu.com, rth@twiddle.net On Mon, 22 Apr 2013 17:18:58 +0200 Andreas F=E4rber wrote: > Am 16.04.2013 00:12, schrieb Igor Mammedov: [...] > > static void icc_bridge_initfn(Object *obj) > > { > > - qbus_create(TYPE_ICC_BUS, DEVICE(obj), "icc-bus"); > > + ICCBridgeState *s =3D ICC_BRIGDE(obj); > > + SysBusDevice *sb =3D SYS_BUS_DEVICE(obj); > > + ICCBus *ibus; > > + > > + ibus =3D ICC_BUS(qbus_create(TYPE_ICC_BUS, DEVICE(obj), "icc-bus")= ); >=20 > qbus_create_inplace() as suggested on ICC patch would allow to access it > through state field. done >=20 > > + > > + /* Do not change order of registering regions, > > + * APIC must be first registered region, board maps it by 0 index > > + */ > > + memory_region_init(&s->apic_container, "icc-apic-container", > > + APIC_SPACE_SIZE); > > + sysbus_init_mmio(sb, &s->apic_container); > > + ibus->apic_address_space =3D &s->apic_container; > > } > > =20 > > static const TypeInfo icc_bridge_info =3D { > > diff --git a/hw/i386/kvmvapic.c b/hw/i386/kvmvapic.c > > index 3a10c07..5b558aa 100644 > > --- a/hw/i386/kvmvapic.c > > +++ b/hw/i386/kvmvapic.c > > @@ -12,6 +12,7 @@ > > #include "sysemu/cpus.h" > > #include "sysemu/kvm.h" > > #include "hw/i386/apic_internal.h" > > +#include "hw/sysbus.h" > > =20 > > #define VAPIC_IO_PORT 0x7e > > =20 >=20 > I take it, this is necessary due to dropping hw/sysbus.h include in > cpu.c? Might be split out then since patch is rather large already. It's due to dropping hw/sysbus.h from include/hw/i386/apic_internal.h It's hard to split in meaningful separate patch. >=20 > > diff --git a/hw/i386/pc.c b/hw/i386/pc.c > > index cb57878..31b5294 100644 > > --- a/hw/i386/pc.c > > +++ b/hw/i386/pc.c > > @@ -52,6 +52,7 @@ > > #include "sysemu/arch_init.h" > > #include "qemu/bitmap.h" > > #include "qemu/config-file.h" > > +#include "hw/i386/icc_bus.h" > > =20 > > /* debug PC/ISA interrupts */ > > //#define DEBUG_IRQ >=20 > > @@ -889,13 +890,13 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, > > int level) } > > } > > =20 > > -static void pc_new_cpu(const char *cpu_model, int64_t apic_id, Error > > **errp) +static X86CPU *pc_new_cpu(const char *cpu_model, int64_t > > apic_id, Error **errp) { > > X86CPU *cpu; > > =20 > > cpu =3D cpu_x86_create(cpu_model, errp); > > if (!cpu) { > > - return; > > + return cpu; > > } > > =20 > > object_property_set_int(OBJECT(cpu), apic_id, "apic-id", errp); > > @@ -904,14 +905,18 @@ static void pc_new_cpu(const char *cpu_model, > > int64_t apic_id, Error **errp) if (error_is_set(errp)) { > > if (cpu !=3D NULL) { > > object_unref(OBJECT(cpu)); > > + cpu =3D NULL; > > } > > } > > + return cpu; > > } > > =20 >=20 > Squash this into the pc_new_cpu() introduction? sure, it's less obvious why it would be needed but makes this patch smaller. >=20 > > void pc_cpus_init(const char *cpu_model) > > { > > int i; > > + X86CPU *cpu =3D NULL; > > Error *error =3D NULL; > > + SysBusDevice *ib; >=20 > icc maybe? Anything that more's comprehensible. ;) icc_bridge then. [...] > > diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c > > index e0ae07a..39396f1 100644 > > --- a/hw/intc/apic_common.c > > +++ b/hw/intc/apic_common.c > > @@ -21,6 +21,8 @@ > > #include "hw/i386/apic_internal.h" > > #include "trace.h" > > #include "sysemu/kvm.h" > > +#include "hw/qdev.h" > > +#include "hw/sysbus.h" > > =20 > > static int apic_irq_delivered; > > bool apic_report_tpr_access; > > @@ -282,12 +284,14 @@ static int apic_load_old(QEMUFile *f, void *opaqu= e, > > int version_id) return 0; > > } > > =20 > > -static int apic_init_common(SysBusDevice *dev) > > +static int apic_init_common(ICCDevice *dev) >=20 > Instead of mechanically replacing SysBusDevice with ICCDevice in qdev > init functions, please change to realize. Could be its own prepended > patch if you prefer. IRC with Andreas, agreed to do it only for ICCDevice. And do re-factoring of init() in APICs/IOAPIC later. >=20 > > { > > APICCommonState *s =3D APIC_COMMON(dev); > > + DeviceState *d =3D DEVICE(dev); > > APICCommonClass *info; > > static DeviceState *vapic; > > static int apic_no; > > + static bool mmio_registered; > > =20 > > if (apic_no >=3D MAX_APICS) { > > return -1; [...] > > @@ -375,7 +382,7 @@ static Property apic_properties_common[] =3D { > > =20 > > static void apic_common_class_init(ObjectClass *klass, void *data) > > { > > - SysBusDeviceClass *sc =3D SYS_BUS_DEVICE_CLASS(klass); > > + ICCDeviceClass *sc =3D ICC_DEVICE_CLASS(klass); >=20 > idc please. :) done >=20 > > DeviceClass *dc =3D DEVICE_CLASS(klass); > > =20 > > dc->vmsd =3D &vmstate_apic_common; > > @@ -387,7 +394,7 @@ static void apic_common_class_init(ObjectClass > > *klass, void *data)=20 > > static const TypeInfo apic_common_type =3D { [...] > > @@ -2120,7 +2121,7 @@ static void x86_cpu_apic_create(X86CPU *cpu, Error > > **errp) apic_type =3D "xen-apic"; > > } > > =20 > > - env->apic_state =3D qdev_try_create(NULL, apic_type); > > + env->apic_state =3D qdev_try_create(dev->parent_bus, apic_type); >=20 > qdev_get_parent_bus() according to header comment. done >=20 > > if (env->apic_state =3D=3D NULL) { [...] > Andreas >=20